Closed marcoliceti closed 7 years ago
Share the file, please? Just because the swagger-editor says it's valid doesn't necessarily mean it's valid. There are some situations that cannot be programmatically checked (they are decreasing, but it is possible).
{
"swagger": "2.0",
"info": {
"title": "ZeroTitoli",
"version": "0.0.0",
},
"schemes": [ "https" ],
"consumes": [ "application/json" ],
"produces": [ "application/json" ],
"paths": {
"/partite": {
"post": {
"description": "
Creazione di una nuova partita per un certo gruppo. Occorre indicare
sia il gruppo sia le informazioni sulla nuova partita. L'utente deve
essere amministratore del gruppo indicato.
",
"parameters": [
{
"name": "partita",
"in": "body",
"schema": {
"$ref": "#/definitions/Partita"
},
"required": true
}
],
"responses": {
"201": {
"description": "La partita è stata creata con successo.",
"schema": {
"$ref": "#/definitions/Partita"
}
},
"403": {
"description": "L'utente non è amministratore del gruppo indicato."
}
},
}
}
},
"security": [
{
"api_key": []
}
],
"definitions": {
"Partita": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"giorno": {
"type": "string"
},
"ora": {
"type": "string"
},
"circolo": {
"type": "string"
},
"quota": {
"type": "string"
},
"note": {
"type": "string"
},
"gruppo": {
"type": "string",
"description": "ID del gruppo per il quale è stata creata la partita."
}
},
"required": [ "giorno", "ora", "circolo", "gruppo" ]
}
},
"securityDefinitions": {
"api_key": {
"type": "apiKey",
"in": "header",
"name": "X-ZeroTitoli-Api-Key"
}
}
}
Hi, your contents are not valid JSON. Try opening it in a JSON viewer and you'll see a number of errors:
\n
Thank you. The editor I use didn't complain and I didn't think about using a JSON validator. However, a more specific error message could be helpful. I think the failure of JSON.parse
can be detected.
Hi. I wrote a valid swagger file and I'd like to feed it to
swagger-ui
.(I know the file is valid because I validated it with swagger-cli and with the online editor).
To avoid CORS issues, I copied my swagger file inside the
dist
folder and started a temporary local web server with the node http-server module. When I paste the URL of my swagger file I get the errorCan't read from server. It may not have the appropriate access-control-origin settings
.As you can see from the screenshot, the swagger file is read from server, so the error message is obviously wrong. And the sentence
It may not have the appropriate access-control-origin settings
is kind of misleading: theswagger-ui
and my swagger file come from the same origin, so CORS issues shouldn't be involved.The
swagger-ui
version I used is2.1.4
.