Skip to content

@Extension values not rendered after 2.7.0 #2979

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

Closed
rolandkreuzer opened this issue May 5, 2025 · 1 comment
Closed

@Extension values not rendered after 2.7.0 #2979

rolandkreuzer opened this issue May 5, 2025 · 1 comment

Comments

@rolandkreuzer
Copy link

rolandkreuzer commented May 5, 2025

Describe the bug

It looks like springdoc versions after 2.7.0 no longer render specification extensions.

Previous versions included values from Extension and ExtensionProperty annotations in the generated OpenAPI contract. They seem to be simply ignored in 2.8.x versions.

The extension mechanism is still part of Spec 3.1.1

To Reproduce

Given the following declaration:

@OpenAPIDefinition(info = @Info(title = "My API", extensions = @Extension(name = "logo", properties = {
        @ExtensionProperty(name = "url", value = "https://www.example.com/logo.png"), 
        @ExtensionProperty(name = "altText", value = "Logo Altext")})))

Version 2.7.0 produced the following JSON definition:

{
	"openapi": "3.0.1",
	"info": {
		"title": "My API",
		"x-logo": {
			"altText": "Logo Altext",
			"url": "https://www.example.com/logo.png"
		}
	},
...

2.8.x versions omit the x-logo property.

I'm working with springdoc-openapi-starter-webmvc-ui.
Working example reproduced with Spring Boot 3.4.1 and SpringDoc 2.7.0.
Bug can be reproduced with latest versions Spring Boot 3.4.5 and SpringDoc 2.8.8.

Expected behavior

Extension values should be rendered as in 2.7.0.

Additional context

The spec extensions in question are used for the Redoc schema viewer
https://redocly.com/docs-legacy/api-reference-docs/spec-extensions

@rolandkreuzer
Copy link
Author

I've tried a few things and it seems the extension will be rendered by SpringDoc if the name explicitly starts with "x-".

This is somewhat unexpected as swagger-annotations explicitly describes the extension name as if the "x-" prefix will be added automatically
an option name for these extensions - will be prefixed with "x-"
https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/extensions/Extension.java

However, since the number of extension fields is somewhat limited, I'd suggest to keep the current behavior and I'll simply adjust my definitions.

Issue can be closed

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

No branches or pull requests

1 participant