Generating Collection from OpenAPI returns [object Object]

I have an OpenAPI Schema and I used to generate collections for testing or documentation from it. However, i am now getting [object Object] in request bodies, when i used to get JSON request bodies following the schema definition.
What might be causing this [object Object] instead of the correct JSON?

An example request body used to be auto-generated such as in this screenshot from the API Schema

However, I am now getting request body with [object Object] as follows

I haven’t used the generate collection action for some time so i am guessing some update to Postman may be resulting into the generation no longer working

I have tried generating a previous version of the schema where the generation worked fine to make sure this issue is not due to recent changes made to the OpenAPI schema

Hi @mrabetr

This might sound weird, but I think there is formatting that is being passed too.

Try stripping out these dots and replace with spaces or tabs:
image

And see if it sends once they are removed…

hi @w4dd325, thanks for your response

However, my screenshots are showing body requests generated from the OpenAPI Schema, when generating a collection from it.
The first screenshot is the correct JSON that was auto-generated from the API Schema and it works perfectly fine when sending a POST request with that body.

The second screenshot is basically Postman app failing to auto-generate the request body.

Therefore, what used to work during the collection generation from the API Schema is no longer working. I don’t usually maintain my collections manually. i have been updating my API Schema (definition in the Postman API tab) and from it i generate the collection for testing or documentation purposes.

The fact that the auto-generation of the request bodies is failing is now causing concerns because i can no longer create new collections on the fly and use them immediately. without the request bodies generated i will then have to copy past them manually

Ahh sorry my mistake, I understand now.

It’s not something I have a lot of knowledge on to be honest, I’ll have a poke around and see if i can recreate a similar scenario.

I have been experiencing this issue as well. I have a workaround and info to help track the bug down. @mrabetr @w4dd325

After testing a bunch of prior version of Postman, I can say it was introduced in either v9.26.x or v9.27.0. I was not able to download any v9.26, but 9.25.2 works as expected, and 9.27.0 displays [object Object] for imported request/response bodies.

I’ve been downloading these by fiddling with the direct download links, eg. https://dl.pstmn.io/download/version/9.25.2/osx64 for the last version without the issue.

I’m on Mac but my colleague on windows has the same issues.

Here is some yaml that you can use as a bug repro:

openapi: 3.0.0
info:
  title: bug-repro
  version: '1.0'
  description: API specification.
servers:
  - url: 'http://localhost:5001'
paths:
  '/api/{tenancy}/name':
    parameters:
      - schema:
          type: string
        name: tenancy
        in: path
        required: true
        description: The tenancy id
    put:
      summary: Check name
      operationId: put-api-tenancy-name
      responses:
        '200':
          description: 'OK'
      requestBody:
        content:
          application/vnd.company.product.name-check-v1+json:
            schema:
              $ref: '#/components/schemas/Name-Check'
components:
  schemas:
    Name-Check:
      title: Name-Check
      description: |
        Model to check name uniqueness
      type: object
      properties:
        name:
          type: string
        type:
          type: integer
      required:
        - name
        - type

thanks @patrick-rsk for sharing your example.

After looking into your example i noticed that in the requestBody you’re using application/vnd.company.product.name-check-v1+json for the content type.

This has triggered me to try with application/json which doesn’t not result into [object Object], but instead it correctly generates the JSON:

{
  "name": "amet in",
  "type": -3872749
}

The reason that caught my attention is because i use application/vnd.api+json in my API

@w4dd325 can you flag this bug please. basically, if the content type of the requestBody is application/json in the OpenAPI, the collection generated from it does produce a valid JSON object. However, if the content type is application/vnd.api+json then this results into the [object Object] bug

I don’t work for Postman, but you can search for / open issues here:

sorry about that @w4dd325
thanks for sharing the link, i created a new issue:

1 Like