/// <summary>Initializes a new instance of the <see cref="SwaggerMiddleware"/> class.</summary> /// <param name="next">The next middleware.</param> /// <param name="path">The path.</param> /// <param name="controllerTypes">The controller types.</param> /// <param name="settings">The settings.</param> /// <param name="schemaGenerator">The schema generator.</param> public SwaggerMiddleware(OwinMiddleware next, string path, IEnumerable<Type> controllerTypes, SwaggerOwinSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) : base(next) { _path = path; _controllerTypes = controllerTypes; _settings = settings; _schemaGenerator = schemaGenerator; }
/// <summary>Addes the Swagger generator to the OWIN pipeline.</summary> /// <param name="app">The app.</param> /// <param name="controllerTypes">The Web API controller types.</param> /// <param name="settings">The Swagger generator settings.</param> /// <param name="schemaGenerator">The schema generator.</param> /// <returns>The app builder.</returns> public static IApplicationBuilder UseSwagger( this IApplicationBuilder app, IEnumerable<Type> controllerTypes, SwaggerOwinSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { app.UseMiddleware<SwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator); return app; }
/// <summary>Addes the Swagger generator to the OWIN pipeline.</summary> /// <param name="app">The app.</param> /// <param name="controllerTypes">The Web API controller types.</param> /// <param name="settings">The Swagger generator settings.</param> /// <param name="schemaGenerator">The schema generator.</param> /// <returns>The app builder.</returns> public static IApplicationBuilder UseSwagger( this IApplicationBuilder app, IEnumerable <Type> controllerTypes, SwaggerSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { app.UseMiddleware <SwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator); return(app); }
/// <summary>Initializes a new instance of the <see cref="WebApiToSwaggerMiddleware"/> class.</summary> /// <param name="nextDelegate">The next delegate.</param> /// <param name="mvcJsonOptions">The injected MVC JSON options.</param> /// <param name="path">The path.</param> /// <param name="controllerTypes">The controller types.</param> /// <param name="settings">The settings.</param> /// <param name="schemaGenerator">The schema generator.</param> public WebApiToSwaggerMiddleware(RequestDelegate nextDelegate, IOptions <MvcJsonOptions> mvcJsonOptions, string path, IEnumerable <Type> controllerTypes, SwaggerSettings <WebApiToSwaggerGeneratorSettings> settings, SwaggerJsonSchemaGenerator schemaGenerator) { _nextDelegate = nextDelegate; _mvcJsonOptions = mvcJsonOptions; _path = path; _controllerTypes = controllerTypes; _settings = settings; _schemaGenerator = schemaGenerator; }
/// <summary>Initializes a new instance of the <see cref="WebApiToSwaggerMiddleware"/> class.</summary> /// <param name="nextDelegate">The next delegate.</param> /// <param name="apiDescriptionGroupCollectionProvider">The <see cref="IApiDescriptionGroupCollectionProvider"/>.</param> /// <param name="settings">The settings.</param> /// <param name="schemaGenerator">The schema generator.</param> public AspNetCoreToSwaggerMiddleware(RequestDelegate nextDelegate, IApiDescriptionGroupCollectionProvider apiDescriptionGroupCollectionProvider, IOptions <MvcJsonOptions> mvcJsonOptions, SwaggerSettings <AspNetCoreToSwaggerGeneratorSettings> settings, SwaggerJsonSchemaGenerator schemaGenerator) { _nextDelegate = nextDelegate; _settings = settings; _path = settings.ActualSwaggerRoute; _schemaGenerator = schemaGenerator; _apiDescriptionGroupCollectionProvider = apiDescriptionGroupCollectionProvider; _mvcJsonOptions = mvcJsonOptions; }
/// <summary>Adds the Swagger generator that uses Api Description to perform Swagger generation.</summary> /// <param name="app">The app.</param> /// <param name="configure">Configure the Swagger settings.</param> /// <param name="schemaGenerator">The schema generator.</param> public static IApplicationBuilder UseSwaggerWithApiExplorer( this IApplicationBuilder app, Action <SwaggerSettings <AspNetCoreToSwaggerGeneratorSettings> > configure = null, SwaggerJsonSchemaGenerator schemaGenerator = null) { var settings = new SwaggerSettings <AspNetCoreToSwaggerGeneratorSettings>(); configure?.Invoke(settings); return(app.UseMiddleware <AspNetCoreToSwaggerMiddleware>(settings, schemaGenerator ?? new SwaggerJsonSchemaGenerator(settings.GeneratorSettings))); }
/// <summary>Addes the Swagger generator to the OWIN pipeline.</summary> /// <param name="app">The app.</param> /// <param name="controllerTypes">The Web API controller types.</param> /// <param name="settings">The Swagger generator settings.</param> /// <param name="schemaGenerator">The schema generator.</param> /// <returns>The app builder.</returns> public static IAppBuilder UseSwagger( this IAppBuilder app, IEnumerable<Type> controllerTypes, SwaggerOwinSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { app.Use<SwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator); app.UseStageMarker(PipelineStage.MapHandler); return app; }
/// <summary>Addes the Swagger generator to the OWIN pipeline.</summary> /// <param name="app">The app.</param> /// <param name="controllerTypes">The Web API controller types.</param> /// <param name="settings">The Swagger generator settings.</param> /// <param name="schemaGenerator">The schema generator.</param> /// <returns>The app builder.</returns> public static IAppBuilder UseSwagger( this IAppBuilder app, IEnumerable <Type> controllerTypes, SwaggerSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { app.Use <SwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator); app.UseStageMarker(PipelineStage.MapHandler); return(app); }
/// <summary>Adds the Swagger generator to the pipeline.</summary> /// <param name="app">The app.</param> /// <param name="controllerTypes">The Web API controller types.</param> /// <param name="configure">Configure the Swagger settings.</param> /// <param name="schemaGenerator">The schema generator.</param> /// <returns>The app builder.</returns> public static IApplicationBuilder UseSwagger( this IApplicationBuilder app, IEnumerable <Type> controllerTypes, Action <SwaggerSettings <WebApiToSwaggerGeneratorSettings> > configure = null, SwaggerJsonSchemaGenerator schemaGenerator = null) { var settings = new SwaggerSettings <WebApiToSwaggerGeneratorSettings>(); configure?.Invoke(settings); app.UseMiddleware <WebApiToSwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator ?? new SwaggerJsonSchemaGenerator(settings.GeneratorSettings)); return(app); }
public async Task<SwaggerDocument> Generate(IAppEntity app, IEnumerable<ISchemaEntity> schemas) { document = SwaggerHelper.CreateApiDocument(context, urlOptions, app.Name); schemaGenerator = new SwaggerJsonSchemaGenerator(settings); schemaResolver = new SwaggerSchemaResolver(document, settings); GenerateSchemasOperations(schemas, app); await GenerateDefaultErrorsAsync(); return document; }
/// <summary>Addes the Swagger generator to the OWIN pipeline.</summary> /// <param name="app">The app.</param> /// <param name="controllerTypes">The Web API controller types.</param> /// <param name="configure">Configure the Swagger settings.</param> /// <param name="schemaGenerator">The schema generator.</param> /// <returns>The app builder.</returns> public static IAppBuilder UseSwagger( this IAppBuilder app, IEnumerable <Type> controllerTypes, Action <SwaggerSettings <WebApiToSwaggerGeneratorSettings> > configure = null, SwaggerJsonSchemaGenerator schemaGenerator = null) { var settings = new SwaggerSettings <WebApiToSwaggerGeneratorSettings>(); configure?.Invoke(settings); app.Use <SwaggerDocumentMiddleware>(settings.ActualSwaggerDocumentPath, controllerTypes, settings, schemaGenerator ?? new SwaggerJsonSchemaGenerator(settings.GeneratorSettings)); app.UseStageMarker(PipelineStage.MapHandler); return(app); }
public SchemasSwaggerGenerator(IHttpContextAccessor context, SwaggerOwinSettings swaggerSettings, IOptions <MyUrlsOptions> urlOptions) { this.context = context.HttpContext; this.urlOptions = urlOptions.Value; schemaGenerator = new SwaggerJsonSchemaGenerator(swaggerSettings); schemaResolver = new SwaggerSchemaResolver(document, swaggerSettings); swaggerGenerator = new SwaggerGenerator(schemaGenerator, swaggerSettings, schemaResolver); schemaBodyDescription = SwaggerHelper.LoadDocs("schemabody"); schemaQueryDescription = SwaggerHelper.LoadDocs("schemaquery"); }
/// <summary>Addes the Swagger generator and Swagger UI to the OWIN pipeline.</summary> /// <param name="app">The app.</param> /// <param name="controllerTypes">The Web API controller types.</param> /// <param name="settings">The Swagger generator settings.</param> /// <param name="schemaGenerator">The schema generator.</param> /// <returns>The app builder.</returns> public static IApplicationBuilder UseSwaggerUi( this IApplicationBuilder app, IEnumerable<Type> controllerTypes, SwaggerUiOwinSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { app.UseMiddleware<RedirectMiddleware>(settings.ActualSwaggerUiRoute, settings.ActualSwaggerUiRoute); app.UseMiddleware<SwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator); app.UseMiddleware<SwaggerUiIndexMiddleware>(settings.ActualSwaggerUiRoute + "/index.html", settings); app.UseFileServer(new FileServerOptions { RequestPath = new PathString(settings.ActualSwaggerUiRoute), FileProvider = new EmbeddedFileProvider(typeof(SwaggerExtensions).GetTypeInfo().Assembly, "NSwag.AspNetCore.SwaggerUi") }); return app; }
/// <summary>Addes the Swagger generator and Swagger UI to the OWIN pipeline.</summary> /// <param name="app">The app.</param> /// <param name="controllerTypes">The Web API controller types.</param> /// <param name="settings">The Swagger generator settings.</param> /// <param name="schemaGenerator">The schema generator.</param> /// <returns>The app builder.</returns> public static IAppBuilder UseSwaggerUi( this IAppBuilder app, IEnumerable <Type> controllerTypes, SwaggerUiOwinSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { app.Use <RedirectMiddleware>(settings.ActualSwaggerUiRoute, settings.ActualSwaggerRoute); app.Use <SwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator); app.Use <SwaggerUiIndexMiddleware>(settings.ActualSwaggerUiRoute + "/index.html", settings); app.UseFileServer(new FileServerOptions { RequestPath = new PathString(settings.ActualSwaggerUiRoute), FileSystem = new EmbeddedResourceFileSystem(typeof(SwaggerExtensions).Assembly, "NSwag.AspNet.Owin.SwaggerUi") }); app.UseStageMarker(PipelineStage.MapHandler); return(app); }
/// <summary>Adds the Swagger generator and Swagger UI to the pipeline.</summary> /// <param name="app">The app.</param> /// <param name="configure">Configure the Swagger settings.</param> /// <param name="schemaGenerator">The schema generator.</param> /// <returns>The app builder.</returns> public static IApplicationBuilder UseSwaggerReDocWithApiExplorer( this IApplicationBuilder app, Action <SwaggerUiSettings <AspNetCoreToSwaggerGeneratorSettings> > configure = null, SwaggerJsonSchemaGenerator schemaGenerator = null) { var settings = new SwaggerUiSettings <AspNetCoreToSwaggerGeneratorSettings>(); configure?.Invoke(settings); app.UseMiddleware <AspNetCoreToSwaggerMiddleware>(settings, schemaGenerator ?? new SwaggerJsonSchemaGenerator(settings.GeneratorSettings)); app.UseMiddleware <RedirectMiddleware>(settings.ActualSwaggerUiRoute, settings.ActualSwaggerRoute); app.UseMiddleware <SwaggerUiIndexMiddleware <AspNetCoreToSwaggerGeneratorSettings> >(settings.ActualSwaggerUiRoute + "/index.html", settings, "NSwag.AspNetCore.ReDoc.index.html"); app.UseFileServer(new FileServerOptions { RequestPath = new PathString(settings.ActualSwaggerUiRoute), FileProvider = new EmbeddedFileProvider(typeof(SwaggerExtensions).GetTypeInfo().Assembly, "NSwag.AspNetCore.ReDoc") }); return(app); }
/// <summary>Initializes a new instance of the <see cref="SwaggerMiddleware"/> class.</summary> /// <param name="nextDelegate">The next delegate.</param> /// <param name="apiDescriptionGroupCollectionProvider">The <see cref="IApiDescriptionGroupCollectionProvider"/>.</param> /// <param name="settings">The settings.</param> /// <param name="schemaGenerator">The schema generator.</param> public AspNetCoreSwaggerMiddleware(RequestDelegate nextDelegate, IApiDescriptionGroupCollectionProvider apiDescriptionGroupCollectionProvider, AspNetCoreToSwaggerMiddlewareSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { _nextDelegate = nextDelegate; _settings = settings; _path = settings.ActualSwaggerRoute; _schemaGenerator = schemaGenerator; _apiDescriptionGroupCollectionProvider = apiDescriptionGroupCollectionProvider; }
/// <summary>Initializes a new instance of the <see cref="SwaggerMiddleware"/> class.</summary> /// <param name="nextDelegate">The next delegate.</param> /// <param name="path">The path.</param> /// <param name="controllerTypes">The controller types.</param> /// <param name="settings">The settings.</param> /// <param name="schemaGenerator">The schema generator.</param> public SwaggerMiddleware(RequestDelegate nextDelegate, string path, IEnumerable <Type> controllerTypes, SwaggerOwinSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { _nextDelegate = nextDelegate; _path = path; _controllerTypes = controllerTypes; _settings = settings; _schemaGenerator = schemaGenerator; }
/// <summary>Initializes a new instance of the <see cref="WebApiToSwaggerGenerator" /> class.</summary> /// <param name="settings">The settings.</param> /// <param name="schemaGenerator">The schema generator.</param> public WebApiToSwaggerGenerator(WebApiToSwaggerGeneratorSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { Settings = settings; _schemaGenerator = schemaGenerator; }
/// <summary>Initializes a new instance of the <see cref="AspNetCoreToSwaggerGenerator" /> class.</summary> /// <param name="settings">The settings.</param> /// <param name="schemaGenerator">The schema generator.</param> public AspNetCoreToSwaggerGenerator(AspNetCoreToSwaggerGeneratorSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { Settings = settings; _schemaGenerator = schemaGenerator; }
/// <summary>Addes the Swagger generator and Swagger UI to the OWIN pipeline.</summary> /// <param name="app">The app.</param> /// <param name="controllerTypes">The Web API controller types.</param> /// <param name="settings">The Swagger UI and generator settings.</param> /// <param name="schemaGenerator">The schema generator.</param> /// <returns>The app builder.</returns> public static IApplicationBuilder UseSwaggerUi( this IApplicationBuilder app, IEnumerable<Type> controllerTypes, SwaggerUiOwinSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { if (controllerTypes != null) app.UseMiddleware<SwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator); app.UseMiddleware<RedirectMiddleware>(settings.ActualSwaggerUiRoute, settings.ActualSwaggerRoute); app.UseMiddleware<SwaggerUiIndexMiddleware>(settings.ActualSwaggerUiRoute + "/index.html", settings); app.UseFileServer(new FileServerOptions { RequestPath = new PathString(settings.ActualSwaggerUiRoute), FileProvider = new EmbeddedFileProvider(typeof(SwaggerExtensions).GetTypeInfo().Assembly, "NSwag.AspNetCore.SwaggerUi") }); return app; }
/// <summary>Initializes a new instance of the <see cref="SwaggerMiddleware"/> class.</summary> /// <param name="next">The next middleware.</param> /// <param name="path">The path.</param> /// <param name="controllerTypes">The controller types.</param> /// <param name="settings">The settings.</param> /// <param name="schemaGenerator">The schema generator.</param> public SwaggerMiddleware(OwinMiddleware next, string path, IEnumerable <Type> controllerTypes, SwaggerSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) : base(next) { _path = path; _controllerTypes = controllerTypes; _settings = settings; _schemaGenerator = schemaGenerator; }
/// <summary>Addes the Swagger generator and Swagger UI to the OWIN pipeline.</summary> /// <param name="app">The app.</param> /// <param name="controllerTypes">The Web API controller types.</param> /// <param name="settings">The Swagger UI and generator settings.</param> /// <param name="schemaGenerator">The schema generator.</param> /// <returns>The app builder.</returns> public static IAppBuilder UseSwaggerUi( this IAppBuilder app, IEnumerable<Type> controllerTypes, SwaggerUiOwinSettings settings, SwaggerJsonSchemaGenerator schemaGenerator) { if (controllerTypes != null) app.Use<SwaggerMiddleware>(settings.ActualSwaggerRoute, controllerTypes, settings, schemaGenerator); app.Use<RedirectMiddleware>(settings.ActualSwaggerUiRoute, settings.ActualSwaggerRoute); app.Use<SwaggerUiIndexMiddleware>(settings.ActualSwaggerUiRoute + "/index.html", settings); app.UseFileServer(new FileServerOptions { RequestPath = new PathString(settings.ActualSwaggerUiRoute), FileSystem = new EmbeddedResourceFileSystem(typeof(SwaggerExtensions).Assembly, "NSwag.AspNet.Owin.SwaggerUi") }); app.UseStageMarker(PipelineStage.MapHandler); return app; }