Skip to content

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

Closed
@EAlf91

Description

@EAlf91

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions