Closed Brutiquzz closed 4 years ago
Hi, @Brutiquzz Can you send me your generated specification json-file (or part of it) to spiritkola@hotmail.com? I will check what the problem is.
I'm also seeing this issue :( with version 2.3.10. Target framework core app 3.1, same swashbuckle version as OP.
I'm also seeing this issue :( with version 2.3.10. Target framework core app 3.1, same swashbuckle version as OP.
Hi, @hahn-kev
Can you show me your json-specification?
I've edited it down a bit, to make it simpler for you and because I'm not sure how public it's allowed to be.
{
"openapi": "3.0.1",
"info": {
"title": "API",
"version": "v1"
},
"paths": {
"/v1/payments": {
"post": {
"tags": [
"Payments"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AuthorizePaymentBody"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/WebshopAuthorizePaymentResponse"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"AuthorizePaymentBody": {
"required": [
"Amount"
],
"type": "object",
"properties": {
"amount": {
"type": "number",
"description": "Order amount",
"format": "double"
}
},
"additionalProperties": false
},
"PaymentErrorCode": {
"enum": [
0,
1,
2
],
"type": "integer",
"format": "int32",
"x-enumNames": [
"noError",
"typeMissMatch",
"unexpected"
]
},
"WebshopAuthorizePaymentResponse": {
"type": "object",
"properties": {
"errorCode": {
"$ref": "#/components/schemas/PaymentErrorCode"
}
},
"additionalProperties": false,
"example": {
"ErrorCode": 0
}
}
}
}
}
Hi, @hahn-kev
I can't reproduce the issue with your json-specification:
Can you show your controller code?
I can't as this is for a closed source project. What's serving the Swagger UI you showed in your screenshot? Looking at the versions
object in the console my swagger UI version is 3.25 maybe you're testing with a newer version?
I used 3.26 version.
I can't as this is for a closed source project. What's serving the Swagger UI you showed in your screenshot? Looking at the
versions
object in the console my swagger UI version is 3.25 maybe you're testing with a newer version?
You can share only the part of controller code. For example, only the method signature.
Sure, it's something like this
Task<ActionResult<WebshopAuthorizePaymentResponse>> AuthorizePayment( [FromBody] AuthorizePaymentBody checkout)
@hahn-kev @Brutiquzz I created a repository with a test project for the issue, in which the description for the enum is displayed correctly. Hope it helps you.
I have a similar issue, please see attached swagger.txt swagger.txt
services.AddSwaggerGen(c =>
{
c.AddEnumsWithValuesFixFilters();
});
and
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Internal DropShip API");
});
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.1" />
<PackageReference Include="Unchase.Swashbuckle.AspNetCore.Extensions" Version="2.3.11" />
Hi, @IainCoSource
Should use:
services.AddSwaggerGen(c =>
{
c.AddEnumsWithValuesFixFilters();
var xmlFilePath = Path.Combine(AppContext.BaseDirectory, "<your_project_name>.xml");
options.IncludeXmlComments(xmlFilePath);
});
with setting:
I thought we only needed to include that if we want to include XML comments, is that required for the Enum values?
@unchase I implemented the following
var mvcXmlFilePath = Path.Combine(AppContext.BaseDirectory, "Pims.Mvc.xml");
c.IncludeXmlComments(mvcXmlFilePath);
var enumXmlFilePath = Path.Combine(AppContext.BaseDirectory, "Updater4.Data.xml");
c.IncludeXmlComments(enumXmlFilePath);
The first one has added some comments, the second does nothing for the enums.
example of the compiler generated xml.
<member name="F:Updater4.Data.Pims.DropShipOrderStatusType.SupplierError">
<summary>
Supplier Error.
</summary>
<remarks>IsError: true.</remarks>
</member>
@Brutiquzz @hahn-kev @IainCoSource Fixed in v 2.3.12
You can use:
services.AddSwaggerGen(c =>
{
c.AddEnumsWithValuesFixFilters();
});
@unchase :) New version is awesome
I have installed Unchase.Swashbuckle.AspNetCore.Extensions v2.3.8 Swashbuckle.AspNetCore v5.5.1
When using swagger I am trying to make it show me the enum names both when filling parameters but also when reading the response schema. Just like your sample picture for a SamplePerson title illustrates it.
However I am only getting the results you are showing for parameters but not for the response schema.
I have pretty much copy pasted the code from your example.
Can you tell me what I am missing or doing wrong?