Bug Report Checklist
Description
The openapi specification for Stripe fails with the following error:
Exception in thread "main" java.lang.RuntimeException: Could not process model 'payment_source'.Please make sure that your schema is correct!
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:539)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:960)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:511)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.IllegalArgumentException: Unreferenced enum custom,express,standard,ach_credit_transfer,ach_debit,acss_debit,alipay,au_becs_debit,bancontact,card,card_present,eps,giropay,ideal,klarna,multibanco,p24,sepa_debit,sofort,three_d_secure,wechat
at org.openapitools.codegen.languages.OCamlClientCodegen.toEnumName(OCamlClientCodegen.java:787)
at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:4057)
at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:3854)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:5882)
at org.openapitools.codegen.DefaultCodegen.addVars(DefaultCodegen.java:5803)
at org.openapitools.codegen.DefaultCodegen.updateModelForComposedSchema(DefaultCodegen.java:2850)
at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:3132)
at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1341)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:534)
... 4 more
With a subset of the spec that contains an enum with an empty string, the following exception is thrown:
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:539)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:960)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:511)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.IllegalArgumentException: Unreferenced enum
at org.openapitools.codegen.languages.OCamlClientCodegen.toEnumName(OCamlClientCodegen.java:787)
at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:4057)
at org.openapitools.codegen.DefaultCodegen.fromProperty(DefaultCodegen.java:3854)
at org.openapitools.codegen.DefaultCodegen.getComposedProperties(DefaultCodegen.java:8183)
at org.openapitools.codegen.DefaultCodegen.getComposedSchemas(DefaultCodegen.java:8165)
at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:3106)
at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1341)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:534)
... 4 more
openapi-generator version
7.0.1
OpenAPI declaration file content or url
https://github.com/stripe/openapi/blob/master/openapi/spec3.json
Generation Details
openapi-generator-cli generate -i spec3.json -g ocaml -o stripe-api
Steps to reproduce
Run above command and see that it quickly fails with the first exception. Slimming down the spec to a single endpoint that has an empty string as an enum shows the second error:
cat spec3.json | jq '(.paths = {"/v1/customers": .paths["/v1/customers"]}) | .components = {}' > spec3-slim.json
openapi-generator-cli generate -i spec3-slim.json -g ocaml -o stripe-api --skip-validate-spec
An example of the enum that trips it up is:
"support_url": {
"anyOf": [
{
"type": "string"
},
{
"enum": [
""
],
"type": "string"
}
]
}
After removing the empty enum, the generation succeeds for this single endpoint.
Related issues/PRs
Suggest a fix
For the first issue, it's unclear to me what the underlying problem is. For the second issue, it seems that empty string enums trip up the generator. I tried this with the java generator and it succeeded, so it seems to be specific to this generator.
Bug Report Checklist
Description
The openapi specification for Stripe fails with the following error:
With a subset of the spec that contains an enum with an empty string, the following exception is thrown:
openapi-generator version
7.0.1
OpenAPI declaration file content or url
https://github.com/stripe/openapi/blob/master/openapi/spec3.json
Generation Details
Steps to reproduce
Run above command and see that it quickly fails with the first exception. Slimming down the spec to a single endpoint that has an empty string as an enum shows the second error:
An example of the enum that trips it up is:
After removing the empty enum, the generation succeeds for this single endpoint.
Related issues/PRs
Suggest a fix
For the first issue, it's unclear to me what the underlying problem is. For the second issue, it seems that empty string enums trip up the generator. I tried this with the java generator and it succeeded, so it seems to be specific to this generator.