swagger-api / swagger-api/swagger-codegen
TermsOfService null produces run-time error with aspnetcore server stub generator
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When using the aspnetcore server stub generator, this generation command results with broken output if the user fails to provide a value for the termsOfService additional property.
Take this generation CLI command, which is about as basic a getting-started experience as a user would expect to make, with as few parameters as possible.
# generates aspnetcore server stub, outputs locally to ./out/petstore/server
./run-in-docker.sh generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml \
-l aspnetcore \
-o /gen/out/petstore/server \
--additional-properties packageName=PetStore.Api
This results in C# code that looks like this:
TermsOfService = new Uri("")
At run-time, this causes an error, as the Uri shouldn't be empty, and when empty, throws. I've prepared a pull request to accommodate this issue's resolution, which I'll submit along with the issue for consideration.
Thanks! I'd like to add an asp.net core 3.1 generator, too, so I may reach out if I run into any issues or have questions - anyone specific I should mention?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generation command in run-in-docker.sh using modules/swagger-codegen/src/test/resources/2_0/petstore.yaml and the aspnetcore generator, then inspect the generated C# around TermsOfService. Reproduce the empty-value case and verify that the generated output no longer causes a runtime Uri error when termsOfService is omitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100