Skip to content

[BUG][PYTHON] Valid schema fails to generate server code #15762

@redbass

Description

@redbass

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?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I'm building openapi-generator to build a basic Python mock server based on this valid schema:

I'm using this command

docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
    -i https://tower.nf/openapi/nextflow-tower-api-1.19.0.yml \
    -g python-flask \
    -o /local/out/python

and the error is:

[main] WARN  o.o.codegen.DefaultCodegen - 'oneOf' is intended to include only the additional optional OAS extension discriminator object. For more details, see https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.9.2.1.3 and the OAS section on 'Composition and Inheritance'.
[main] WARN  o.o.c.l.AbstractPythonCodegen - Type null not handled properly in toExampleValue
[main] ERROR o.o.codegen.DefaultCodegen - Error in generating `example` for the property launch. Default to ERROR_TO_EXAMPLE_VALUE. Enable debugging for more info.
[main] ERROR o.o.codegen.DefaultCodegen - Error in generating `example` for the property launch. Default to ERROR_TO_EXAMPLE_VALUE. Enable debugging for more info.
[main] WARN  o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: AbstractGridConfig
[...]
[main] WARN  o.o.codegen.DefaultCodegen - allOf with multiple schemas defined. Using only the first one: ComputeEnv.Status
[main] WARN  o.o.c.l.AbstractPythonCodegen - Type null not handled properly in toExampleValue
Exception in thread "main" java.lang.RuntimeException: Could not process model 'Credentials'.Please make sure that your schema is correct!
	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:527)
	at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:948)
	at org.openapitools.codegen.cmd.Generate.execute(Generate.java:487)
	at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
	at java.base/java.lang.StringLatin1.charAt(Unknown Source)
	at java.base/java.lang.String.charAt(Unknown Source)
	at org.openapitools.codegen.languages.AbstractPythonConnexionServerCodegen.postProcessPattern(AbstractPythonConnexionServerCodegen.java:740)
	at org.openapitools.codegen.languages.AbstractPythonConnexionServerCodegen.postProcessModelProperty(AbstractPythonConnexionServerCodegen.java:623)
	at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:3093)
	at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1327)
	at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:522)
	... 4 more
openapi-generator version

This specific error occurs for all v6.0.0+
It works for v5.4.0

OpenAPI declaration file content or url

https://tower.nf/openapi/nextflow-tower-api-1.19.0.yml

Generation Details
Steps to reproduce
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
    -i https://tower.nf/openapi/nextflow-tower-api-1.19.0.yml \
    -g python-flask \
    -o /local/out/python
Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions