8

I have an OpenAPI 3.0 schema YAML document that defines some API endpoints with all the required parameters and responses.

Now, I'd like to generate some boilerplate server-side code: the controllers and their methods. My API will be written using ASP.NET Core 2. So, is it possible to use some kind of generators or should I do it manually?

P.S. I know that I can generate the client-side code, but I don't need it right now...

andrew.fox
  • 7,435
  • 5
  • 52
  • 75
Daniel Vygolov
  • 884
  • 2
  • 13
  • 26
  • OAS3 support in Swagger-Codegen is in progress - but the ASP.NET codegen is currently not available. https://github.com/swagger-api/swagger-codegen/issues/6598#issuecomment-360780224 – Helen Feb 05 '18 at 11:11
  • Related: [How to run swagger-codegen for openapi 3.0.0](https://stackoverflow.com/q/45717099/113116) – Helen Feb 05 '18 at 11:12

2 Answers2

10

Please try OpenAPI Generator, which is a community-driven version of Swagger Codegen and supports both OpenAPI spec v2, v3.

For more information on why we (top contributors) forked it, please refer to the Q&A

If you've docker installed, you can easily try it with the following command

docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate \
    -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml \
    -g aspnetcore \
    -o /local/out/aspnetcore

For any question or feedback, please open a ticket via https://github.com/OpenAPITools/openapi-generator/issues/new

Gabriel Kunkel
  • 2,643
  • 5
  • 25
  • 47
William Cheng
  • 10,137
  • 5
  • 54
  • 79
0

I think there exist some tools for NSwag that generate server-side code. enter image description here

src: https://learn.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-nswag?view=aspnetcore-5.0&tabs=visual-studio

The tool NSwagStudio has also an option for the controller generation enter image description here

troYman
  • 1,648
  • 16
  • 18