fix(deps): make swagger-annotations compileOnly to avoid jakarta conflict#818
Open
arimu1 wants to merge 1 commit into
Open
fix(deps): make swagger-annotations compileOnly to avoid jakarta conflict#818arimu1 wants to merge 1 commit into
arimu1 wants to merge 1 commit into
Conversation
…lict Stop re-exporting javax swagger-annotations as an api dependency so consumers can use swagger-annotations-jakarta without split-package clashes. Register Swagger2Module only when Schema is on the classpath, and document that @Schema users must declare the annotation artifact. Fixes openai#796
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.
Summary
Fixes #796.
openai-java-coredeclaredapi("io.swagger.core.v3:swagger-annotations:…"), which forced the javax Swagger annotations artifact onto every consumer classpath. That conflicts withswagger-annotations-jakarta(same packageio.swagger.v3.oas.annotations), common in Spring Boot 3 / springdoc apps.Change
swagger-annotationsascompileOnly(plustestImplementationfor SDK tests) so it is not a published transitive dependency.Swagger2Moduleonly whenio.swagger.v3.oas.annotations.media.Schemais loadable, so structured outputs still work when neither annotation artifact is present (Jackson annotations continue to drive schema generation).swagger-annotationsdependency toopenai-java-example(examples use@Schema/@ArraySchema).swagger-annotationsorswagger-annotations-jakartathemselves.Tradeoff
Consumers who need Swagger annotations at compile time for their own schema classes must declare the dependency themselves (javax or jakarta coordinate). That is intentional: the SDK should not pick a side and break the other ecosystem. Jackson-based schema generation needs no extra dependency.
jsonschema-module-swagger-2already treatsswagger-annotationsasprovided; this aligns the SDK with that model.Competing PRs
Searched open/closed PRs for
swagger/#796onopenai/openai-javabefore opening — none found covering this change.Test plan
./gradlew :openai-java-core:compileKotlin :openai-java-example:compileJava./gradlew :openai-java-core:test --tests 'com.openai.core.StructuredOutputsTest'— 95 tests, 0 failures (JDK 21)pom-default.xmlno longer listsswagger-annotations(onlyjsonschema-module-swagger-2, which does not transitively pull annotations)