swagger-api / swagger-core

Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API
http://swagger.io
Apache License 2.0
7.36k stars 2.17k forks source link

Distinguish between no default value specified and a default value `null` specified in the OpenAPI. #4664

Open simon-spinner opened 2 months ago

simon-spinner commented 2 months ago

Schema::getDefault() today returns a null value if no default value is specified in the OpenAPI document. The OpenAPI standard allows to explicitly specify null when a property is nullable. However this case cannot be detected because Schema:getDefault() will return null in that situation, too. An additional boolean flag Schema::hasDefaultValue() would be required.

Use case is the OpenAPI generator, where I would like to generate special code if the default value is set explicitly to null.