Bug Report Checklist
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.
Description
openapi-generator version
7.9.0
OpenAPI declaration file content or url
openapi: '3.0.3'
info:
title: Test
version: 0.1.0
paths: {}
components:
schemas:
Test:
type: array
items:
type: string
default: null
nullable: true
Generation Details
$ 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)
Steps to reproduce
Run the command with the given schema
Related issues/PRs
None
Suggest a fix
null defaults are allowed when nullable, regardless of the type (array in this case).
Bug Report Checklist
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
nullvs[]behaves differently. (Similarly, as passing and empty string vsnull)However, when encoding this in a spec and trying to generate an typescript-fetch client for this, it results in an error.
Description
openapi-generator version
7.9.0OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Run the command with the given schema
Related issues/PRs
None
Suggest a fix
nulldefaults are allowed when nullable, regardless of the type (arrayin this case).