示例#1
0
        public static void Apply(IDictionary <string, IOpenApiExtension> extensions, Type enumType, XmsEnumExtensionsOptions options)
        {
            var name = enumType.GetTypeInfo().IsGenericType&& enumType.GetGenericTypeDefinition() == typeof(Nullable <>)
                ? enumType.GetGenericArguments()[0].Name
                : enumType.Name;
            var modelAsString = options != XmsEnumExtensionsOptions.UseEnums;

            extensions["x-ms-enum"] = new OpenApiObject
            {
                ["name"]          = new OpenApiString(name),
                ["modelAsString"] = new OpenApiBoolean(modelAsString)
            };
        }
 public XmsEnumSchemaFilter(XmsEnumExtensionsOptions options)
 {
     _options = options;
 }
 public XmsEnumOperationFilter(XmsEnumExtensionsOptions options)
 {
     _options = options;
 }
 public XmsEnumParameterFilter(XmsEnumExtensionsOptions options)
 {
     _options = options;
 }
示例#5
0
 public static void Apply(IDictionary <string, IOpenApiExtension> extensions, string typeName, XmsEnumExtensionsOptions options)
 {
     extensions.Add(
         "x-ms-enum",
         new OpenApiObject
     {
         ["name"]          = new OpenApiString(typeName),
         ["modelAsString"] = new OpenApiBoolean(options != XmsEnumExtensionsOptions.UseEnums)
     }
         );
 }
示例#6
0
 public static void Apply(IDictionary <string, IOpenApiExtension> extensions, Type enumType, XmsEnumExtensionsOptions options)
 {
     extensions.Add(
         "x-ms-enum",
         new OpenApiObject
     {
         ["name"] = enumType.GetTypeInfo().IsGenericType&& enumType.GetGenericTypeDefinition() == typeof(Nullable <>)
                 ? new OpenApiString(enumType.GetGenericArguments()[0].Name)
                 : new OpenApiString(enumType.Name),
         ["modelAsString"] = new OpenApiBoolean(options != XmsEnumExtensionsOptions.UseEnums)
     }
         );
 }
 /// <summary>
 /// Enables "x-ms-enum" swagger extension, which allows Autorest tool generates enum or set of string constants for each server-side enum.
 /// </summary>
 /// <param name="swaggerOptions"></param>
 /// <param name="options">"x-ms-enum" extensions options. Default value is <see cref="XmsEnumExtensionsOptions.UseEnums"/></param>
 public static void EnableXmsEnumExtension(this SwaggerGenOptions swaggerOptions, XmsEnumExtensionsOptions options = XmsEnumExtensionsOptions.UseEnums)
 {
     swaggerOptions.SchemaFilter <XmsEnumSchemaFilter>(options);
     swaggerOptions.OperationFilter <XmsEnumOperationFilter>(options);
 }
 public static void Apply(IDictionary <string, object> extensions, Type enumType, XmsEnumExtensionsOptions options)
 {
     extensions.Add("x-ms-enum", new
     {
         name = enumType.GetTypeInfo().IsGenericType&& enumType.GetGenericTypeDefinition() == typeof(Nullable <>) ?
                enumType.GetGenericArguments()[0].Name :
                enumType.Name,
         modelAsString = options != XmsEnumExtensionsOptions.UseEnums
     });
 }