swagger-api / swagger-api/swagger-codegen

[typescript-angular] Primitive typed parameters

Open
#7,407 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: TypeScript General: Suggestion
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Hi,

I have some API's that contain primitive parameters in the request body of POST requests.
The problem is that primtive parameters are forced to be JSON encoded, generating random
interfaces like:

export interface Body2 {
usuario: OctopusEntitiesColetorTUsuario;
iRecnoSolicitacao: number;
}

This also happens to responses classes.

Thank you.

Swagger-codegen version

2.4.0.
Also tested on 2.3.0. Same problem.

Swagger declaration file content or url
"/WmsService/AlocarTransferirMateriaisWms":{
         "post":{
            "tags":[
               "WmsService"
            ],
            "operationId":"IWmsService.AlocarTransferirMateriaisWms",
            "consumes":[
               "application/json"
            ],
            "produces":[
               "application/json"
            ],
            "parameters":[
               {
                  "in":"body",
                  "name":"body",
                  "required":true,
                  "schema":{
                     "type":"object",
                     "properties":{
                        "sCodigoItem":{
                           "type":"string"
                        },
                        "sLote":{
                           "type":"string"
                        },
                        "sMotivoMovimentacao":{
                           "type":"string"
                        },
                        "sUsuarioSistema":{
                           "type":"string"
                        },
                        "dQtdeMovimentacao":{
                           "type":"number"
                        },
                        "iNumeroOdf":{
                           "type":"integer"
                        },
                        "iCodigoLocalOrigem":{
                           "type":"integer"
                        },
                        "iCodigoLocalDestino":{
                           "type":"integer"
                        },
                        "iEmpresaRecno":{
                           "type":"integer"
                        }
                     },
                     "required":[
                        "sCodigoItem",
                        "sLote",
                        "sMotivoMovimentacao",
                        "sUsuarioSistema",
                        "dQtdeMovimentacao",
                        "iNumeroOdf",
                        "iCodigoLocalOrigem",
                        "iCodigoLocalDestino",
                        "iEmpresaRecno"
                     ]
                  }
               }
            ],
            "responses":{
               "200":{
                  "description":"Successful response",
                  "schema":{
                     "type":"object",
                     "properties":{
                        "value":{
                           "type":"boolean"
                        }
                     }
                  }
               }
            }
         }
      },

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 by running the typescript-angular generator against the Swagger declaration in the issue, focusing on the POST body and response schemas containing primitive properties. Done means primitive request and response values use their declared types without generating unnecessary interfaces or JSON encoding.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.