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

Add Info to OpenAPI and GroupedOpenAPI properties #2318

Closed
simomonster opened this issue Jul 24, 2023 · 3 comments
Closed

Add Info to OpenAPI and GroupedOpenAPI properties #2318

simomonster opened this issue Jul 24, 2023 · 3 comments

Comments

@simomonster
Copy link

simomonster commented Jul 24, 2023

Is your feature request related to a problem? Please describe.

When declaring groups with properties it's not possible to add info customizations dynamically, for each group.

Programmatically I can add info (Title, Description) to openAPIs, but when I want to generate groups dynamically I can't customize (adding Info) each grouped openAPI identifying it by group.

Describe the solution you'd like

  • adding properties: springdoc.info and springdoc.group-configs[].info where info will be mapped to io.swagger.v3.oas.models.info.Info or at least title, description, version fields. ie:
    springdoc.info.title
    springdoc.info.description
    springdoc.info.version
  • Document is generated automatically (without adding customization) with info included

Describe alternatives you've considered

  • In alternative, simpler, but with more effort for clients. Add OpenApiGroupedCustomizer. This way we can add info dynamically for each group.
    The alternative could be added even in parallel with the main solution, as it could be useful for other purposes as well.
@bnasslahsen
Copy link
Contributor

bnasslahsen commented Jul 29, 2023

There are no plans to add these new properties. But feel free to propose a PR if you feel it's useful for the community.

You can use addOpenApiCustomizer instead:

	@Bean
	public GroupedOpenApi tweetsOpenApi(@Value("${springdoc.version}") String appVersion) {
		String[] paths = { "/tweets/**" };
		return GroupedOpenApi.builder().
				group("tweets")
				.addOpenApiCustomizer(openApi -> openApi.info(new Info().title("Tweets API").version(appVersion)))
				.pathsToMatch(paths)
				.build();
	}

@simomonster
Copy link
Author

There are no plans to add these new properties. But feel free to propose a PR if you feel it's useful for the community.

You can use addOpenApiCustomizer instead:

	@Bean
	public GroupedOpenApi tweetsOpenApi(@Value("${springdoc.version}") String appVersion) {
		String[] paths = { "/tweets/**" };
		return GroupedOpenApi.builder().
				group("tweets")
				.addOpenApiCustomizer(openApi -> openApi.info(new Info().title("Tweets API").version(appVersion)))
				.pathsToMatch(paths)
				.build();
	}

Hi @bnasslahsen, thanks for the answer.
However the solution you posted is hardcoded, if I'm using springdoc properties to dynamically configure groups, then I can't add a specific customizer for each group thus I can't set proper info.

@bnasslahsen
Copy link
Contributor

@simomonster,

As explained, only the programmatic way is now possible ...

@bnasslahsen bnasslahsen reopened this Jul 31, 2023
@springdoc springdoc locked as too heated and limited conversation to collaborators Jul 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants