-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
With SchemaType.Swagger2, GET requests with parameters generate invalid swagger.json #390
Comments
well... |
@dj-nitehawk Thank you for your quick reply and fix. I tried with the latest version (5.7.2.8-beta): the errors for the GET route parameters have disappeared. 🙏 However, there are still errors on the examples: I will look at your patch to see if I can do a PR for this case. Here is the remaining error:
Here is the now generated swagger: {
"x-generator": "NSwag v13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))",
"swagger": "2.0",
"info": {
"title": "FastEndpointsBugGetSwagger20",
"version": "1.0.0"
},
"host": "localhost:5120",
"schemes": [
"http"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/api/user/search": {
"get": {
"tags": [
"Api"
],
"operationId": "FastEndpointsBugGetSwagger20FeaturesEndpoint",
"parameters": [
{
"type": "integer",
"name": "Age",
"in": "query",
"required": true,
"format": "int32",
"x-nullable": false
}
],
"responses": {
"200": {
"x-nullable": false,
"description": "Success",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/MyResponse"
}
},
"examples": [
{
"firstName": "marlon",
"lastName": "brando",
"age": 80
}
]
}
}
}
}
},
"definitions": {
"MyResponse": {
"type": "object",
"required": [
"age"
],
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer",
"format": "int32"
}
}
},
"MyRequest": {
"type": "object",
"required": [
"age"
]
}
}
} |
this one actually looks like a bug in nswag where it produces the incorrect swagger spec when the response schema is an array type. the only solution i could figure out was to make the example a json string. FastEndpoints/Src/Swagger/OperationProcessor.cs Lines 110 to 115 in cf0bf8c
give do send in a PR if that's not good enough or if you can come up with a more elegant solution. cheers! |
Hi,
Some tools we use force us to generate the swagger.json in Swagger 2.0 format rather than Open API 3.0 format.
In the Swagger 2.0 format, structural errors are reported by editor.swagger.io for GET requests with parameters.
For the same endpoint in Open Api 3.0 format, no errors are reported.
I don't know if the problem is in FastEndpoints swagger generation or in NSwag library for this case.
Here is the API showing the problem:
And here are the errors reported:
In addition, here is the generated swagger.json:
The text was updated successfully, but these errors were encountered: