Ref to alias support
Closed this issue · 1 comments
Api sample:
Boundaries:
type: object
properties:
boundary:
$ref: "models.yaml#/components/schemas/Boundary"
Boundary:
type: array
items:
$ref: "models.yaml#/components/schemas/GeoCoordinates"
Expected kotlin generated entity:
data class BoundariesEntity(
val boundary: List<GeoCoordinates>?
)
surfgen lint
succeed, and the result for surfgen generate
doesn't provide expected result.
The entity template fix is required, but now it seems to be impossible to support such kind of api description. Type model properties have useful fields like isObject
, isArray
, but both of them are false for the given sample (checked in template with {{ property.typeModel.isArray }}, {{ property.typeModel.isObject }}
expression for boundary
).
Possible option: isArray
should return true
for this case, it would be helpful to handle it in the entity template.
Another sample:
/onboarding:
get:
security: []
parameters:
- name: type
in: query
required: true
schema:
$ref: “models.yaml#/components/schemas/OnboardingType”
OnboardingType:
type: string
enum: [“Onboarding”, “NewFeature”]
A query param which references to enum has the same problem.
An expected result in kotlin:
fun getOnboarding(
cityId: Int,
type: OnboardingType
): Single<List<OnboardingEntity>>
But the {{ parameter.typeModel.isObject }}
returns false and the {{ parameter.typeName }}
is empty, so we can only handle such enum as a primitive string using such condition {% elif parameter.typeModel.name == “string” or parameter.typeModel.aliasTypeName == “string” or parameter.typeModel.enumTypeName == “string” %}String
UPD There was an error in template. Instead of {{ parameter.typeName }}
use {{ parameter.typeModel.name }}
. Enum in params works fine