Skip to content
New issue

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

Fix some issues in generated OpenAPI spec #824

Merged
merged 2 commits into from
Aug 16, 2024

Conversation

mnonnenmacher
Copy link
Contributor

Please see the commit messages for details.

@mnonnenmacher
Copy link
Contributor Author

@mmurto I have verified that this fixes the issues in #797.

Enable the option to mark optional properties as not required in the
OpenAPI spec. Otherwise, some (but for some reason not all) properties
with default arguments are still marked as required in the generated
OpenAPI spec.

Relates to eclipse-apoapsis#605.

Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
The `OptionalValue` class is only used in Kotlin code to model the
difference between `null` values and not present values for PATCH
requests. In the JSON request bodies such properties can simply be
omitted.

Configure type redirects for `OptionalValue` to its generic types used
in the API classes to eliminate the class from the generated OpenAPI
spec.

Fixes eclipse-apoapsis#821.
Relates to eclipse-apoapsis#605.

Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
@@ -116,7 +117,9 @@ fun Application.configureOpenApi() {
}
.connectSubTypes()
.handleNameAnnotation()
.generateSwaggerSchema()
.generateSwaggerSchema {
optionalHandling = OptionalHandling.NON_REQUIRED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird that it is not the default to mark optional properties as not required... 😕

@sschuberth sschuberth added this pull request to the merge queue Aug 16, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 16, 2024
@sschuberth sschuberth added this pull request to the merge queue Aug 16, 2024
Merged via the queue into eclipse-apoapsis:main with commit f342054 Aug 16, 2024
12 checks passed
@mnonnenmacher mnonnenmacher deleted the fix-openapi-spec branch August 16, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants