Skip to content

openapi spec returns schema of incorrect type #1252

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

Closed
spacether opened this issue Nov 13, 2019 · 1 comment
Closed

openapi spec returns schema of incorrect type #1252

spacether opened this issue Nov 13, 2019 · 1 comment

Comments

@spacether
Copy link
Contributor

If additionalProperties exists in the fruit model, then
final Schema schema = openAPI.getComponents().getSchemas().get("fruit");
returns an instance of MapSchema.
Without additionalProperties, it returns the correct type of ComposedSchema.

incorrectly returns MapSchema as the type of the above schema instance for fruit.

openapi: 3.0.1
info:
   title: fruity
   version: 0.0.1
paths:
   /:
      get:
         responses:
            '200':
               description: desc
               content:
                  application/json:
                     schema:
                        $ref: '#/components/schemas/fruit'
components:
   schemas:
      fruit:
         title: fruit
         properties:
            color:
               type: string
         oneOf:
            - $ref: '#/components/schemas/apple'
            - $ref: '#/components/schemas/banana'
         additionalProperties:
            type: string
      apple:
         title: apple
         type: object
         properties:
            kind:
               type: string
      banana:
         title: banana
         type: object
         properties:
            count:
               type: number

correctly returns ComposedSchema as the type of the above schema instance for fruit

openapi: 3.0.1
info:
   title: fruity
   version: 0.0.1
paths:
   /:
      get:
         responses:
            '200':
               description: desc
               content:
                  application/json:
                     schema:
                        $ref: '#/components/schemas/fruit'
components:
   schemas:
      fruit:
         title: fruit
         properties:
            color:
               type: string
         oneOf:
            - $ref: '#/components/schemas/apple'
            - $ref: '#/components/schemas/banana'
      apple:
         title: apple
         type: object
         properties:
            kind:
               type: string
      banana:
         title: banana
         type: object
         properties:
            count:
               type: number

Requested change:
When additionalProperties is included in a composed schema, please return an instance of ComposedSchema which includes additionalProperties info.

@gracekarina
Copy link
Contributor

Hi I just added a test and this is working now. thanks for the report.

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

2 participants