openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

schemas are blank in html2 generatation

Open jcald1 opened this issue 6 years ago • 5 comments
trafficstars

I pulled the latest openapitools/openapi-generator-cli Docker image: 193486a2ca74

Command:

docker run --rm -w /local -v ${PWD}:/local openapitools/openapi-generator-cli generate -i openapi.yaml -g html2

Opened the generated index.html file and saw that all of the schemas were blank. When I ran the html2 generator in https://github.com/swagger-api/swagger-codegen, the schemas were populated.

openapi.yaml: https://raw.githubusercontent.com/PresencePG/grip-server/feature/time-series/documentation/openapi.yaml?token=ABKWFWZBSGDI6FYD4JA4IWS5OAR5Q

jcald1 avatar Aug 28 '19 20:08 jcald1

👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

auto-labeler[bot] avatar Aug 28 '19 20:08 auto-labeler[bot]

Any updates on this? I see the same behavior.

JogoShugh avatar Apr 15 '20 13:04 JogoShugh

I ran into the problem that a single schema was blank. In my case this was fixed by turning

... :
    schema:
        $ref: '#/components/schemas/X'
components:
    schemas:
        X:
            type: array
            items:
                $ref: '#/components/schemas/Y'
        Y:
            ...

into

... :
    schema:
        type: array
        items:
            $ref: '#/components/schemas/Y'
components:
    schemas:
        Y:
            ...

This might be related to this issue. The first snippet used to work, however, in an old version of openapi-generator. So there seems to be a regression.

bachorp avatar Mar 11 '21 06:03 bachorp

Any update on this? I am facing the same issue too.

nmandya avatar May 31 '21 03:05 nmandya

Any update on this? I am facing the same issue too.

May want to try openapigenerator version 6.0.0. Something broke starting with 6.0.1 regarding schema refs when using the html2 generator. https://github.com/OpenAPITools/openapi-generator/issues/12842 It's still broken in 6.0.2

haydenm315 avatar Aug 09 '22 13:08 haydenm315

This also happened to me on version 6.2.0 (from the Arch repositories), but without using any references. Here is a (sort of) minimal example that results in empty schemas:

openapi: 3.0.3
info:
  title: Minimal example
  description: |-
    description …
  contact:
    email: [email protected]
  license:
    name: proprietary
    # url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: 0.1
paths:
  /test:
    post:
      operationId: test
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  enabled:
                    type: boolean
        '405':
          description: Some reason
      security: []

I build the documentation with:

$ openapi-generator-cli generate -i example.yaml -g html2 -o output

There is an empty box shown where I'd expect the template to be. Moving the schema into a request works as expected.

Edit: Here is the output of the command:

[main] INFO  o.o.codegen.DefaultGenerator - Generating with dryRun=false
[main] INFO  o.o.codegen.DefaultGenerator - OpenAPI Generator: html2 (documentation)
[main] INFO  o.o.codegen.DefaultGenerator - Generator 'html2' is considered stable.
[main] INFO  o.o.codegen.InlineModelResolver - Inline schema created as test_200_response. To have complete control of the model name, set the `title` field or use the inlineSchemaNameMapping option (--inline-schema-name-mapping in CLI).
[main] INFO  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] INFO  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] INFO  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] INFO  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] INFO  o.o.codegen.TemplateManager - writing file /home/$USER/tmp/2022-10-04 openapi-minimal-example-test/output/index.html
[main] INFO  o.o.codegen.TemplateManager - Skipped /home/$USER/tmp/2022-10-04 openapi-minimal-example-test/output/.openapi-generator-ignore (Skipped by supportingFiles options supplied by user.)
[main] INFO  o.o.codegen.TemplateManager - writing file /home/$USER/tmp/2022-10-04 openapi-minimal-example-test/output/.openapi-generator/VERSION
[main] INFO  o.o.codegen.TemplateManager - writing file /home/$USER/tmp/2022-10-04 openapi-minimal-example-test/output/.openapi-generator/FILES
################################################################################
# Thanks for using OpenAPI Generator.                                          #
# Please consider donation to help us maintain this project 🙏                 #
# https://opencollective.com/openapi_generator/donate                          #
################################################################################

(I have replaced my user name with $USER)

lrittel avatar Oct 04 '22 13:10 lrittel

And I did some further testing. The example above is broken in version 6.0.1 but works in 6.0.0. So it seems to be a regression in version 6.0.1. Both version were from the Arch Package Archive (if that matters). I don't have the time to investigate further atm. For now, I'll stay at 6.0.0, but going forward, I can see this becoming a deal breaker for me :/ .

Oh and I forgot to mention that examples are not rendered as well (yes, the example given above does not include one).

lrittel avatar Oct 04 '22 13:10 lrittel