unchase / Unchase.Swashbuckle.AspNetCore.Extensions

:hammer: A library contains a bunch of extensions (filters) for Swashbuckle.AspNetCore.
https://www.nuget.org/packages/Unchase.Swashbuckle.AspNetCore.Extensions
Apache License 2.0
115 stars 16 forks source link

Feature Request: Support x-enum-varnames #18

Closed meinsiedler closed 3 years ago

meinsiedler commented 3 years ago

Hi!

The OpenAPI Generator uses x-enum-varnames to define names of the enum items as stated in the docs: https://openapi-generator.tech/docs/templating/#all-generators-core

x-enum-varnames can be used to have an other enum name for the corresponding value. This is used to define names of the enum items.

Would it be possible to support x-enum-varnames additionally to x-enumNames so that the OpenAPI generator can generate the correct enum variable names?

unchase commented 3 years ago

Hi, @meinsiedler

Yes, I will add this feature a little later

unchase commented 3 years ago

@meinsiedler done. See the latest version.

meinsiedler commented 3 years ago

Nice, thank you @unchase!

cryo75 commented 1 year ago

How do I need to configure the swagger gen to have this feature?

craustin commented 5 months ago
services
    .AddSwaggerGen(options =>
    {
        options.AddEnumsWithValuesFixFilters();  // will set x-enumNames and x-enumDescriptions
    });

or do this to use the hyphen-separated names:

services
    .AddSwaggerGen(options =>
    {
        options.AddEnumsWithValuesFixFilters(fixEnumsOptions =>
        {
            fixEnumsOptions.XEnumNamesAlias = "x-enum-varnames";
            fixEnumsOptions.XEnumDescriptionsAlias = "x-enum-descriptions";
        });
    });