[jaxrs-spec] Fix builder field type for JsonNullable properties - #10
Closed
Ignacio-Vidal wants to merge 13 commits into
Closed
[jaxrs-spec] Fix builder field type for JsonNullable properties#10Ignacio-Vidal wants to merge 13 commits into
Ignacio-Vidal wants to merge 13 commits into
Conversation
…ols#22494) (OpenAPITools#23398) * [python-fastapi] Default default value ... instead of None (OpenAPITools#22494) With various FastAPI parameters (Query, Path, Header, Cookie, Body, Form, and File) the default value of None is a valid value, but signifies that the parameter is optional. To allow for required parameters, default should either not be set at all or be set to '...' (ellipsis). Issue: OpenAPITools#22494 * Update samples after previous changes * Add generated newlines * Adjust test to expect ... Since the initial PR, a new test was added expecting None rather than '...'. Changing test and samples as needed. * Update test and samples after last change A new test needed to be adjusted, the Form was required so ... is more appropriate than None.
…4534) Bumps [docker/login-action](https://github.com/docker/login-action) from 4 to 4.5.2. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](docker/login-action@v4...v4.5.2) --- updated-dependencies: - dependency-name: docker/login-action dependency-version: 4.5.2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [sbt/setup-sbt](https://github.com/sbt/setup-sbt) from 1 to 1.5.4. - [Release notes](https://github.com/sbt/setup-sbt/releases) - [Commits](sbt/setup-sbt@v1...v1.5.4) --- updated-dependencies: - dependency-name: sbt/setup-sbt dependency-version: 1.5.4 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ols#24536) A server presenting a certificate issued by a private CA is unreachable by a generated client: the default trust store holds public authorities only, and Configuration exposed no way to say otherwise. The escape hatch it does offer, `Configuration#use`, cannot help — Faraday settles TLS when it builds the connection, before any middleware runs. `ssl` is handed to Faraday verbatim, so anything the adapter understands works, `{ ca_file: ... }` and `{ verify: false }` alike. It defaults to an empty hash, which is what Faraday assumes when the option is absent, so generated clients are unchanged unless they set it. - configuration.mustache: add the :ssl accessor, initialized to {} - connection.mustache: pass it to Faraday.new as a connection option - README.mustache: document it in the configuration example - Regenerate the petstore and qdrant samples Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ttributes (OpenAPITools#24533) * ✨ Added required and dataType properties to validationAttributes.mustache in typescript-fetch generator * Updated samples * Fix HTML escaping
…ITools#23778) Co-authored-by: Kaan <kaannkara@icloud.com>
* fix(dart-dio): PATCH tri-state optional handling * fix(dart-dio): avoid whitespace-only sample churn in class template * fix(dart-dio): remove trailing ? from Optional-wrapped fields The outer Optional should never be null—only the inner value can be null. Field type should be Optional<T?>, not Optional<T?>? This fixes compilation errors when serializer tries to access .isPresent on a potentially null Optional. * fix: more testings which ended up actually needing the deserialization part --------- Co-authored-by: Jeffrey Oloresisimo <jeffrey.oloresisimo@tmasystems.com>
…APITools#23429) Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
…avalin templates (OpenAPITools#24556) * [kotlin] Add = null default for optional parameters in jvm-ktor and javalin templates Fixes OpenAPITools#23100 Several Kotlin templates made optional parameters nullable (Type?) but did not assign = null as a default value, forcing callers to explicitly pass null for every optional parameter instead of omitting them. Updated templates: - kotlin-client/libraries/jvm-ktor/api.mustache - kotlin-server/libraries/javalin5/service.mustache - kotlin-server/libraries/javalin5/serviceImpl.mustache - kotlin-server/libraries/javalin6/service.mustache - kotlin-server/libraries/javalin6/serviceImpl.mustache Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [kotlin] Add `= null` default for optional parameters in jvm-ktor templates and javalin serviceImpls Expanded test coverage for jvm-ktor optional parameters to verify `= null` defaults in generated code. Updated javalin5 and javalin6 serviceImpl templates to include correct default value assignments. * [kotlin] Fix nullable Flow types in javalin5 and javalin6 service templates * Update samples for kotlin jvm-ktor and javalin templates Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [kotlin] Simplify default value template logic per PR review Move defaultValue outside required-check since it always applies, simplify nullable/default patterns in jvm-ktor api.mustache and javalin5/javalin6 service.mustache templates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * [kotlin] Add default `= null` for optional parameter in `addPet` method * disabled failing tests --------- Co-authored-by: Bartłomiej Kozak <b.kozak@avsystem.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Bartłomiej Kozak <bartlomiejkozak@proton.me>
* normalize 3.1 spec map schema * update samples * return updated map schema * refactor nullable check * Update modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
With `generateBuilders=true`, a property carrying
`x-is-jackson-optional-nullable` produced a model that does not compile:
error: incompatible types: String cannot be converted to JsonNullable<String>
The pojo field is rendered as `JsonNullable<T>`, but the generated builder
declared the property with its raw type, so the copy constructor's
`this.x = b.x` mismatched.
Declare the builder field as `JsonNullable<T>` (defaulting to `undefined()`, or
`of(default)` for a non-container with a default, mirroring the pojo field), and
have the builder's setter take the raw type and wrap it, mirroring the pojo's
own fluent setter.
No existing sample combines `generateBuilders` with a JsonNullable property,
which is why this went unnoticed; regenerating the jaxrs samples produces no
diff.
Owner
Author
|
Opened upstream as OpenAPITools#24561. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
generateBuilders=true, a property carryingx-is-jackson-optional-nullableproduces a jaxrs-spec model that does notcompile:
The pojo field is rendered as
JsonNullable<T>, but the generated builderdeclared the property with its raw type, so the builder copy constructor's
this.x = b.xmismatched:Fix
Declare the builder field as
JsonNullable<T>, defaulting toundefined()(orof(default)for a non-container with a default), mirroring the pojo field. Thebuilder's setter still takes the raw type and wraps it, mirroring the pojo's own
fluent setter — so the builder API is unchanged for callers.
Why this was not caught
No existing sample combines
generateBuilderswith aJsonNullableproperty.Regenerating the jaxrs samples produces zero diff.
Reproduced on a minimal 3.0 spec with no records, oneOf or inheritance involved —
only
generateBuilders=trueplus the extension is required.Tests
New
testBuilderFieldMatchesJsonNullableFieldType_issue24561, which fails onmaster and passes with the fix.
JavaJAXRSSpecServerCodegenTest152 green.