swagger-api / swagger-api/swagger-codegen

[aspnetcore] Required Error in params templates

Open
#9,436 0 comments 1 reaction 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.