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

Schema with type object and items is being read as an array #4721

Open
AdityaSingh04SAP opened this issue Aug 26, 2024 · 0 comments
Open

Schema with type object and items is being read as an array #4721

AdityaSingh04SAP opened this issue Aug 26, 2024 · 0 comments

Comments

@AdityaSingh04SAP
Copy link

For all swagger files which have type mentioned as object and items is also present under the schema, the requests like these are being read as array which is wrong.

For example:

swagger: '2.0'
info:
  description: 'This is a TEST.'
  version: 1.0.0
  title: Test
host: www.abc.com
basePath: /api
schemes:
  - http
paths:
  /test:
    get:
      summary: Test
      description: 'test'
      operationId: test
      responses:
        '200':
          schema:
	    type: 'object'
            items:
              $ref: '#/definitions/myResponse'
          description: myResponse
definitions:
  myResponse:
    type: object
    properties:
      id:
        type: integer
        format: `int64'

Here, under schema details since we are passing items as a non-null object which has some value, it is treating it as a array object. But, if you look above that, you'll notice that we have defined the type for this, i.e., object. So, this is wrong. It should treat this also as an object instead of array.

This change was made as a part of the following issue:
#4109

This can be solved by checking if it contains a type or not. If it doesn't contain a type and items is present, then we can treat it as an array by default. But, if it contains type, then we should use that type instead of treating it as an array.
Can you please correct this?

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