Skip to content

Enum return value not included in definitions #210

Description

@andyrooger

I have code similar to the following

[ServiceContract(Namespace="blah")]
[SwaggerWcf("/v1/rest")]
[SwaggerWcfServiceInfo("x", "y")]
public interface IService
{
    [OperationContract, WebGet()]
    MyEnum GetEnum();
}

[DataContract(Namespace = "blah")]
[Flags]
public enum MyEnum
{
    [EnumMember]
    One = 1,
    [EnumMember]
    Two = 2
}

The resulting swagger JSON refers to #definitions/MyEnum as the ref for the method response type, but that definition does not exist in the definition. Thus I have an invalid swagger JSON.

Debugging this, it looks like it makes it into the list of types to include but then is ignored when including in the schema since it's treated as primitive. This is because all enums seem to be treated as type=integer + format=enum and all integers, whether or not they're enums are treated as primitive.

So can we exclude enums from the primitives check in TypeFormat?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions