Comments (5)
Afaics, we are rendering correct OpenAPI 2, but redoc would like to have the yaml example string in a certain format/syntax?
from restdocs-api-spec.
I seem to have forgotten to answer to this. The problem is not that the example has wrong string format, but that it is a string, since using |-
denotes a string.
examples:
application/json: |-
{
"foo": "bar"
}
This cannot be rendered as an object, since it’s not. It is a string representation of the object we need.
The correct way to represent the example would be to use an actual object:
examples:
application/json:
{
”foo”: ”bar”
}
Reference: https://swagger.io/docs/specification/2-0/adding-examples/
The same happens with JSON output as well, because the example is wrapped in quotes. What we ended up doing to work around this was to parse the output ourselves to get rid of the extra characters in examples.
from restdocs-api-spec.
Fyi - after upgrading to spring boot 2.3.x, and transitively to jackson 2.11.0, this is now a bit tricker to work around.
Where we used to get this output:
|-
{
"a":"b",
"c":"d"
}
We now get:
"{\n \"a\":\"b\",\n \"c\":\"d\"\n}"
So it's no longer just a case of removing |-
to get redoc to display unquoted request / response samples.
I think it's potentially due to this change - FasterXML/jackson-dataformats-text@c41a621#diff-6eedc03a68a69933c763e674f2d7c42f
from restdocs-api-spec.
So it's no longer just a case of removing
|-
to get redoc to display unquoted request / response samples.
Try this workaround: #109 (comment)
from restdocs-api-spec.
Based on kiftio's findings and https://yaml.org/spec/1.2/spec.html#id2788859, I'd say: quoting of the example is working as intended by YAML spec and I'd close this.
thugcee provided a nice workaround for redoc users.
from restdocs-api-spec.
Related Issues (20)
- Cannot setup Spring Boot 3 with ePages HOT 1
- ResourceSnippet does not support PayloadSubsectionExtractor HOT 1
- Generated examples are saved as string instead of JSON objects HOT 2
- Share common attributes of extensions in the same class
- Please tell me how to make the api specification look better in swagger ui
- When i use webtestclient, i am getting on error message 'please use RestDocumentationRequestBuilders with urlTemplate to construct the request' HOT 1
- Replace TravisCI with GitHub Actions HOT 2
- OpenAPI 3 oauth2 security scheme not applied globally for all endpoints
- How to join documentation from multi-project build? HOT 1
- Limited supported constraints(PATTERN) in generated contract HOT 3
- Response Json Data 4Depth
- Keep supporting Spring Boot 2.7.x HOT 5
- Subschema examples
- openapi3 task null exception HOT 1
- Support License section of OpenAPI spec
- There is no way to indicate the requestBody is required
- Use general description, summary and operationId in generate openapi2 and postman
- Doesn't it support setting up authentication for cookies?
- Documenting Bean Validation constraints not supporting spring boot 3 HOT 1
- Could not find com.epages:restdocs-api-spec-openapi-generator:0.19.1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from restdocs-api-spec.