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

[REQ] Openapi response examples #16051

Open
emajo opened this issue Jul 10, 2023 · 0 comments · May be fixed by #17613
Open

[REQ] Openapi response examples #16051

emajo opened this issue Jul 10, 2023 · 0 comments · May be fixed by #17613

Comments

@emajo
Copy link
Contributor

emajo commented Jul 10, 2023

Is your feature request related to a problem? Please describe.

Working on the zapier generator came up the need to use response examples but actually are not supported by the generator.

Describe the solution you'd like

It would be great to have available in the templates the responses examples.

Describe alternatives you've considered

Additional context

There is already a TODO in the DefaultCodegen code -> https://github.com/OpenAPITools/openapi-generator/blob/fe78be405ed83c1d33045bc8bd5ea953f74a058f/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java#L4778C5-L4780C59

I suppose there are multiple ways to define response examples, here I have a simple spec (example added with stoplight studio):

I'm referring to the examples inside responses.content.application/json.examples

openapi: 3.0.0
servers:
  - url: 'http://petstore.swagger.io/v2'
info:
  description: 'This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.'
  version: 1.0.0
  title: OpenAPI Petstore
  license:
    name: Apache-2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
tags:
  - name: pet
    description: Everything about your Pets
paths:
  /pet:
    post:
      tags:
        - pet
      summary: Add a new pet to the store
      description: ''
      operationId: addPet
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
              examples:
                example-1:
                  value:
                    id: 0
                    name: doggie
components:
  schemas:
    Pet:
      title: a Pet
      description: A pet for sale in the pet store
      type: object
      required:
        - name
        - photoUrls
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
          example: doggie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant