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

Problem in Enum with Swagger Code Grnerator #9

Closed akghasemi closed 4 years ago

akghasemi commented 4 years ago

Hi this Enum fix still doesn't fix the problems in swagger code generator and Enums are still generated in wrong way

unchase commented 4 years ago

Hi, @akghasemi Could you describe your issue in more detail?

akghasemi commented 4 years ago

this is the class that is being generated for enums by swagger code generator. as you can see the enum names are replaced with Number_0 , etc and Enum names are part of summary

using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel.DataAnnotations;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;

namespace IO.Swagger.Model
{
    /// <summary>
    /// &lt;br&gt;0 &#x3D; Normal ()&lt;br&gt;1 &#x3D; Advanced ()
    /// </summary>
    /// <value>&lt;br&gt;0 &#x3D; Normal ()&lt;br&gt;1 &#x3D; Advanced ()</value>

    [JsonConverter(typeof(StringEnumConverter))]

    public enum EnmUserType
    {

        /// <summary>
        /// Enum NUMBER_0 for value: 0
        /// </summary>
        [EnumMember(Value = "0")]
        NUMBER_0 = 1,

        /// <summary>
        /// Enum NUMBER_1 for value: 1
        /// </summary>
        [EnumMember(Value = "1")]
        NUMBER_1 = 2
    }

}
unchase commented 4 years ago

@akghasemi This extension fixes generation by adding descriptions to enum elements. It does not change the mechanism of generation.

akghasemi commented 4 years ago

the problem is that if I am going to fix that ,I have to add StringEnumConverter then Unchase library fails

unchase commented 4 years ago

It only works without StringEnumConverter.