We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When having a required and nullable property in my OpenAPI spec, it becomes non-nullable in the Kotlin code.
Taking the YAML example later down in this bug report, it results in this Kotlin code with the kotlin-server generator:
kotlin-server
package com.example.models /** * * @param notNullableRequired * @param nullableRequired * @param nullableNotRequired * @param notNullableNotRequired */ data class Pet( val notNullableRequired: kotlin.String, val nullableRequired: kotlin.String, val nullableNotRequired: kotlin.String? = null, val notNullableNotRequired: kotlin.String? = null )
The nullableRequired example is incorrect, because it's supposed to be nullable. It should be kotlin.String? instead.
nullableRequired
kotlin.String?
7.8.0
# OpenAPI schemas support 4 possible combinations for properties: # 1. nullable + required # 2. nullable + not required # 3. not nullable + required # 4. not nullable + not required # This sample contains all of them to demonstrate how they are rendered in the generated code. openapi: 3.0.3 info: title: Nullable Required version: 1.0.0 servers: - url: /api/v3 paths: /pet: post: operationId: addPet requestBody: content: application/json: schema: $ref: '#/components/schemas/Pet' responses: "200": description: Successful operation content: application/json: schema: $ref: '#/components/schemas/Pet' components: schemas: Pet: required: - notNullable_required - nullable_required type: object properties: nullable_notRequired: type: string example: doggie nullable: true notNullable_notRequired: type: string example: doggie notNullable_required: type: string example: doggie nullable_required: type: string example: doggie nullable: true
Using the openapi-generator Gradle plugin:
openapi-generator
openApiGenerate { group = "build" generatorName = "kotlin-server" inputSpec = "src/main/resources/openapi/example.yaml" outputDir = "${layout.buildDirectory.get()}/generated/example" packageName = "com.example" library = "javalin6" }
Probably related issue: #14765
I'll provide a PR right after submitting this with a fix. It's a bug in the Mustache template.
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Bug Report Checklist
Description
When having a required and nullable property in my OpenAPI spec, it becomes non-nullable in the Kotlin code.
Taking the YAML example later down in this bug report, it results in this Kotlin code with the
kotlin-server
generator:The
nullableRequired
example is incorrect, because it's supposed to be nullable. It should bekotlin.String?
instead.openapi-generator version
7.8.0
OpenAPI declaration file content or url
Generation Details
Using the
openapi-generator
Gradle plugin:Steps to reproduce
kotlin-server
generatorRelated issues/PRs
Probably related issue: #14765
Suggest a fix
I'll provide a PR right after submitting this with a fix. It's a bug in the Mustache template.
The text was updated successfully, but these errors were encountered: