Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation for ISwaggerDocumentSerializer #2837

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ The steps described above will get you up and running with minimal setup. Howeve
* [Modify Swagger with Request Context](#modify-swagger-with-request-context)
* [Serialize Swagger JSON in the 2.0 format](#serialize-swagger-in-the-20-format)
* [Working with Virtual Directories and Reverse Proxies](#working-with-virtual-directories-and-reverse-proxies)
* [Customizing how the OpenAPI document is serialized](#customizing-how-the-openapi-document-is-serialized)

* [Swashbuckle.AspNetCore.SwaggerGen](#swashbuckleaspnetcoreswaggergen)

Expand Down Expand Up @@ -318,6 +319,29 @@ app.UseSwaggerUI(c =>

_NOTE: In previous versions of the docs, you may have seen this expressed as a root-relative link (e.g. `/swagger/v1/swagger.json`). This won't work if your app is hosted on an IIS virtual directory or behind a proxy that trims the request path before forwarding. If you switch to the *page-relative* syntax shown above, it should work in all cases._

### Customizing how the OpenAPI document is serialized ###

By default, Swagger will serialize the OpenAPI document using the Serialize methods on the OpenAPI document object. If a customized serialization is desired,
martincostello marked this conversation as resolved.
Show resolved Hide resolved
it is possible to create a custom document serializer that implements the `ISwaggerDocumentSerializer` interface. This can be set on the SwaggerOptions in the service collection using ConfigureSwagger():
remcolam marked this conversation as resolved.
Show resolved Hide resolved

_NOTE: If you plan on using the commandline tool to generate OpenAPI specification files, this must be done on the service collection using ConfigureSwagger()._
remcolam marked this conversation as resolved.
Show resolved Hide resolved

```csharp
services.ConfigureSwagger(c =>
{
c.SetCustomDocumentSerializer<CustomDocumentSerializer>();
})
remcolam marked this conversation as resolved.
Show resolved Hide resolved
```

When the commandline tool is not used, it can also be done on the application host:
remcolam marked this conversation as resolved.
Show resolved Hide resolved

```csharp
app.UseSwagger(c =>
{
c.SetCustomDocumentSerializer<CustomDocumentSerializer>();
})
remcolam marked this conversation as resolved.
Show resolved Hide resolved
```

## Swashbuckle.AspNetCore.SwaggerGen ##

### Assign Explicit OperationIds ###
Expand Down