Skip to content

[HTML] Does not accept additionalProperties flag for a schema within requestBody. #409

@sri3390

Description

@sri3390

Description

Currently the html generation fails for schemas that have the field additionalProperties mentioned within requestBody schema for openapi v3 with the exception:

[main] WARN  o.o.codegen.utils.URLPathUtils - 'host' not defined in the spec (2.0). Default to http://localhost
Exception in thread "main" java.lang.RuntimeException: Could not process model 'body_4'.Please make sure that your schema is correct!
	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:398)
	at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:783)
	at org.openapitools.codegen.cmd.Generate.run(Generate.java:315)
	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:58)
Caused by: java.lang.ClassCastException: java.lang.Boolean cannot be cast to io.swagger.v3.oas.models.media.Schema
	at org.openapitools.codegen.languages.StaticHtmlGenerator.getTypeDeclaration(StaticHtmlGenerator.java:121)
	at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:1782)
	at org.openapitools.codegen.DefaultCodegen.addParentContainer(DefaultCodegen.java:2970)
	at org.openapitools.codegen.DefaultCodegen.addAdditionPropertiesToCodeGenModel(DefaultCodegen.java:1539)
	at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:1523)
	at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1016)
	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:393)
	... 3 more

openapi-generator version

3.0.2, 3.0.3

OpenAPI declaration file content or url

https://gist.github.com/sri3390/18907fb14ad3b909eb6dd44c7036d80b

Command line used for generation

java -jar openapi-generator-cli-3.0.3-20180626.073419-19.jar generate -i openapi.json -g html -o /test

Steps to reproduce
Copy the json file linked and run the above command.

This works fine if we remove the flag defined here: https://gist.github.com/sri3390/18907fb14ad3b909eb6dd44c7036d80b#file-sample-json-file-L38.

This also works fine if additionalProperties is present in the response schemas.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions