Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

NullPointer when generating after change on 2019-02-23 #329

Closed
Discordia opened this issue Mar 15, 2019 · 3 comments · Fixed by #330
Closed

NullPointer when generating after change on 2019-02-23 #329

Discordia opened this issue Mar 15, 2019 · 3 comments · Fixed by #330

Comments

@Discordia
Copy link

Discordia commented Mar 15, 2019

We have been using the 3.0.0 branch of swagger-codegen to generate som code for our rest APIs. It was working fine until I took a pull of swagger-codegen. I have tracked the issue down to a change made on the 23 of February 2019 in this project (swagger-codegen-generators):
"added contenttype extension for response schema. Hugo Mercado 2019-02-23 20:00"

There was a change then in the file DefaultCodegenConfig on rows: 3755-3757.

Now when I use for instance this yaml to generate:

openapi: 3.0.1
info:
  title: Authentication API
  description: Authentication API
  contact:
    url: https://example.net
  license:
    name: Proprietary
    url: https://example.net
  version: "1.0"
servers:
- url: https://example.net
tags:
- name: /authentication
paths:
  /authentication/#_with_token:
    post:
      tags:
      - /authentication
      operationId: loginWithToken
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AuthenticationTokenRequest'
        required: true
      responses:
        default:
          content:
            application/json: {}
components:
  schemas:
    AuthenticationTokenRequest:
      type: object
      properties:
        identityToken:
          minLength: 1
          type: string

I get a NullPointerException in Default.CodegenConfig.getSchemaFromResponse. Heres part of the log with the error:

12:49:57.957 [Thread-1] DEBUG io.swagger.codegen.v3.config.CodegenConfigurator - getClientOptInput - parsed inputSpecURL ../authentication-api-1.0.yml
12:49:58.146 [Thread-1] DEBUG com.github.jknack.handlebars.internal.HbsParserFactory - About to parse: /handlebars/cpp/model-header.mustache
12:49:58.199 [Thread-1] DEBUG com.github.jknack.handlebars.internal.HbsParserFactory - Building AST
12:49:58.241 [Thread-1] DEBUG com.github.jknack.handlebars.internal.HbsParserFactory - Applying Mustache spec
12:49:58.250 [Thread-1] DEBUG com.github.jknack.handlebars.internal.HbsParserFactory - Creating templates
12:49:58.277 [Thread-1] INFO io.swagger.codegen.v3.AbstractGenerator - writing file /var/tmp/authentication-client/example/api/authentication/AuthenticationTokenRequest.h
java.lang.NullPointerException
        at io.swagger.codegen.v3.generators.DefaultCodegenConfig.getSchemaFromResponse(DefaultCodegenConfig.java:3773)
        at io.swagger.codegen.v3.generators.DefaultCodegenConfig.fromResponse(DefaultCodegenConfig.java:2192)
        at io.swagger.codegen.v3.generators.DefaultCodegenConfig.fromOperation(DefaultCodegenConfig.java:1903)
        at io.swagger.codegen.v3.DefaultGenerator.processOperation(DefaultGenerator.java:847)
        at io.swagger.codegen.v3.DefaultGenerator.processPaths(DefaultGenerator.java:774)
        at io.swagger.codegen.v3.DefaultGenerator.generateApis(DefaultGenerator.java:419)
        at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:722)
        at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:342)
        at java.lang.Thread.run(Thread.java:748)
Exception in thread "Thread-1" java.lang.RuntimeException: Could not process operation:
  Tag: class Tag {
    name: /authentication
    description: null
    externalDocs: null
}
  Operation: loginWithToken
  Resource: post /authentication/#_with_token
  Exception: null
        at io.swagger.codegen.v3.DefaultGenerator.processOperation(DefaultGenerator.java:872)
        at io.swagger.codegen.v3.DefaultGenerator.processPaths(DefaultGenerator.java:774)
        at io.swagger.codegen.v3.DefaultGenerator.generateApis(DefaultGenerator.java:419)
        at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:722)
        at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:342)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
        at io.swagger.codegen.v3.generators.DefaultCodegenConfig.getSchemaFromResponse(DefaultCodegenConfig.java:3773)
        at io.swagger.codegen.v3.generators.DefaultCodegenConfig.fromResponse(DefaultCodegenConfig.java:2192)
        at io.swagger.codegen.v3.generators.DefaultCodegenConfig.fromOperation(DefaultCodegenConfig.java:1903)
        at io.swagger.codegen.v3.DefaultGenerator.processOperation(DefaultGenerator.java:847)
        ... 5 more
@HugoMario
Copy link
Contributor

Hi @Discordia, sorry for this mess, going to work on a fix with high priority

@Discordia
Copy link
Author

@HugoMario Thanks!

@HugoMario
Copy link
Contributor

@Discordia this has been fixed with #330 , can you please check when you have a chance? if you find something wrong, please don't hesitate to let me know.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants