Skip to content

Add ServerBaseUrlCustomizer functionality to be able to customize the generated Server URL #1543

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

Merged
merged 2 commits into from
Mar 22, 2022

Conversation

skylar-stark
Copy link

@skylar-stark skylar-stark commented Mar 9, 2022

ServerBaseUrlCustomiser to allow making changes to the generated server base URL. Also adds a getter method for retrieving the generated server base URL to use in an OpenApiBuilderCustomizer in order to make customizations based on the generated value

@skylar-stark skylar-stark changed the title Add method to retrieve server base URL Add ServerBaseUrlCustomizer functionality to be able to customize the generated Server URL Mar 9, 2022
@skylar-stark
Copy link
Author

Use case: strip the "context-path" off the generated server URL and instead add it to the beginning of each path, so that Open API generation works behind a reverse proxy

@bnasslahsen
Copy link
Collaborator

@skylar-stark,

Could you add the corresponding unit tests to your PR?

@skylar-stark
Copy link
Author

@bnasslahsen Unit test added. Thanks!

@bnasslahsen bnasslahsen merged commit 6d3dd16 into springdoc:master Mar 22, 2022
@bnasslahsen
Copy link
Collaborator

@skylar-stark,

Thank you for your contribution !

bnasslahsen added a commit that referenced this pull request Mar 22, 2022
/**
* The server base URL customisers.
*/
private final Optional<List<ServerBaseUrlCustomizer>> serverBaseUrlCustomisers;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird pattern to use Optional for class vars when the code has to check if it's null anyway.

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.

3 participants