Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving schema array items refs #2108

Open
cosmin-marginean opened this issue Jun 27, 2024 · 0 comments
Open

Resolving schema array items refs #2108

cosmin-marginean opened this issue Jun 27, 2024 · 0 comments

Comments

@cosmin-marginean
Copy link

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

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.

What should the outcome of resolving #/components/schemas/Child be in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant