You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, changes made to Kotlin serialization configurations, such as setting a naming strategy to snake_case (e.g., via JsonNamingStrategy.SnakeCase), are not reflected in the generated OpenAPI specification when using SmallRye OpenAPI. This contrasts with Jackson configurations, where naming strategy changes (e.g., PropertyNamingStrategy.SNAKE_CASE) do propagate to the OpenAPI spec. For projects avoiding Jackson in favor of Kotlin serialization, this lack of support creates inconsistencies and fails to meet certain validation requirements, such as those enforced by the IBM API validator.
Main Goals
To ensure compatibility with Kotlin serialization and compliance with validators like IBM's, we need the following features:
Kotlin Serialization Reflection in OpenAPI: Annotations (e.g., @SerialName) and custom serializers (e.g., for enums) defined in Kotlin serialization should be reflected in the generated OpenAPI specification.
Global Naming Strategy Support: Setting a global naming strategy (e.g., snake_case) in Quarkus configuration (e.g., quarkus.kotlinx.serialization.naming-strategy=SnakeCase) should apply to the OpenAPI spec for properties and enums.
Current Behavior
When using Kotlin serialization with Json { namingStrategy = JsonNamingStrategy.SnakeCase }, the OpenAPI spec still uses camelCase for property names.
Explicit annotations like @SerialName("snake_case") or custom serializers for enums are not honored in the OpenAPI output.
Jackson-based configurations (e.g., ObjectMapper with PropertyNamingStrategy.SNAKE_CASE) correctly influence the OpenAPI spec, but we aim to avoid Jackson dependencies.
This results in validation failures with tools like the IBM API validator, which require snake_case for properties and enums.
Expected Behavior
Kotlin serialization configurations, including JsonNamingStrategy.SnakeCase and annotations like @SerialName, should be respected in the generated OpenAPI spec.
A global configuration option (e.g., in Quarkus) should allow setting a naming strategy (e.g., snake_case) that applies to all schemas in the OpenAPI output.
Enums and properties serialized with snake_case (via naming strategy) should appear as snake_case in the OpenAPI spec to ensure compliance with validators like IBM's.
Description: Integer schemas (e.g., for query parameters like id) must define minimum and maximum properties. For example, the annotation @Size(min = 1, max = 100) @QueryParam("id") ids: List<@Min(0) @Max(Long.MAX_VALUE) Long> does not generate items.minimum or items.maximum in the OpenAPI
Rule ID: ibm-accept-and-return-models
Description: Request and response bodies must define properties (i.e., be objects). Returning Unit (e.g., in DELETE endpoints) generates an empty schema, which violates this rule.
Rule ID: ibm-use-date-based-format
Description: The @Schema(format = "date-time") annotation on OffsetDateTime fields is not correctly reflected in the generated OpenAPI spec. As a result, the OpenAPI output omits the expected format: date-time
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Issue Description
Currently, changes made to Kotlin serialization configurations, such as setting a naming strategy to
snake_case
(e.g., viaJsonNamingStrategy.SnakeCase
), are not reflected in the generated OpenAPI specification when using SmallRye OpenAPI. This contrasts with Jackson configurations, where naming strategy changes (e.g.,PropertyNamingStrategy.SNAKE_CASE
) do propagate to the OpenAPI spec. For projects avoiding Jackson in favor of Kotlin serialization, this lack of support creates inconsistencies and fails to meet certain validation requirements, such as those enforced by the IBM API validator.Main Goals
To ensure compatibility with Kotlin serialization and compliance with validators like IBM's, we need the following features:
@SerialName
) and custom serializers (e.g., for enums) defined in Kotlin serialization should be reflected in the generated OpenAPI specification.snake_case
) in Quarkus configuration (e.g.,quarkus.kotlinx.serialization.naming-strategy=SnakeCase
) should apply to the OpenAPI spec for properties and enums.Current Behavior
Json { namingStrategy = JsonNamingStrategy.SnakeCase }
, the OpenAPI spec still usescamelCase
for property names.@SerialName("snake_case")
or custom serializers for enums are not honored in the OpenAPI output.ObjectMapper
withPropertyNamingStrategy.SNAKE_CASE
) correctly influence the OpenAPI spec, but we aim to avoid Jackson dependencies.snake_case
for properties and enums.Expected Behavior
JsonNamingStrategy.SnakeCase
and annotations like@SerialName
, should be respected in the generated OpenAPI spec.snake_case
) that applies to all schemas in the OpenAPI output.snake_case
(via naming strategy) should appear assnake_case
in the OpenAPI spec to ensure compliance with validators like IBM's.small reproducer
Issues Identified with IBM API Validator
Rule ID: ibm-integer-attributes
Description: Integer schemas (e.g., for query parameters like id) must define minimum and maximum properties. For example, the annotation
@Size(min = 1, max = 100) @QueryParam("id") ids: List<@Min(0) @Max(Long.MAX_VALUE) Long>
does not generate items.minimum or items.maximum in the OpenAPIRule ID: ibm-accept-and-return-models
Description: Request and response bodies must define properties (i.e., be objects). Returning Unit (e.g., in DELETE endpoints) generates an empty schema, which violates this rule.
Rule ID: ibm-use-date-based-format
Description: The @Schema(format = "date-time") annotation on OffsetDateTime fields is not correctly reflected in the generated OpenAPI spec. As a result, the OpenAPI output omits the expected format: date-time
The text was updated successfully, but these errors were encountered: