Comments (8)
This would be useful, they are included in the standard swagger-ui - any hints on where to enabled these in this awesome theme?
from swagger-ui.
If example responses and schemas are defined in your Swagger definition file, then it should just work out of the box for you. (Nice touch: if you shrink the width of your screen to tablet-or-lower resolutions, the responsive design that @jensoleg has put together hides the sample/schema column, and adds a Show Sample button to display them in a pop-up instead).
In the Swagger definition for an API endpoint, it would look something like this:
"responses": {
"200" : {
"description": "The operation completed successfully",
"schema": {
"$ref": "#/Namespace.To.Your.Model"
},
"examples": {
"application/json": {
id: 12345,
name: "Sample value",
created: "2016-02-14T06:02:03"
}
}
}
}
I'm using Swashbuckle to generate the Swagger definition from my ASP.NET WebAPI.
from swagger-ui.
It works for the responses but I dont have any that describe the exceptions, the examples are defined in my definition block - not sure if that makes a difference?
from swagger-ui.
As in a model/schema and sample when the response is e.g. a 400 Bad Request?
from swagger-ui.
Yep - e.g:
"NoCampaignFoundError [data]": {
"type": "object",
"properties": {
"code": {
"description": "HTTP Error Code",
"type": "integer",
"format": "int32"
},
"message": {
"description": "Description of Error",
"type": "string"
},
"exception": {
"description": "Exception Details",
"type": "array",
"items": {
"$ref": "#/definitions/ExceptionObject"
}
}
},
"example": {
"success": false,
"data": {
"message": "No campaign found",
"url": "/impressions/beacon.json",
"code": 404,
"exception": {
"class": "Cake\\Network\\Exception\\NotFoundException",
"code": 404,
"message": "No campaign found"
}
}
}
},
from swagger-ui.
And that renders successfully in this fork? I can't even get Swashbuckle to generate that part of the definition, so I can't try it out in my API.
from swagger-ui.
No sorry that was my point, the error examples dont render in this but they work fine in the vanilla swagger-ui, I assume that those template sections have been removed but not sure where to look?
from swagger-ui.
Nowadays, we're having the same issue. It's only happens with array/list models. If we use a simple model (object, string...) it works.
Wrong Rendered:
`HTTP Status Code | Reason | Response Model | Headers |
---|---|---|---|
400 | BadRequest | Array[object] | ` |
Expected Rendered:
`HTTP Status Code | Reason | Response Model | Headers |
---|---|---|---|
400 | BadRequest | [{"codigo": 0,"mensaje": "string"}] |
` |
This wrong rendered only happens with all request that aren't 200 (404,500...) and the reponse model is an array/list.
¿Any idea what's happening?
from swagger-ui.
Related Issues (20)
- Installation Doc
- Failed to load resource: the server responded with a status of 504 (Outdated Optimize Dep) HOT 1
- Ability to split body params into single input boxes
- No CURL support (?)
- How to re-publish updated source? HOT 2
- JsonEdittor Configuration Css not working properly
- Try out form does not work when POST with application/x-www-form-urlencoded
- Deeper reference does not work
- Array or list parameter does not seem to work ! HOT 1
- How can i display 'Introduction'
- Not working enum references
- I will rebuild css in SASS (scss) if someone can walk me through current version
- The navigation seems to get buggy sometimes
- Installation guide?
- Is this still maintained? HOT 3
- Support for OAS 3.0?
- Angular
- Custom Layout
- SideBar not expanding HOT 1
- Any pre-built docker image available?
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 swagger-ui.