Azure / Azure/azure-functions-openapi-extension
DateOnly in response body
- Dominant language
- C#
- Stars
- 388
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
I have an azure function with a trigger decorated with the two attributes required for specifiying the input and output:
```csharp
[OpenApiParameter(name: "myDate", In = ParameterLocation.Query, Required = true, Type = typeof(DateOnly))]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(DateOnly))]
```
In the OpenApi definition that gets generated I get the following
```json
"parameters": [
{
"in": "query",
"name": "myDate",
"required": true
}
],
"responses": {
"200": {
"schema": {
"$ref": "#/definitions/dateOnly"
}
},
```
Is it possible for both the parameters and responses section to show that I'm expecting a string with a date format?
I've seen this exact issue mentioned and solved for other swagger implementations ([example](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/2319)) but there doesn't seem to be a way of mapping a type for this library.
**To Reproduce**
Steps to reproduce the behavior:
1. Create a new function app with a HTTP trigger
2. Add the necessary attributes, including the ones above.
3. Check the resulting swagger doc.
**Expected behavior**
This isn't a bug since it's expected behaviour. I'd just like to know if there's a way I can override the behaviour like in the URL above?
Thank you.
Contributor guide
Research direction
Reproduce the generated OpenAPI document using the OpenApiParameter and OpenApiResponseWithBody attributes shown in the issue. Inspect how the query parameter and response schema are generated, then determine whether an override or type mapping can make both represent DateOnly as a string with date format; done when the generated document reflects that representation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, openapi
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100