Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

NullPointerException Thrown when Both properties and allOf are Defined in a schema Object #12402

Open
ChihweiLHBird opened this issue May 17, 2024 · 0 comments

Comments

@ChihweiLHBird
Copy link

ChihweiLHBird commented May 17, 2024

Description

Not sure if it's my spec's issue but a null pointer exception was thrown.

Swagger-codegen version

Latest code in 3.0.0 branch

Swagger declaration file content or url
openapi: 3.0.1
info:
  version: 4.176.0
  title: Linode API
servers:
- url: https://api.linode.com/v4
paths:
  /networking/firewalls/{firewallId}/rules:
    parameters:
      - name: firewallId
        in: path
        required: true
        schema:
          type: integer
    put:
      tags:
      - Networking
      summary: Firewall Rules Update
      operationId: updateFirewallRules
      requestBody:
        content:
          application/json:
            schema:
              allOf:
              - $ref: '#/components/schemas/Firewall/properties/rules'
              type: object
              properties:
                inbound:
                  type: array
                  items:
                    $ref: '#/components/schemas/FirewallRuleConfig'
                outbound:
                  type: array
                  items:
                    $ref: '#/components/schemas/FirewallRuleConfig'
      responses:
        '200':
          description: Firewall Rules updated successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Firewall/properties/rules'
components:
  schemas:
    Firewall:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        rules:
          type: object
          properties:
            inbound:
              type: array
              items:
                $ref: '#/components/schemas/FirewallRuleConfig'
            outbound:
              type: array
              items:
                $ref: '#/components/schemas/FirewallRuleConfig'
    FirewallRuleConfig:
      type: object
      properties:
        protocol:
          type: string
Command line used for generation
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i ./openapi.yaml -l go -o ./swagger-client-go
Exception in thread "Thread-0" java.lang.RuntimeException: Could not process operation:
  Tag: class Tag {
    name: Networking
    description: null
    externalDocs: null
}
  Operation: updateFirewallRules
  Resource: put /networking/firewalls/{firewallId}/rules
  Exception: Cannot invoke "io.swagger.v3.oas.models.media.Schema.getProperties()" because "fileTypeSchema" is null
        at io.swagger.codegen.v3.DefaultGenerator.processOperation(DefaultGenerator.java:989)
        at io.swagger.codegen.v3.DefaultGenerator.processPaths(DefaultGenerator.java:891)
        at io.swagger.codegen.v3.DefaultGenerator.generateApis(DefaultGenerator.java:484)
        at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:796)
        at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:388)
        at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.NullPointerException: Cannot invoke "io.swagger.v3.oas.models.media.Schema.getProperties()" because "fileTypeSchema" is null
        at io.swagger.codegen.v3.generators.DefaultCodegenConfig.isFileTypeSchema(DefaultCodegenConfig.java:4443)
        at io.swagger.codegen.v3.generators.DefaultCodegenConfig.fromResponse(DefaultCodegenConfig.java:2349)
        at io.swagger.codegen.v3.generators.DefaultCodegenConfig.fromOperation(DefaultCodegenConfig.java:2042)
        at io.swagger.codegen.v3.generators.go.GoClientCodegen.fromOperation(GoClientCodegen.java:118)
        at io.swagger.codegen.v3.DefaultGenerator.processOperation(DefaultGenerator.java:965)
        ... 5 more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant