We have a schema which can either be null or a list of object. This is mainly to allow the parameter to be optionally passed and to detect if the property was set to do case distinction on. So passing null vs [] behaves differently. (Similarly, as passing and empty string vs null)
However, when encoding this in a spec and trying to generate an typescript-fetch client for this, it results in an error.
When running this through the OpenAPI generator, the swagger validation seems to fail.
$ java -jar "/node_modules/@openapitools/openapi-generator-cli/versions/7.9.0.jar" generate --input-spec="/test_schema.yaml" --generator-name="typescript-fetch" --output="/tmp/" --additional-properties="withInterfaces=true"
Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
| Error count: 1, Warning count: 3
Errors:
-attribute components.schemas.PaymentConfigurationResponse.default is not of type `array`
Warnings:
-attribute components.schemas.PaymentConfigurationResponse.default is not of type `array`
at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:717)
at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:744)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:527)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
My expectation is that this would be valid. I expect null defaults are allowed when nullable, regardless of the type (array in this case).
We have a schema which can either be null or a list of object. This is mainly to allow the parameter to be optionally passed and to detect if the property was set to do case distinction on. So passing null vs [] behaves differently. (Similarly, as passing and empty string vs null)
However, when encoding this in a spec and trying to generate an typescript-fetch client for this, it results in an error.
Spec I tried:
When running this through the OpenAPI generator, the swagger validation seems to fail.
My expectation is that this would be valid. I expect null defaults are allowed when nullable, regardless of the type (array in this case).