/// <summary> /// Confgures Swaschbuckle to provide additional metadata in methods which use FromQuery attribute so the API provided by DotVVM API generator is easier to use. /// </summary> public static void EnableDotvvmIntegration(this SwaggerDocsConfig options, Action <DotvvmApiOptions> configureOptions = null) { var apiOptions = new DotvvmApiOptions(); configureOptions?.Invoke(apiOptions); var propertySerialization = new DefaultPropertySerialization(); options.OperationFilter(() => new AddAsObjectAnnotationOperationFilter(propertySerialization)); options.SchemaFilter(() => new AddTypeToModelSchemaFilter()); options.DocumentFilter(() => new HandleKnownTypesDocumentFilter(apiOptions, propertySerialization)); }
public static void Init(TestContext testContext) { var t = typeof(CompaniesController); var config = new HttpConfiguration(); config.MapHttpAttributeRoutes(); config.EnsureInitialized(); var apiExplorer = new ApiExplorer(config); var settings = new JsonSerializerSettings(); var versions = new Dictionary <string, Info> { { "v1", new Info() { version = "v1", title = "Test API" } } }; var apiOptions = new DotvvmApiOptions(); apiOptions.AddKnownType(typeof(Company <string>)); var options = new SwaggerGeneratorOptions(operationFilters: new IOperationFilter[] { // default filters used by Swashbuckle new HandleFromUriParams(), new ApplySwaggerOperationAttributes(), new ApplySwaggerResponseAttributes(), new ApplySwaggerOperationFilterAttributes(), // our custom filters new AddAsObjectAnnotationOperationFilter(new DefaultPropertySerialization()), }, schemaFilters: new[] { new AddTypeToModelSchemaFilter() }, documentFilters: new[] { new HandleKnownTypesDocumentFilter(apiOptions, new DefaultPropertySerialization()) }); var generator = new SwaggerGenerator(apiExplorer, settings, versions, options); document = generator.GetSwagger("http://localhost:61453/", "v1"); }
public AddAsObjectOperationFilter(IOptions <DotvvmApiOptions> knownTypesOptions) { this.knownTypesOptions = knownTypesOptions.Value; this.propertySerialization = new DefaultPropertySerialization(); }
public HandleKnownTypesDocumentFilter(DotvvmApiOptions apiOptions, IPropertySerialization propertySerialization) { this.apiOptions = apiOptions; this.propertySerialization = propertySerialization; }