swagger-api / swagger-api/swagger-codegen-generators

Bug: Content-Type of responces examples (html generator)

Open
#965 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

Hi! I get code from example of docs: https://swagger.io/docs/specification/adding-examples/

image

and

image

and see:

image

Why Ron and Jessica is content type? The documentation doesn't have it.

src\main\resources\handlebars\htmlDocs\index.mustache
image

Reproduce:

openapi: 3.0.1

info:
  title:
  description:
  version:

paths:
  /users:
    post:
      summary: Adds a new user
      requestBody:
        content:
          application/json:     # Media type
            schema:             # Request body contents
              $ref: '#/components/schemas/User'   # Reference to an object
            examples:    # Child of media type
              Jessica:   # Example 1
                value:
                  id: 10
                  name: Jessica Smith
              Ron:       # Example 2
                value:
                  id: 11
                  name: Ron Stewart
      responses:
        '200':
          description: A user object.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'   # Reference to an object
              examples:
                Jessica:
                  value:
                    id: 10
                    name: Jessica Smith
                Ron:
                  value:
                    id: 20
                    name: Ron Stewart

components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: integer
          format: int64
          example: 1
        name:
          type: string
          example: New order

and run generation:

docker run --rm \
    -v $PWD:/local \
    swaggerapi/swagger-codegen-cli-v3:3.0.27 \
    generate \
        -i /local/openapi.yaml \
        -o /local/html \
        -l html

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/main/resources/handlebars/htmlDocs/index.mustache and reproduce the output using the provided OpenAPI YAML and Docker generation command. Trace how the example names are rendered and confirm that the generated HTML labels the response examples with the actual media type rather than Jessica or Ron.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
documentation
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.