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

[ASPNETCORE] Generation of Interfaces Only? #9141

Closed
Peter554 opened this issue Feb 1, 2019 · 1 comment
Closed

[ASPNETCORE] Generation of Interfaces Only? #9141

Peter554 opened this issue Feb 1, 2019 · 1 comment

Comments

@Peter554
Copy link

Peter554 commented Feb 1, 2019

Description

I'm trying to use the swagger codegen to design and then stub out my Api. On the server side I'm using asp dotnet Core. The generated code is very elaborate but at hard as I try I can't find online any real info about how to control the output. Specifically I would really just like to stub out interfaces for my controllers and generate model definitions. I then want to handle the implementation of those interfaces myself seperately. I also don't need a whole .csproj and .sln really - I just want the interfaces and models. Is this possible? Where can I find documentation relating to the asp dotnet Core options?

Swagger-codegen version

https://hub.docker.com/r/swaggerapi/swagger-codegen-cli (latest)

Swagger declaration file content or url

https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v2.0/json/petstore-minimal.json

Command line used for generation

docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli generate -i /local/petstore-minimal.json -l as pnetcore -o /local/gen

Steps to reproduce
Related issues/PRs

Couldn't find any?

Suggest a fix/enhancement

More documentation.

@frantuma
Copy link
Member

frantuma commented Aug 1, 2019

To limit the generated output to models and controllers, you can provide system properties as mentioned in README.

Since 2.4.7 version it is possible to only generate interfaces by adding interface-only=true to additionalProperties,

Such properties are listed in language options by running

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar config-help -l aspnetcore

the following command limits the output to models and controller interfaces

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
   -i https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/json/petstore-minimal.json \
   -l aspnetcore \
   -o /tmp/codegen/aspnet \
   --api-package my.api \
   --model-package my.model \
   --additional-properties sourceFolder=src,interface-only=true \
   -D models \
   -D apis \
   -D modelDocs=false \
   -D apiTests=false \
   -D apiDocs=false 

please close ticket if this answers your question

@Peter554 Peter554 closed this as completed Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants