Azure / Azure/azure-functions-openapi-extension
Unnecessary quotes within example
- Dominant language
- C#
- Stars
- 388
- Forks
- 202
- PR merge metrics
- No merged PRs in 30d
Description
Taken from the docs:
```
// Example
public class CatExample : OpenApiExample
{
public override IOpenApiExample Build(NamingStrategy namingStrategy = null)
{
this.Examples.Add(OpenApiExampleResolver.Resolve("nabi", new Cat() { Id = 123, Name = "Nabi" }, namingStrategy));
return this;
}
}
// Model
[OpenApiExample(typeof(CatExample))]
public class Cat
{
public int Id { get; set; }
public string Name { get; set; }
}
// This will result in:
// {
// "components": {
// "schemas": {
// "cat": {
// "type": "object",
// "properties": {
// "id": {
// "type": "integer"
// "format": "int32"
// },
// "name": {
// "type": "string"
// }
// },
// "example": "{\"id\":123,\"name\":\"Nabi\"}"
// }
// }
// }
// }
```
Focusing on "example": "{\"id\":123,\"name\":\"Nabi\"}"
I have found when importing into APIM that the example does not run as there are quotes and escape characters within the payload, should importing the specification correctly parse this into a valid json string or should this value within the spec be valid json?
Contributor guide
Research direction
Review the generated OpenAPI example shown in the issue and test its import into Azure API Management. Determine whether the example should be emitted as a JSON value rather than an escaped string, and establish the expected behavior for a valid specification and APIM import.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100