Skip to content

Configuration

OpenApiWeaverDocument item

Configure OpenApiWeaver by declaring the OpenApiWeaverDocument MSBuild item. The item supports the following metadata:

MetadataRequiredDescriptionDefault
IncludeYesPath to the OpenAPI document (.json, .yaml, or .yml)-
ClientNameNoName of the generated root client classFile name -> PascalCase + Client
NamespaceNoNamespace for all generated typesProject's RootNamespace

Example

xml
<ItemGroup>
  <OpenApiWeaverDocument Include="openapi\petstore.yaml"
                         ClientName="PetstoreClient"
                         Namespace="Contoso.Generated" />
</ItemGroup>

At build time, the package's buildTransitive targets project each OpenApiWeaverDocument item into compiler-visible AdditionalFiles and forward the ClientName and Namespace metadata to the source generator.

Multiple documents

You can include multiple OpenAPI documents in a single project. Each document generates an independent client:

xml
<ItemGroup>
  <OpenApiWeaverDocument Include="openapi\petstore.yaml"
                         ClientName="PetstoreClient"
                         Namespace="Contoso.Petstore" />
  <OpenApiWeaverDocument Include="openapi\billing.json"
                         ClientName="BillingClient"
                         Namespace="Contoso.Billing" />
</ItemGroup>

Client name derivation

When ClientName is not specified, the generator derives the client name from the file name by converting it to PascalCase and appending Client:

File NameGenerated Client Name
petstore.yamlPetstoreClient
api-schema.jsonApiSchemaClient
my_service.ymlMyServiceClient

Supported document formats

OpenApiWeaver reads OpenAPI 3.0-3.2 documents in the following formats:

ExtensionFormat
.jsonOpenAPI 3.x JSON
.yamlOpenAPI 3.x YAML
.ymlOpenAPI 3.x YAML

Files with other extensions are ignored, even if they are included through OpenApiWeaverDocument.

Document discovery

The generator processes only OpenApiWeaverDocument items.

  • Files added directly as AdditionalFiles are ignored
  • ClientName and Namespace metadata are only available when supplied through OpenApiWeaverDocument

Released under the MIT License.