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

Generating a collection from a .yaml with deepObjects yields unexpected results #10752

Closed
1 task done
ericdehmel opened this issue Mar 14, 2022 · 3 comments
Closed
1 task done

Comments

@ericdehmel
Copy link

Is there an existing issue for this?

  • I have searched the tracker for existing similar issues

Describe the Issue

While generating a collection using an API specification I stumbled upon two issues with deepObjects:

  • List nested inside deepObjects are generated as deepObject[list][0]=value and deepObject[list][1]=value. I would have expected it to be deepObject[list]=value,value
  • If a deepObject has a property called length it will be interpreted as array and generate multiple parameters like deepObject[i] up to the number that is set as example for the length property.

Steps To Reproduce

  1. Click on Import
  2. Select the .yaml file:
openapi: 3.0.1
info:
  title: Demo
  version: "1.0"
paths:
  /get:
    get:
      operationId: someRequest
      parameters:
        - $ref: '#/components/parameters/DeepObjectNestedList'
        - $ref: '#/components/parameters/DeepObjectLengthParameter'
      responses:
        '200':
          description: Response on success.
components:
  parameters:
    DeepObjectNestedList:
      name: deepObjectNestedList
      in: query
      required: false
      style: deepObject
      schema:
        $ref: '#/components/schemas/DeepObjectNestedList'
      explode: true     
    DeepObjectLengthParameter:
      name: deepObjectLengthParameter
      in: query
      required: false
      style: deepObject
      schema:
        $ref: '#/components/schemas/DeepObjectLengthParameter'
      explode: true      
  schemas:
    DeepObjectLengthParameter:
      type: object
      properties:
        length:
          nullable: true
          type: integer
          format: int32
          minimum: 1
          example: 20    
    DeepObjectNestedList:
      type: object
      properties:
        nestedList:
          $ref: '#/components/schemas/NestedList'
          example: someValue,anotherValue  
    NestedList:
      nullable: true
      type: array
      items:
        type: string
        pattern: '[A-Z]{2}|[A-Z]{2}-[A-Z0-9]{1,3}'    
  1. In advanced settings, use Example to generate request parameters

Screenshots or Videos

image

Environment Information

- Operating System: Windows 10
- Platform Type: Native App
- Postman Version: 9.14.0

Additional Context?

No response

@VShingala
Copy link
Member

@ericdehmel Thanks for reporting the issue!

As I understand OpenAPI specification doesn't mention the behavior of array under deepObject style (source). This means currently, array is treated as an object and thus the behavior of each element is mentioned separately.

As for issue 2, Is the expected behavior to have the following key-value?

Key: deepObjectLengthParameter[length]
Value: 20

@ericdehmel
Copy link
Author

As you have guessed I expected to get deepObjectLengthParameter[length]=20.

@VShingala
Copy link
Member

@ericdehmel This issue should now be fixed. Feel free to reopen if you face any further problems.

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

No branches or pull requests

5 participants