Azure / Azure/azure-functions-openapi-extension
OpenApiRequestBodyAttribute Example parameter is ignored
- Dominant language
- C#
- Stars
- 388
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
The example object used for the Example parameter in OpenApiRequestBodyAttribute appears ignored.
I've added the OpenApiRequestBodyAttribute to an HTTP trigger function as below:
`[OpenApiRequestBody("application/json", typeof(Trip), Required = true, Example = typeof(TripExample))]`
Implementation of the TripExample class is below
```
public class TripExample : OpenApiExample
{
public override IOpenApiExample Build(NamingStrategy namingStrategy = null)
{
Examples.Add(OpenApiExampleResolver.Resolve("manifest", "Example trip advice json document.",
new Trip
{
EventHeader = new EventHeader
{
...
Code I've skipped for brevity
...
},
namingStrategy));
return this;
}
}
```
If I specify the example using the OpenApiExampleAttribute the swagger doc renders correctly. I cannot do this outside of a PoC though because the request objects are implemented in their own class library and I don't want to include a dependency on this library.
Contributor guide
Assessment
This issue has not been assessed yet.