swagger-api / swagger-api/swagger-codegen
NullPointerException during generation
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Hi, I have following swagger definition
/api/v2.0/accounts/{account_id}/rebate_accounts/{rebate_account_id}: {
post: {
parameters: [
{
description: "New rebate percent",
in: "body",
name: "body",
required: true,
type: "number"
},
{
default: "FBB1234.111",
description: "Account Id",
example: "FBB1234.111",
in: "path",
name: "account_id",
required: true,
type: "string"
}]
…
When I run generate command:
java -jar ./swagger-codegen-cli.jar generate -i http://localhost/api-docs/swagger.json -l python -o ../swagger-codegen
It fails with the following exception:
Exception in thread "main" java.lang.RuntimeException: Could not process operation:
Tag: accounts
Operation: null
Resource: post /api/v2.0/accounts/{account_id}/rebate_accounts/{rebate_account_id}
...
Exception: null
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:861)
at io.swagger.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:764)
at io.swagger.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:388)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:700)
at io.swagger.codegen.cmd.Generate.run(Generate.java:285)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
Caused by: java.lang.NullPointerException
at io.swagger.codegen.DefaultCodegen.isDataTypeBinary(DefaultCodegen.java:2682)
at io.swagger.codegen.DefaultCodegen.fromParameter(DefaultCodegen.java:2633)
at io.swagger.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:2191)
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:808)
... 5 more
ver. swagger-codegen 2.2.3
Swagger declaration file content or url
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
Reproduce the failure with the shown swagger-codegen generate command, then trace DefaultGenerator.processOperation through DefaultCodegen.fromParameter and isDataTypeBinary, where the stack trace reports the NullPointerException. Done means the supplied Swagger definition can generate Python output without this exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, python
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100