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

Incorrect type set for AnyType Schemas #1603

Closed
spacether opened this issue Sep 6, 2021 · 3 comments
Closed

Incorrect type set for AnyType Schemas #1603

spacether opened this issue Sep 6, 2021 · 3 comments
Assignees

Comments

@spacether
Copy link
Contributor

spacether commented Sep 6, 2021

When parsing this v3.0.1 schema:

openapi: 3.0.1
info:
  title: ping test
  version: '1.0'
servers:
  - url: 'http://localhost:8000/'
paths:
  /ping:
    get:
      operationId: pingGet
      responses:
        '201':
          description: OK
components:
  schemas:
    AnyValue: {}
    AnyValueWithDesc:
      description: Can be any value - string, number, boolean, array or object.
    AnyValueNullable:
      nullable: true
      description: Can be any value, including `null`.
    AnyValueModel:
      description: test any value
      type: object
      properties:
        any_value:
          $ref: '#/components/schemas/AnyValue'
        any_value_with_desc:
          $ref: '#/components/schemas/AnyValueWithDesc'
        any_value_nullable:
          $ref: '#/components/schemas/AnyValueNullable'
    AnyValueModelInline:
      description: test any value inline
      type: object
      properties:
        any_value: {}
        any_value_with_desc:
          description: inline any value
        any_value_nullable:
          nullable: true
          description: inline any value nullable
        map_any_value:
          additionalProperties: {}
        map_any_value_with_desc:
          additionalProperties: 
            description: inline any value
        map_any_value_nullable:
          additionalProperties:
            nullable: true
            description: inline any value nullable
        array_any_value:
          items: {}
        array_any_value_with_desc:
          items: 
            description: inline any value
        array_any_value_nullable:
          items:
            nullable: true
            description: inline any value nullable

swagger-parser incorrectly defines the type of the schemas:

  • map_any_value as object when it should be null
  • map_any_value_with_desc as object when it should be null
  • map_any_value_nullable as object when it should be null
  • array_any_value as array when it should be null
  • array_any_value_with_desc as array when it should be null
  • array_any_value_nullable as array when it should be null

Using swagger-parser 2.0.26
For one of them here is the shown value of the schema

map_any_value -> {MapSchema@2888} "class MapSchema {
    class Schema {
        type: object
        format: null
        $ref: null
        description: null
        title: null
        multipleOf: null
        maximum: null
        exclusiveMaximum: null
        minimum: null
        exclusiveMinimum: null
        maxLength: null
        minLength: null
        pattern: null
        maxItems: null
        minItems: null
        uniqueItems: null
        maxProperties: null
        minProperties: null
        required: null
        not: null
        properties: null
        additionalProperties: class Schema {
            type: null
            format: null
            $ref: null
            description: null
            title: null
            multipleOf: null
            maximum: null
            exclusiveMaximum: null
            minimum: null
            exclusiveMinimum: null
            maxLength: null
            minLength: null
            pattern: null
            maxItems: null
            minItems: null
    "
@gracekarina
Copy link
Contributor

This ticket will be solved when 3.1 branch is merged.

frantuma pushed a commit that referenced this issue Mar 2, 2022
frantuma pushed a commit that referenced this issue May 22, 2022
frantuma pushed a commit that referenced this issue May 22, 2022
@spacether
Copy link
Contributor Author

Using swagger-parser 2.0.31

This issue is also happening for:

openapi: 3.0.3
info:
  title: openapi 3.0.3 sample spec
  description: sample spec for testing openapi functionality, built from json schema
    tests for draft6
  version: 0.0.1
paths: {}
components:
  schemas:
    PropertyRefsContainingComponentSchema:
      properties:
        foo:
          $ref: '#/components/schemas/PropertyRefsContainingComponentSchema'
      additionalProperties: false

PropertyRefsContainingComponentSchema type should be unset but it is incorrectly set to object

@frantuma
Copy link
Member

frantuma commented Jul 7, 2022

This should be fixed in #1768, see this comment.
Closing ticket, please reopen if you're experiencing further issues

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

3 participants