OpenAPI.NET.CSharpAnnotations icon indicating copy to clipboard operation
OpenAPI.NET.CSharpAnnotations copied to clipboard

Added support for media types in query parameters

Open Graz21 opened this issue 3 years ago • 1 comments

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

Graz21 avatar Apr 13 '21 09:04 Graz21

CLA assistant check
All CLA requirements met.

ghost avatar Apr 13 '21 09:04 ghost