Support relative path in @ExampleObject
See original GitHub issueHaving a file in /src/main/resources/static/swagger/example.json
. Placed inside /static
because spring can expose those to the web.
It should be possible to reference the file relative to the application itself. Eg as follows:
@Operation(responses = @ApiResponse(content = @Content(examples = @ExampleObject(externalValue = "swagger/example.json")))
But even if I can access the resource via locahost:8080/swagger/example.json
, when adding the url to @ExampleObject
it is still not resolved:
@Operation(responses = @ApiResponse(content = @Content(examples = @ExampleObject(externalValue = "locahost:8080/swagger/example.json")))
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
OpenAPI Specification - Version 3.0.3 - Swagger
This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the OpenAPI...
Read more >How to construct a relative path in Java from two absolute ...
tl;dr answer: Paths.get(startPath).relativize(Paths.get(endPath)).toString() (which, by the way, seems to be working just fine with ...
Read more >Export Relative or Absolute Paths - TechDocs
When you initiate an export, you can select either Export Absolute Paths or Export Relative Paths. The option that you select affects the ......
Read more >How to use JSON references ($refs) - Redocly
Within a separate file we need a relative path to the file and then the JSON Pointer path to the object separated by...
Read more >OpenAPI Specification v3.1.0 | Introduction, Definitions, & More
The OpenAPI document MUST contain at least one paths field, a components field ... This URL supports Server Variables and MAY be relative, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m facing same issue and i got an idea from springdoc-openapi project.
In this project, it create example entry(
http500Example
) and add Example throughopenApiCustomiser
actually, this code represent ref in setValue but i put json file in
Example
objecthere is my code
Hi,
Tested with springdoc-openapi: 1.1.15. In order to add the examples reference, in the generated yaml/json documentation, you need to add the name of the ExampleObject:
responses= @ApiResponse(content = @Content(examples = @ExampleObject(name = "toto", externalValue = "http://localhost:8080/test/example.json")))
Displaying the example on the swagger-ui, is not a springdoc-openapi issue, but depends on a pending issue on swagger-ui side: