-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Closed
Description
Description
Few very minor bugs around how default values and required fields are handled in requestBodys and parameters. In particular in correct use of nullable types (?).
- Request bodies are not respecting the
requiredfield when provided. Therefore types are not being correctly set as null-able in controller method signatures.
requestBodies:
MetaInfoBody:
required: true # no matter if set to true or false
content:
application/json:
schema:
$ref: "#/components/schemas/MetaInfo"The above definition yields the below code no matter if required is set to true of false.
bodiesPost(@RequestBody metaInfo: MetaInfo)- Request parameters that have default values, the types remain null-able. For example, a request parameter such as the following, which has required
falsebut has a default value, still set the types in theRequestParamas null-able.
components:
parameters:
Limit:
name: "limit"
in: query
required: false # required is false, but has a default
schema:
type: "integer"
minimum: 1
maximum: 50
default: 10The above definition would yields:
@RequestParam(value = "limit", required = false, defaultValue = "10") limit: Int? // <-- still null-ableopenapi-generator version
Latest release - org.openapitools:openapi-generator:2.3.2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels