Skip to content

martin-hirsch/NSwag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

Controller

docker run --rm --volume "$(CURDIR):/app/publish" nswag \
  --file "/app/publish/my.oas.yaml" \
  --namespace "My.Namespace" \
  --generator "controller"

Client

docker run --rm --volume "$(CURDIR):/app/publish" nswag \
  --file "publish/my.oas.yaml" \
  --namespace "My.Namespace" \
  --generator "client" \
  --suffix "Contract" \
  --inject-http-client true

Options

  • --file: (Required) The path to the OpenAPI specification file.
  • --namespace: (Required) The namespace for the generated code.
  • --generator: (Required) Select whether to generate a Client or a Controller.
  • --suffix: The suffix for the generated classes.
  • --inject-http-client: Whether to inject an HttpClient into the generated client (default: false).
  • --output: The output path for the generated file. If not specified, the input file path with .cs extension will be used.

Advanced Example

The following example shows how to use the --output option~~~~ to specify a custom path for the generated file.

generate-test-client:
	docker run --rm --volume '$(CURDIR):/app/publish' nswag \
	--file 'publish/my.oas.yaml' \
	--namespace 'My.Other.Namespace' \
	--generator 'client' \
	--suffix 'Dto' \
	--output 'publish/My.Other.Namespace/Rest/my.oas.yaml.cs'

About

NSwag, wrapped in a Console App - rdy for Docker

Resources

Stars

Watchers

Forks

Contributors