swagger-api / swagger-api/swagger-codegen
[aspnetcore] Required Error in params templates
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
In modules/swagger-codegen/src/main/resources/aspnetcore/:
The formParam.mustache, headerParam.mustache and queryParam.mustache templates have an error in the Required sentence that generate wrong params in the controller file. It would be [Required] and not [Required()]. The brackets are left over.
The pathParam.mustache template is correct.
Swagger-codegen version
Latest master
Swagger declaration file content or url
modules/swagger-codegen/src/main/resources/aspnetcore/formParam.mustache
modules/swagger-codegen/src/main/resources/aspnetcore/headerParam.mustache
modules/swagger-codegen/src/main/resources/aspnetcore/queryParam.mustache
Steps to reproduce
Genereate an aspnetcore project with:
paths:
/customers:
get:
operationId: getCustomerById
parameters:
- in: query
name: idCustomer
description: customer id
required: true
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CustomerCard'
Suggest a fix/enhancement
Remove the brackets of [Required()] in:
modules/swagger-codegen/src/main/resources/aspnetcore/formParam.mustache
modules/swagger-codegen/src/main/resources/aspnetcore/headerParam.mustache
modules/swagger-codegen/src/main/resources/aspnetcore/queryParam.mustache
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 modules/swagger-codegen/src/main/resources/aspnetcore/formParam.mustache, headerParam.mustache, and queryParam.mustache, comparing them with pathParam.mustache. Generate an aspnetcore project from the supplied OpenAPI example. Done means the generated controller uses the expected Required annotation for the affected parameter templates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100