Open WillGunn opened 7 years ago
Can confirm this issue happens over here too, any example is not being output. The task compile-handlebars seems to have issues with them:
Running "compile-handlebars:compile" (compile-handlebars) task
Cannot format property { token: 'string', valid_until: 'timestamp' }
Cannot format object { token: 'string',
valid_until: 'timestamp',
anchor: '/definitions',
title: 'AuthResponse' }
I have quickly traced the source of one of these to be app/views/partials/swagger/definition.hbs
(the {{>json-schema/body}}
tag). Bad escaping?
The template seems to start rendering examples (then fails), but only when "schema" is specified. Using the default template, this means that 'Response example (200 OK)' is shown, but nothing more.In the same way, the AuthResponse definition is shown as an object, without displaying any of its fields.
This is the relevant parts of our swagger definition:
{
"definitions": {
"AuthResponse": {
"token": "string",
"valid_until": "timestamp"
}
},
"paths": {
"/auth/": {
"post": {
"description": "Handles authentication attemps",
"responses": {
"200": {
"description": "Succesful authentication",
"examples": {
"application/json": {
"token": "Auth token to use for every other request",
"valid_until": "Date until which the token is valid"
}
},
"schema": {
"$ref": "#/definitions/AuthResponse"
}
}
},
}
}
},
"swagger": "2.0"
}
Is anybody working on that issue?
Hi guys
The current system just supports a single example, not an array of examples by content type/language. I would be open to and very happy to receive a PR for this, but some kind of language switch at the UI level would also need to be added
I don't even get a single example to render. How does this work @auscaster?
@MSchmidt A single "example" inside "definitions" is supported, but "examples" inside "responses" is not.
@auscaster Could you explain a bit about the language switch? Does it mean something like tab to switch content type to show?
@yyamano some sort of tabbed interface would be the idea, probably with the languages situated at the top of the right hand column, and on selection all the examples would change to the selected language.
Just like Stripe: https://stripe.com/docs/api
Hi, I'm having the same issue. Does anyone is working on a fix for this issue or has a workaround?
This issue is closed but I actually has exactly the same problem than @WillGunn .
Thanks =)
I would also like to have tabs between generated examples (based on schema) and provided examples.
Yea that is a major disappointment. It's 2 years later now and still no support for multiple example types. The stuff with the languages is extra, but not supporting a basic feature of the OpenApi Spec like 'examples' within 'responses' is a deal breaker.
We are using Swashbuckle to generate swagger from a .net project, Given the sample swagger.json file, the example block is not rendered onto the webpage, only the generic schema:
The example block starts at line 30 swagger_example_issue.txt
For easy reference:
"responses": { "200": { "description": "Success", "schema": { "type": "array", "items": { "$ref": "#/definitions/BasicClient" } }, "examples": { "application/json": [ { "userId": "c12cfeef-0001-0010-0100-abb9e51deaf1", "firstName": "Bruce", "lastName": "Wayne", "email": "BWayne@website.moc", "homePhone": "555-555-5551", "cellPhone": "555-555-5550" }, { "userId": "d12cfeef-0001-0010-0100-abb9e51deaf2", "firstName": "George", "lastName": "Washington", "email": "POTUS1@website.moc", "homePhone": "555-555-5553", "cellPhone": "555-555-5552" }, { "userId": "e12cfeef-0001-0010-0100-abb9e51deaf3", "firstName": "George", "lastName": "Washington", "email": "CiC@website.moc", "homePhone": "555-555-5555", "cellPhone": "555-555-5554" } ] } } }
with BasicClient defined as"BasicClient": { "type": "object", "properties": { "userId": { "type": "string" }, "firstName": { "type": "string" }, "lastName": { "type": "string" }, "email": { "type": "string" }, "homePhone": { "type": "string" }, "cellPhone": { "type": "string" } } }