Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

[BUG] Null pointer exception thrown when openapi doc has no components #259

@spacether

Description

@spacether

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request
Description

Opening this issue per: #237 (comment)

Reported by @robin-nitrokey

Thanks! I tried to use 3.2.0 but it does not work for me:

  • On the nethsm-sdk-py codebase, it does not generate path parameters.
  • On the example from this issue, it causes a NullPointerException.
  • On Example 1, it does not generate the path parameters either.
  • On Example 2, I again get a NullPointerException.

Am I missing something?

Example 1
openapi: 3.0.0
info:
  title: NetHSM
  version: v1
servers:
  - url: https://{host}/api/{version}
    variables:
      host:
        default: localhost:8443
      version:
        default: v1
paths:
  /users/{UserID}:
    parameters:
      - name: UserID
        in: path
        required: true
        schema:
          type: string
    get:
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                type: string
      description: "Get user info: name and role."
components:
  securitySchemes:
    basic:
      description: |
        NetHSM supports Basic Authentication.
      type: http
      scheme: basic
Example 2
openapi: 3.0.0
info:
  title: NetHSM
  version: v1
servers:
  - url: https://{host}/api/{version}
    variables:
      host:
        default: localhost:8443
      version:
        default: v1
paths:
  /users/{UserID}:
    parameters:
      - name: UserID
        in: path
        required: true
        schema:
          type: string
    get:
      responses:
        "200":
          description: ""
          content:
            application/json:
              schema:
                type: string
      description: "Get user info: name and role."

NPE:

Exception in thread "main" java.lang.NullPointerException
        at org.openapijsonschematools.codegen.generatorrunner.DefaultGeneratorRunner.generateRequestBodies(DefaultGeneratorRunner.java:775)
        at org.openapijsonschematools.codegen.generatorrunner.DefaultGeneratorRunner.generate(DefaultGeneratorRunner.java:1456)
        at org.openapijsonschematools.codegen.clicommands.Generate.execute(Generate.java:441)
        at org.openapijsonschematools.codegen.clicommands.AbstractCommand.run(AbstractCommand.java:34)
        at org.openapijsonschematools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:76)
##### openapi-json-schema-generator version

3.2.0

OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions