no parameter'd constructor and Enum defined differently while generate server code for aspnetcore

10 views
Skip to first unread message

Mahesh Kumar K

unread,
Mar 16, 2018, 11:30:18 AM3/16/18
to Swagger
Hi Team,
I have a problem with defining enum in my swagger. I used the below definition last week and used 'generate server' -> aspnetcore to generate IO.SWAGGER.MODELS.It generated the parameter'd constructor and Enum in the Model Mail.cs file. I incorporated the models in my lambda and was compiled successfully.
This was done last week and today when i tried to generate the same,  was getting different enum defined and there is no parameter'd constructor in the Model .cs file.Also, when i tried to incorporate the Model, .Net throws compilation error.

definition from swagger:
  Mail:
    type: object
    properties:
      forward:
        type: string
        enum:
          - None
          - Increment
          - Reset

Working Model Mail.cs:- (copied part of it)
public enum ForwardCountActionEnum
        {
            
            /// <summary>
            /// Enum NoneEnum for "None"
            /// </summary>
            [EnumMember(Value = "None")]
            NoneEnum,
            
            /// <summary>
            /// Enum IncrementEnum for "Increment"
            /// </summary>
            [EnumMember(Value = "Increment")]
            IncrementEnum,
            
            /// <summary>
            /// Enum ResetEnum for "Reset"
            /// </summary>
            [EnumMember(Value = "Reset")]
            ResetEnum
        }
and it generated the parameter'd constructor as below:-
public Mailbox(int? Id = default(int?), string Pin = default(string), ForwardCountActionEnum? ForwardCountAction = default(ForwardCountActionEnum?))
        {
            this.Id = Id;
            this.Pin = Pin;
            this.ForwardCountAction = ForwardCountAction;
        }

Newly generated model today-:
 
 public enum ForwardCountActionEnum
        { 
            /// <summary>
            /// Enum NoneEnum for None
            /// </summary>
            [EnumMember(Value = None)]
            NoneEnum = 1,
            
            /// <summary>
            /// Enum IncrementEnum for Increment
            /// </summary>
            [EnumMember(Value = Increment)]
            IncrementEnum = 2,
            
            /// <summary>
            /// Enum ResetEnum for Reset
            /// </summary>
            [EnumMember(Value = Reset)]
            ResetEnum = 3
        }
There's no constructor created.

May i know what is the problem here? I did not change anything in my swagger file.

Mahesh Kumar K

unread,
Mar 19, 2018, 3:01:50 AM3/19/18
to Swagger
Dear Team,
Can anyone help me here? Thanks in advance if some one free me from this obstacle.
Reply all
Reply to author
Forward
0 new messages