Open cosmin-marginean opened 1 week ago
I've been struggling to understand how resolving refs works and I've created a basic example to try and reproduce what I think should happen when setting resolve to true.
resolve
Below is the YAML spec
openapi: 3.0.3 components: schemas: Child: type: object properties: name: type: string Parent: type: object properties: children: type: array items: $ref: '#/components/schemas/Child'
The (Kotlin) code to parse this is as follows
val parseOptions = ParseOptions() parseOptions.isResolve = true val parseResult = OpenAPIParser().readLocation("spec.yaml", null, parseOptions) val childrenProperty = parseResult.openAPI.components .schemas["Parent"]!! .properties["children"]!! println(childrenProperty.items.`$ref`) println(childrenProperty.items.type)
This prints out
#/components/schemas/Child null
That is, $ref for the items in the children array is still a full reference (i.e. not dereferenced) and the type is null.
$ref
children
type
What should the outcome of resolving #/components/schemas/Child be in this case?
#/components/schemas/Child
I've been struggling to understand how resolving refs works and I've created a basic example to try and reproduce what I think should happen when setting
resolve
to true.Below is the YAML spec
The (Kotlin) code to parse this is as follows
This prints out
That is,
$ref
for the items in thechildren
array is still a full reference (i.e. not dereferenced) and thetype
is null.What should the outcome of resolving
#/components/schemas/Child
be in this case?