question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OpenAPI 3: Cannot create example from empty response

See original GitHub issue

I want to create examples with an empty response body. However, Microcks does not recognize the example at all, possibly because there is no matching response.

What’s the best way to achieve this?

Example

  openapi: 3.0.1
  info:
    title: sample
    version: '1.0'

  paths:
    /accounts/{accountId}:
      delete:
        parameters:
        - name: accountId
          in: path
          required: true
          schema:
            $ref: "#/components/schemas/accountId"
          examples:
            "Example 1":
              value: 396be545-e2d4-4497-a5b5-700e89ab99c0
        responses:
          204:
            $ref: "#/components/responses/NO_CONTENT_204"

  components:
    responses:
      NO_CONTENT_204:
        description:  No Content

    schemas:
      accountId:
        type: string
        format: uuid
      accountDetails:
        type: object
        properties:
          resourceId:
            type: string

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
my-flowcommented, Aug 26, 2020

@lbroudoux Thanks, this work-around makes the trick for now. You can close this issue.

1reaction
lbroudouxcommented, Aug 21, 2020

Sorry I was too quick answering and the response is syntactically incorrect. The syntactically correct form would be:

    responses:
      NO_CONTENT_204:
        description:  No Content
        content:
          application/json:
            schema:
              type: string   
            examples:
              "Example 1":
                 value: ''

This is just a suggestion as I do not have some time right now to test this. Will try to find some time on this week-end.

I don’t think your suggestion will work as you may have multiples responses with different response code (200, 201 or 204) that may depend on different input params and thus being different examples.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot generate OpenAPI 3.x code describing an HTTP ...
This annotation generates a compiler warning, due to the assignment of an empty generic array ( Array<Content> ) to a property with a...
Read more >
Open Api 3.0 HEAD with no responses property - Stack Overflow
I tried different variation, including empty property responses, empty object and it always fails the validation. Example can be preview on ...
Read more >
Describing Responses - Swagger
To learn about the latest version, visit OpenAPI 3 pages. Describing Responses. An API specification needs to specify the responses for all API...
Read more >
OpenAPI Specification v3.1.0 | Introduction, Definitions, & More
An exception is if the path item is empty, for example due to ACL constraints, matching path parameters are not required. The value...
Read more >
Set up method responses in API Gateway - AWS Documentation
There is no need for you to set up the API method response. ... For example, responses of 200, 400, and 500 indicate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found