postmanlabs / postman-app-support

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
https://www.postman.com
5.82k stars 839 forks source link

Documentation Generated from an OpenAPI Specification Fails Validation and Has Incorrect Indentation; Issue Resolution Creates Negative Integer Values #10953

Open k98kurz opened 2 years ago

k98kurz commented 2 years ago

Is there an existing issue for this?

Describe the Issue

When Documentation is generated from or synchronized to an OenAPI Specification document, integer path variables and schema attributes generate negative values like "-10968727" despite having examples like "1". Request bodies also have incorrect indentation upon generation, and the validation tool labels these as issues immediately after generation.

Additionally, if Documentation is generated from an OAS with the "Request parameter generation" and "Response parameter generation" options set to "Schema", running validation immediately thereafter results in issues for every such value, and these are then turned into the above-referenced negative values that appear to be coming from nowhere.

Steps To Reproduce

  1. Create an API.
  2. Paste in an OAS document (JSON; do not know if it breaks for YAML as well).
  3. Generate Documentation from the Overview tab setting the advanced options "Request parameter generation" and "Response parameter generation" to "Schema".
  4. Validate the Documentation in the Overview tab, then Review Issues.
  5. Look through the issues. It will complain about the auto-generated indentation being wrong and integer values being not negative. Select all issues and click the confirmation button to resolve them.
  6. All integers in path variables will be random negative values. Approximately 50% change that request body integers will be replaced with random negative values and 50% change they will be replaced with the example values specified in the OAS.

Screenshots or Videos

image image

Operating System

Linux

Postman Version

9.19.0

Postman Platform

Postman App

Additional Context?

No response

kristytoman commented 2 years ago

Hi, I just ran into this issue and I had a similar problem but I don't know if this is your case too.

You're talking about setting example to 1 but have you considered setting the minimum value in the schema definition?

Here's mine in YAML:

            parameters:
                - name: id
                  required: true
                  in: path
                  description: ID of the user
                  schema:
                      type: integer
                      format: int32
                      minimum: 1

Take care!