Skip to content

OpenAPI import: application/problem+json responses don't generate a body #2009

@SimonBachmaier

Description

@SimonBachmaier

Describe the bug

When importing an environment from an OpenAPI/Swagger document, any responses with the content type application/problem+json is imported without a generated body.
If I change the media type to application/json in the same OpenAPI document, Mockoon generates a body as expected.
This makes it difficult to work with APIs that use RFC 7807 problem details, which typically use application/problem+json as their content type.

Steps to Reproduce

  • Create a new local environment from OpenAPI/Swagger
  • Paste the OpenAPI spec content below:
paths:
 /memes/{memeId}:
   parameters:
     - name: memeId
       in: path
       description: meme Object Id
       required: true
       schema:
         $ref: '#/components/schemas/MemeId'
   get:
     summary: Returns one meme with specified Id.
     description: This resource represents an individual meme in the system. Each meme is identified by a id.
     responses:
       "200":
         description: OK
         content:
           application/json:
             schema:
               $ref: "#/components/schemas/Meme"
       "400":
         description: A JSON array of Error Details
         content:
           application/problem+json:
             schema:
               $ref: "#/components/schemas/ErrorDetails"
       '401':
         description: Unauthorized
         content:
           application/problem+json:
             schema:
               $ref: '#/components/schemas/ErrorDetails'
       '404':
         description: Not Found
         content:
           application/problem+json:
             schema:
               $ref: '#/components/schemas/ErrorDetails'
             example:
               error: NOT_FOUND
               errorDescription: Meme not found
               errorUri: https://foo.bar.com/error
               errorId: "not-found-123"
               additionalMessages: []
  • Complete the import and inspect the generated response
  • Now change the content type in the OpenAPI document from appication/problem+json to application/json, re-import and compare the generated response body

Mockoon version:

9.4.0

OS / OS version:

Windows 11

Metadata

Metadata

Assignees

Labels

component:lib-commonsIssue related to the @mockoon/commons libeffort:easyQuick fixes or small taskspriority:lowNice-to-have features or minor issuesstatus:approvedIssue confirmed for implementation

Projects

Status

📦 Released (v9.5.0)

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions