OpenAPITools / OpenAPITools/openapi-generator

[BUG][HTML] Vendor-specific media type breaks Example Data

Open
#1,707 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: HTML Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

Using a vendor-specific media type causes the Example data section of the operation listing to be empty. Vendor-specific media types are fully supported by OpenAPI Spec 3.0 according to the 'Media Type Names' section on this page: https://swagger.io/docs/specification/media-types/

openapi-generator version

4.0.0-SNAPSHOT

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: Test
  description: Test YAML
  version: '1.0'
servers:
  - url: http://localhost
paths:
  /employees/{id}:
    get:
      operationId: getEmployeeById
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        200:
          description: Success
          content:
            application/vnd.john3300+json;version=1.0:
              schema:
                $ref: '#/components/schemas/employee'
components:
  schemas:
    employee:
      type: object
      properties:
        name:
          type: string
      required:
        - name
Command line used for generation

java -jar openapi-generator-cli-4.0.0-20181217.102953-101.jar generate -g html -i test.yaml

Related issues/PRs

None that I've seen.

Suggest a fix

The code to generate these example sections needs to use a regex to be able to correctly parse these vendor-specific media types and also any additional parameters (e.g. `;version=1.0) that are present.

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 by running the provided Java CLI command with the YAML declaration and inspect the generated HTML operation listing, focusing on the empty Example data section for the vendor-specific media type. Locate the HTML generator code responsible for parsing response content types, then verify that Example data appears for the supplied media type and its version parameter.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.