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

[BUG] html2 generator: some schemas are generated empty #11204

Closed
3 of 5 tasks
OnkelTem opened this issue Dec 30, 2021 · 11 comments · Fixed by #18356
Closed
3 of 5 tasks

[BUG] html2 generator: some schemas are generated empty #11204

OnkelTem opened this issue Dec 30, 2021 · 11 comments · Fixed by #18356

Comments

@OnkelTem
Copy link

OnkelTem commented Dec 30, 2021

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

I'm trying to generate API docs for our API. I run html2 generator but it returns blank space where schemas should go.

openapi-generator version

5.3.1

OpenAPI declaration file content or url

I'm afraid I cannot provide the full API as it's covered by NDA. But here is a snippet for which schemas are not generated:

  /inputs:
    get:
      summary: All inputs data
      description: Returns a list of currently configured inputs
      operationId: inputsGet
      security:
        - bearerAuth: []
      tags:
        - inputs
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Inputs'
        '401':
          $ref: '#/components/responses/Unauthorized'
        default:
          $ref: '#/components/responses/Error'
#...
    Inputs:
      type: array
      items:
        $ref: '#/components/schemas/Input'
    Input:
      type: object
      required:
        - input_id
        - name
        - config
        - alerts_config
      properties:
        input_id:
          type: integer
        name:
          type: string
        # ...

It's just a regular API with paths and schemas. Nothing special.

It has perfectly generated code for more than 2 years. Recently we decided to generate docs using one of the html generators provided by this tool. GitLab renders the API using swagger w/o any problems.

Generation Details

We generate with html2 generator.

Steps to reproduce

The generator is launched with the following params:

$ npx openapi-generator-cli generate -i api_openapi.yaml -g html2 -o docs/api/

and it outputs empty schemas. Not all of them are empty, but most.

@hauntingEcho
Copy link
Contributor

Is this issue only when using $ref to define the structures (i.e. if you inline them then it works)? If so, I've been seeing similar issues: #11027

@madelinekosse
Copy link

I have also run into this issue: the outer level of the schema is correctly generated, but the property schemas are not, even when I define them inline.

For the following response schema:

responses:
        '200':
          description: Details about the registration given by the ID parameter
          content:
            application/json:
              schema:
                type: object
                properties:
                  meta:
                    type: object
                  items:
                    type: array
                    minItems: 1
                    maxItems: 1
                    items:
                      type: object
                      properties:
                        anInlineProperty:
                          type: string
                        anInlineObject:
                          type: object
                          properties:
                            id:
                              type: integer
                            name:
                              type: string

The html2 generator, with no customisation, produces the following:
image

@MapleWolf64
Copy link

Issue happens again with version 6.2.0
ok with version 6.1.0

@harish2704
Copy link
Contributor

harish2704 commented Oct 9, 2022

Hi,
I iterated through all previous versions and found that this bug does not exists with version 5.4.0
So, a workaround for this bug is to issue following command in our terminal

openapi-generator-cli version-manager set 5.4.0

( I downgraded my version from 6.2.0 to 5.4.0 )

@cgm-aw
Copy link

cgm-aw commented Jan 13, 2023

I can confirm this bug. Here is my reproducer:

{https://docs.github.com/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax
    "openapi": "3.0.1",
    "info": {
        "title": "Reproducer API for missing response schemas",
        "version": "0.0.1"
    },
    "paths": {
        "/appointments/{id}": {
            "get": {
                "summary": "test 1",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "successful operation",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/GetAppointmentsResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "client error, probably a wrong request"
                    },
                    "500": {
                        "description": "server error, probably a temporary problem"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "GetAppointmentsResponse": {
                "type": "object",
                "properties": {
                    "appointmentId": {
                        "type": "string"
                    }
                }
            }
        }
    }
}

openapi-generator-cli with html2 produces this:
image

@r-gruber
Copy link

r-gruber commented Mar 2, 2023

This problem still exists even in latest nightly build: openapi-generator-cli-6.5.0-20230302.132003-21.jar

Here is a simple test file:

openapi: '3.0.3'
info:
  title: 'Dummy'
  version: 1.0.0
servers:
- url: https://dummy/v1
tags:
  - name: DummyService
paths:
  '/info/{inDummyParam}':
    get:
      tags:
        - DummyService
      summary: 'Retrieve data'
      operationId: getDummy
      parameters:
        - $ref: '#/components/parameters/inDummyParam'
      responses:
        '200':
          description: 'Successful operation'
          content:
            application/json:
              schema:
                 $ref: '#/components/schemas/Ok2Dto'
        '400':
          description: 'Error'
          content:
            application/json:
              schema:
                 type: string
components:
  parameters:
    inDummyParam:
      name: inDummyParam
      in: path
      required: true
      schema:
        type: string
  schemas:
    Ok2Dto:
      description: 'Data set for information on a specific loading unit.'
      type: object
      required:
        - prop1
        - prop2
      properties:
        prop1:
          type: string
          description: Unique ID
        prop2:
          type: string
          description: Something else

Tested with latest nightly build version:
java -jar openapi-generator-cli-6.5.0-20230302.132003-21.jar generate -g html2 -i test.yaml -o htmlNightly
results in incorrect "Responses":
image

Tested with old 6.1.0 version:
java -jar openapi-generator-cli-6.1.0.jar generate -g html2 -i test.yaml -o html61
results in correct output:
image

@r-gruber
Copy link

r-gruber commented Mar 2, 2023

I can confirm that in version 6.2.0 it is already broken.
So somewhere between 6.1.0 and 6.2.0 the bug was introduced.

@wogri
Copy link

wogri commented Apr 19, 2023

I can confirm this is broken on 6.5.0 as well.

@stuartford
Copy link

All of my Schema tabs are now blank with 6.6.0.

@VeXell
Copy link

VeXell commented Nov 2, 2023

Same for me

@paranat
Copy link

paranat commented Feb 13, 2024

Still broken as of 7.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

12 participants