private HttpContent ContentFor(HttpRequestMessage request, SwaggerDocument swaggerDoc, SwaggerGeneratorOptions options) { var negotiator = request.GetConfiguration().Services.GetContentNegotiator(); var result = negotiator.Negotiate(typeof(SwaggerDocument), request, GetSupportedSwaggerFormatters(options)); return new ObjectContent(typeof(SwaggerDocument), swaggerDoc, result.Formatter, result.MediaType); }
public SwaggerOptions() { SwaggerGeneratorOptions = new SwaggerGeneratorOptions(); SwaggerGeneratorOptions.OperationFilters.Add(new ApplySwaggerOperationAttributes()); SwaggerGeneratorOptions.OperationFilters.Add(new ApplySwaggerResponseAttributes()); SchemaGeneratorOptions = new SchemaGeneratorOptions(); }
public SwaggerGenerator( IApiDescriptionGroupCollectionProvider apiDescriptionsProvider, Func <ISchemaRegistry> schemaRegistryFactory, SwaggerGeneratorOptions options = null) { _apiDescriptionsProvider = apiDescriptionsProvider; _schemaRegistryFactory = schemaRegistryFactory; _options = options ?? new SwaggerGeneratorOptions(); }
public SwaggerGenerator( IApiDescriptionGroupCollectionProvider apiDescriptionsProvider, Func<ISchemaRegistry> schemaRegistryFactory, SwaggerGeneratorOptions options = null) { _apiDescriptionsProvider = apiDescriptionsProvider; _schemaRegistryFactory = schemaRegistryFactory; _options = options ?? new SwaggerGeneratorOptions(); }
public SwaggerGenerator( string basePath, string apiVersion, IEnumerable <ApiDescription> apiDescriptions, SwaggerGeneratorOptions options) { _basePath = basePath; _apiVersion = apiVersion; _apiDescriptions = apiDescriptions; _options = options; }
public SwaggerGenerator( IApiExplorer apiExplorer, IContractResolver jsonContractResolver, IDictionary<string, Info> apiVersions, SwaggerGeneratorOptions options = null) { _apiExplorer = apiExplorer; _jsonContractResolver = jsonContractResolver; _apiVersions = apiVersions; _options = options ?? new SwaggerGeneratorOptions(); }
public SwaggerGenerator( IApiExplorer apiExplorer, JsonSerializerSettings jsonSerializerSettings, IDictionary<string, Info> apiVersions, SwaggerGeneratorOptions options = null) { _apiExplorer = apiExplorer; _jsonSerializerSettings = jsonSerializerSettings; _apiVersions = apiVersions; _options = options ?? new SwaggerGeneratorOptions(); }
public SwaggerGenerator( IApiExplorer apiExplorer, JsonSerializerSettings jsonSerializerSettings, IDictionary <string, Info> apiVersions, SwaggerGeneratorOptions options = null) { _apiExplorer = apiExplorer; _jsonSerializerSettings = jsonSerializerSettings; _apiVersions = apiVersions; _options = options ?? new SwaggerGeneratorOptions(); }
public SwaggerGenerator( IApiExplorer apiExplorer, IContractResolver jsonContractResolver, IDictionary <string, Info> apiVersions, SwaggerGeneratorOptions options = null) { _apiExplorer = apiExplorer; _jsonContractResolver = jsonContractResolver; _apiVersions = apiVersions; _options = options ?? new SwaggerGeneratorOptions(); }
public SwaggerGenerator( string basePath, string apiVersion, IEnumerable<ApiDescription> apiDescriptions, SwaggerGeneratorOptions options) { _basePath = basePath; _apiVersion = apiVersion; _apiDescriptions = apiDescriptions; _options = options; }
public SwaggerGenerator( IApiExplorer apiExplorer, JsonSerializerSettings jsonSerializerSettings, IDictionary <string, Info> apiVersions, SwaggerGeneratorOptions options = null) { this._apiExplorer = apiExplorer; this._jsonSerializerSettings = jsonSerializerSettings; this._apiVersions = apiVersions; this._options = options ?? new SwaggerGeneratorOptions((Func <ApiDescription, string, bool>)null, (IEnumerable <string>)null, (IDictionary <string, SecurityScheme>)null, false, (Func <ApiDescription, string>)null, (IComparer <string>)null, (IDictionary <Type, Func <Schema> >)null, (IEnumerable <ISchemaFilter>)null, (IEnumerable <IModelFilter>)null, false, (Func <Type, string>)null, false, false, false, (IEnumerable <IOperationFilter>)null, (IEnumerable <IDocumentFilter>)null, (Func <IEnumerable <ApiDescription>, ApiDescription>)null); }
private IEnumerable<MediaTypeFormatter> GetSupportedSwaggerFormatters(SwaggerGeneratorOptions options) { var jsonFormatter = new JsonMediaTypeFormatter { SerializerSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Converters = new List<JsonConverter>() { new VendorExtensionsConverter() } } }; if (options.DescribeAllEnumsAsStrings) { jsonFormatter.SerializerSettings.Converters.Add(new StringEnumConverter() { CamelCaseText = options.DescribeStringEnumsInCamelCase }); } // NOTE: The custom converter would not be neccessary in Newtonsoft.Json >= 5.0.5 as JsonExtensionData // provides similar functionality. But, need to stick with older version for WebApi 5.0.0 compatibility return new[] { jsonFormatter }; }
private SwaggerGenerator Subject( Action <FakeApiDescriptionGroupCollectionProvider> setupApis = null, Action <SwaggerGeneratorOptions> configure = null) { var apiDescriptionsProvider = new FakeApiDescriptionGroupCollectionProvider(); if (setupApis != null) { setupApis(apiDescriptionsProvider); } var options = new SwaggerGeneratorOptions(); if (configure != null) { configure(options); } return(new SwaggerGenerator( apiDescriptionsProvider, () => new SchemaGenerator(new DefaultContractResolver()), options )); }
private SwaggerGenerator Subject( Action<FakeApiDescriptionGroupCollectionProvider> setupApis = null, Action<SwaggerGeneratorOptions> configure = null) { var apiDescriptionsProvider = new FakeApiDescriptionGroupCollectionProvider(); if (setupApis != null) setupApis(apiDescriptionsProvider); var options = new SwaggerGeneratorOptions(); if (configure != null) configure(options); return new SwaggerGenerator( apiDescriptionsProvider, () => new SchemaGenerator(new JsonSerializerSettings()), options ); }
public static void DocumentFilter <TFilter>(this SwaggerGeneratorOptions options) where TFilter : IDocumentFilter, new() { options.DocumentFilters.Add(new TFilter()); }
public static void OperationFilter <TFilter>(this SwaggerGeneratorOptions options) where TFilter : IOperationFilter, new() { options.OperationFilters.Add(new TFilter()); }