Skip to content

Any way of using properties from application.yml as schema example? #231

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
gruutak opened this issue Dec 6, 2019 · 6 comments
Closed
Labels
enhancement New feature or request

Comments

@gruutak
Copy link

gruutak commented Dec 6, 2019

I'm trying to set an example for an endpoint schema, but I'd like to keep the example in a property files, like application.yml. Is there any way of using it in the example?

I tried the following code, but it didn't work:

@Operation(summary = "Something something")
@ApiResponses(value = {
        @ApiResponse(responseCode = "200", description = "Successful operation",
                content = @Content(schema = @Schema(example = "${swagger.examples.fooApi}")))
})
@GetMapping(path = "/foo/{bar}", produces = APIVersions.API_VERSION_V1)
public ResponseEntity getFoo(@PathVariable("bar") @LogParameter final String bar) {
    return ResponseEntity.ok(this.fooService.getFoo(bar));
}
@gruutak gruutak changed the title Any wayof using properties from application.yml as example? Any way of using properties from application.yml as example? Dec 6, 2019
@johnheitor
Copy link

I too am looking for a solution for passing config param to @OAuthFlow tokenUrl as per @gruutak example.

@kremers
Copy link

kremers commented Dec 13, 2019

👍

@kremers
Copy link

kremers commented Dec 13, 2019

Please release 1.2.18 ❤️

@springdoc
Copy link
Collaborator

Hi,

A support will be available on v1.2.18.
The support will not be added to all the parameters as the performance impact is not yet evaluated.

You can declare the following urls with v1.2.18, inside spring-boot properties/yml files (application.yml) and inject them into the swagger annotations using securityScheme or oAuthFlow:

  • securityScheme.openIdConnectUrl
  • oAuthFlow.authorizationUrl
  • oAuthFlow.refreshUrl
  • oAuthFlow.tokenUrl

@gruutak gruutak changed the title Any way of using properties from application.yml as example? Any way of using properties from application.yml as schema example? Dec 16, 2019
@edgeofoblivion
Copy link

I'd be interested in a way to load detailed operation descriptions (containing markdown) from yaml, something like:

@Operation(summary = "This API will do something.", description = "${springdoc.operation-descriptions.myOperation}")

This would keep the controller class less polluted when providing a detailed, formatted description.

Thanks.

@johnheitor
Copy link

Fantastic news. Thank you for adding support.

@bnasslahsen bnasslahsen added the enhancement New feature or request label Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants