You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Install ASP.NET Core (.net 5.0) API project template, install this swashbuckle nuget pkg.
Enable XML comments for documenting the API with Swagger. (this works for everything except this quotation marks issue, so I believe it's done correctly)
Add xml example tags to a data model class' string-type property that contains a quotation mark (I'm trying to use it as the annotation for "inches").
optional: Add other xml example tags to other model properties that don't have the problematic quotation marks, as a control.
run the project and check the swagger page's examples; while other parameters may have an example from your xml tags, the parameter with a quotation mark will just show the default "string" for text.
namespaceCatalog.API.Entities{publicclassProduct{/// <example>602d2149e773f2a3990b47f5</example>[BsonId][BsonRepresentation(BsonType.ObjectId)]publicstringId{get;set;}/// <example>Tablets</example>publicstringCategory{get;set;}/** here comes the problematic tag, with the quotes after '10.5' *//// <example>10.5" touchscreen tablet with keyboard and stylus</example>publicstringSummary{get;set;}/// <example>Lorem ipsum ...</example>publicstringDescription{get;set;}/** more stuff */}}
and here's what the "Example Value" looks like in the Swagger page:
{
"id": "602d2149e773f2a3990b47f5",
"name": "Surface Go",
"category": "Tablets",
"summary": "string", // not the text from the example tag"description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ut, tenetur natus doloremque laborum quos iste ipsum rerum obcaecati impedit odit illo dolorum ab tempora nihil dicta earum fugiat. Temporibus, voluptatibus. Lorem ipsum dolor sit amet, consectetur adipisicing elit.",
"imageFile": "product-1.png",
"price": 490.99
}
I am also running into this issue, specifically when trying to provide stringified JSON, for example this doesn't work at all and leads to an empty input value in the Swagger page:
Q&A
Content & configuration
and here's what the "Example Value" looks like in the Swagger page:
Solution attempts
I tried escaping the quote using:
"
U+0022
None of those worked. I eventually settled for representing "inches" as "in" instead of using quotation mark.
Screenshots
Here's how it looks when using "in" instead of a quotation mark to indicate "inches"
Here's how it looks when I use a quotation mark to indicate "inches"
The text was updated successfully, but these errors were encountered: