OpenAPI.NET.CSharpAnnotations
OpenAPI.NET.CSharpAnnotations copied to clipboard
Added support for media types in query parameters
This project really helped us out generating OpenAPI 3.0 schemas for out .Net Framework WebAPI.
In our WebAPI some of the controllers have actions that can have complex types as query parameters and we wanted the possibility of describing those parameters as content, instead of schema.
For example:
"parameters": [
{
"name": "queryString",
"in": "query",
"description": "Query param 1 with no media type",
"schema": {
"type": "string"
}
},
{
"name": "sampleObjectInQuery2",
"in": "query",
"description": "Query param as application/json content",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Microsoft.OpenApi.CSharpAnnotations.DocumentGeneration.Tests.Contracts.SampleObject1"
}
}
}
}
]
Changes introduced:
- Query parameters can have type specified (similar to body parameters)
- If no type is specified describes the parameter as schema (maintains the default behaviour)
- Added a new controller to test default and new behaviour
- Added a test in GetTestCasesForValidDocumentationShouldReturnCorrectDocument