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

[BUG][csharp][aspnetcore] Generator fails with exception when using 6.0.0 instead of 5.4.0 #12527

Closed
5 of 6 tasks
mparge opened this issue Jun 3, 2022 · 1 comment · Fixed by #12538
Closed
5 of 6 tasks

Comments

@mparge
Copy link

mparge commented Jun 3, 2022

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 (example)
Description

Generation code from a yaml spec (see example yaml) fails when using generator 6.0.0 instead of 5.4.0 with this output:

Exception: Cannot read field "dataType" because "p.items" is null
at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1167)
at org.openapitools.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:1058)
at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:553)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:895)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:449)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.NullPointerException: Cannot read field "dataType" because "p.items" is null
at org.openapitools.codegen.languages.AbstractCSharpCodegen.setParameterExampleValue(AbstractCSharpCodegen.java:1414)
at org.openapitools.codegen.DefaultCodegen.setParameterExampleValue(DefaultCodegen.java:1901)
at org.openapitools.codegen.DefaultCodegen.finishUpdatingParameter(DefaultCodegen.java:4528)
at org.openapitools.codegen.DefaultCodegen.fromParameter(DefaultCodegen.java:4847)
at org.openapitools.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:4162)
at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1135)

openapi-generator version

Works with 5.4.0
Fails with 6.0.0

OpenAPI declaration file content or url
openapi: "3.0.0"
info:
  version: 0.1.0
  title:  API
servers:
  - url: http://api/
paths:
  /FunctionControl/ChannelEnable:
    get:
      operationId: GetChannelEnable
      tags: 
        - configuration
      parameters:
        - name: data
          in: query
          required: true
          schema:
            $ref: "#/components/schemas/ChannelEnable"        
      responses:
        '200':
          description: description
          content:
            application/json:    
              schema:
                $ref: "#/components/schemas/ChannelEnable"
 
components:
  schemas:
    ChannelEnable:
      type: object
      properties:
        Index:
          type: integer
          format: int32
          minimum: 1
          maximum: 5
        Channel:
          type: integer
          format: int32
          minimum: 1
          maximum: 4
        Status:
          type: boolean
Generation Details
Steps to reproduce

Take the yaml spec and try to generate, 5.4.0 will succeed, 6.0.0 will fail with an exception

java -jar "..\generator\openapi-generator-cli-5.4.0.jar" generate -g aspnetcore -i ...\api\api.yml -o ..\api\generated\aspnetcore
java -jar "..\generator\openapi-generator-cli-6.0.0.jar" generate -g aspnetcore -i ...\api\api.yml -o ..\api\generated\aspnetcore

Related issues/PRs
Suggest a fix

#11355 might have introduces the bug,

@wing328
Copy link
Member

wing328 commented Jun 5, 2022

@mparge thanks for reporting the issue, which has been fixed by #12538

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants