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

Openapi (OAS 3.0) deepObject incorrect rendering on import. #9053

Closed
n2ygk opened this issue Sep 13, 2020 · 6 comments
Closed

Openapi (OAS 3.0) deepObject incorrect rendering on import. #9053

n2ygk opened this issue Sep 13, 2020 · 6 comments

Comments

@n2ygk
Copy link

n2ygk commented Sep 13, 2020

Describe the bug
Import of a deepObject parameter definition results in incorrect query parameters.

To Reproduce
Steps to reproduce the behavior:

  1. Import the attached example openapi spec file which has this definition:
     fields:
       name: fields
       in: query
       description: '[sparse fieldsets](https://jsonapi.org/format/#fetching-sparse-fieldsets)'
       required: false
       style: deepObject
       schema:
         type: object
       explode: true
  2. Look at the query parameters generated, e.g. for the GET of /v1/Courses: &fields[0]=<&fields[1]=o&fields[2]=b&fields[3]=j&fields[4]=e&fields[5]=c&fields[6]=t&fields[7]=> and note that this is the word spelled out.

    Expected behavior
    Not quite sure other than perhaps ignore deepObjects when converting to query parameters. Certainly spelling out the word <object> is not the right behavior.

    App information (please complete the following information):

    • App Type: Native App
    • Postman Version 7.31.1 (7.31.1)
    • OS: macOS Catalina 10.15.6 (19G2021)

    t4.yaml.txt

@VShingala
Copy link
Member

@n2ygk Thanks for reporting issue.

The issue is happening due to wrong handling of empty objects, which is fixed with postmanlabs/openapi-to-postman#294 and should be available in App with upcoming releases.

This will mean that for mentioned parameter object no query params will be added.

Also just to confirm that issue is present only when no properties are mentioned for schema with type object. And current behaviour is whenever properties are present, they should be to added as query params for each property.

i.e. for following query

name: fields
in: query
description: '[sparse fieldsets](https://jsonapi.org/format/#fetching-sparse-fieldsets)'
required: true
style: deepObject
schema:
  type: object
  properties:
    hello:
      type: string
    world:
      type: integer
explode: true

below mentioned query params should be present.

fields[hello] = <string>
fields[world] = <integer>

@VShingala VShingala self-assigned this Sep 14, 2020
@n2ygk
Copy link
Author

n2ygk commented Sep 14, 2020

@VShingala Thanks! For the time being I've changed my definition like this:

    fields:
      name: fields
      in: query
      description: '[sparse fieldsets](https://jsonapi.org/format/#fetching-sparse-fieldsets).

        Use fields[\<typename\>]=field1,field2,...,fieldN'
      required: false
      style: deepObject
      schema:
        type: object
        properties:
          <typename>:
            type: string
      explode: true

This generates a single query parameter like this: fields[<typename>]=<string>

@VShingala
Copy link
Member

@n2ygk This issue has been resolved with the latest App release v7.33. Closing this for now.

@n2ygk
Copy link
Author

n2ygk commented Nov 5, 2020

@n2ygk This issue has been resolved with the latest App release v7.33. Closing this for now.

@VShingala I don't think this is fixed. I'm seeing the same behavior with v7.35 for this:

    fields:
      name: fields
      in: query
      description: '[sparse fieldsets](https://jsonapi.org/format/#fetching-sparse-fieldsets).

        Use fields[\<typename\>]=field1,field2,...,fieldN'
      required: false
      style: deepObject
      schema:
        type: object
      explode: true

image

@VShingala
Copy link
Member

VShingala commented Nov 5, 2020

@n2ygk 🤔 I verified the solution for option Request parameter generation set to Example which seems to work and skip this param as it's an empty object. And looks like for option set to Schema, the problem is still there because essentially placeholder for object is <object> which isstring is treated as object and separated into multiple query param handling.

I will reopen this issue, and keep this thread updated with any development. Thanks for testing it.

@VShingala
Copy link
Member

@n2ygk This issue has been fixed for some time now. Current behavior is for both Schema and Example as value for option Request parameter generation will result in no query parameter being added for a schema with type object but no properties.

I'll close the issue, but feel free to re-open 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

4 participants