Skip to content

fix(deps): make swagger-annotations compileOnly to avoid jakarta conflict#818

Open
arimu1 wants to merge 1 commit into
openai:mainfrom
arimu1:fix/796-swagger-annotations-compile-only
Open

fix(deps): make swagger-annotations compileOnly to avoid jakarta conflict#818
arimu1 wants to merge 1 commit into
openai:mainfrom
arimu1:fix/796-swagger-annotations-compile-only

Conversation

@arimu1

@arimu1 arimu1 commented Jul 25, 2026

Copy link
Copy Markdown

Summary

Fixes #796.

openai-java-core declared api("io.swagger.core.v3:swagger-annotations:…"), which forced the javax Swagger annotations artifact onto every consumer classpath. That conflicts with swagger-annotations-jakarta (same package io.swagger.v3.oas.annotations), common in Spring Boot 3 / springdoc apps.

Change

  • Mark swagger-annotations as compileOnly (plus testImplementation for SDK tests) so it is not a published transitive dependency.
  • Register Swagger2Module only when io.swagger.v3.oas.annotations.media.Schema is loadable, so structured outputs still work when neither annotation artifact is present (Jackson annotations continue to drive schema generation).
  • Add an explicit swagger-annotations dependency to openai-java-example (examples use @Schema / @ArraySchema).
  • Document in the README that consumers who want Swagger annotations must declare either swagger-annotations or swagger-annotations-jakarta themselves.

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-2 already treats swagger-annotations as provided; this aligns the SDK with that model.

Competing PRs

Searched open/closed PRs for swagger / #796 on openai/openai-java before 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)
  • Confirmed published pom-default.xml no longer lists swagger-annotations (only jsonschema-module-swagger-2, which does not transitively pull annotations)
  • CI green on this PR

…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
@arimu1
arimu1 requested a review from a team as a code owner July 25, 2026 16:17
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.

swagger-annotations api dependency conflicts with swagger-annotations-jakarta

1 participant