swagger-api / swagger-api/swagger-codegen

NullPointerException caused by "in": "body"

Open
#5,931 2 comments 0 reactions 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

Using this command:

swagger-codegen generate -i https://raw.githubusercontent.com/npomfret/coinsbank-php-sdk/master/reference/coinsbank-sapi.json -l spring -o .

I'm getting a NPE that seems to be caused by this:

"/card/name/_{cardUniqueId}": {
  "put": {
    "description": "Set user-defined card name",
    "parameters": [
      {
        "name": "cardUniqueId",
        "in": "path",
        "description": "Card UID",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      {
        "name": "params",
        "in": "body",
        "description": "Card params",
        "requried": true,
        "schema": {
          "properties": {
            "name": {
              "type": "string",
              "description": "User-defined card name"
            }
          }
        }
      }
    ],
    "responses": {
      "200": {
        "description": "Card has been renamed"
      }
    }
  }
},

If I remove the "in": "body", section of the 2nd parameter (the one called "params" confusingly) it works. Is this invalid swagger?

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

Reproduce the failure with the swagger-codegen command and the referenced coinsbank-sapi.json definition, focusing on the parameter whose "in" value is "body". Inspect how body parameters are handled and confirm that generation no longer raises a NullPointerException, or reports the definition as invalid with a useful error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.