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

OpenAPI Config schemas no longer generated in 2.4.0 - $refs must reference a valid location in the document #2553

Closed
EAlf91 opened this issue Mar 27, 2024 · 0 comments · Fixed by #2552

Comments

@EAlf91
Copy link
Contributor

EAlf91 commented Mar 27, 2024

Describe the bug

Since 2.4.0 we're facing ref errors when declaring schemas using addSchemas in a custom OpenAPI Bean like this:

@Bean
	OpenAPI customOpenApi() {
		return new OpenAPI()
				.components(new Components().addSecuritySchemes("bearerScheme",
						new SecurityScheme()
								.type(SecurityScheme.Type.HTTP)
								.scheme("bearer")
								.bearerFormat("JWT"))
						.addSchemas("FeedResponse", feedResponseSchema()))
				.info(new Info()
						.title("Response API")
						.description("API for some response")
						.version("0.0.1")
						.contact(new Contact()
								.name("EAlf91")))
				.tags(List.of(new Tag()
								.name("ResponseTag")
								.description("ResponseTag for API"),
						new Tag()
								.name("ResponseData")
								.description("Version 2 ResponseApi")));

	}

The resulting spec leads to this error as the whole ResponseData schema is not being generated:
image

Below is a diff of the generated spec using 2.3.0, which contains the Schema, and 2.4.0, which does not.
image

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using? 3.2.4
  • What modules and versions of springdoc-openapi are you using? 2.4.0
  • What is the actual and the expected result using OpenAPI Description (yml or json)? json
  • Provide with a sample code (HelloController) or Test that reproduces the problem
    Showcase Issue #2553 #2552

Expected behavior

  • schemas declared and referenced in an OpenAPI custom configuration bean should be included as before

Additional context
PR here is showcasing the issue and the thing I changed back to make it work again. I reverted OpenAPIService changes for the object mapper and added app9wrong.json which is being produced by 2.4.0
#2552

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 a pull request may close this issue.

1 participant