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] R generator throws: Cannot read field "isArray" because "codegenProperty" is null #15915

Closed
4 of 6 tasks
tschaffter opened this issue Jun 23, 2023 · 5 comments · Fixed by #15953
Closed
4 of 6 tasks

Comments

@tschaffter
Copy link

tschaffter commented Jun 23, 2023

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?
    • The main branch does not compile successfully (package lombok does not exist)
  • 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

I want to generate an API client for R from this OpenAPI description, but the generation fails with the following error:

$ openapi-generator-cli generate

...
[[api-client-r] #{cwd}/../api-description/build/openapi.yaml] Exception in thread "main" java.lang.RuntimeException: Could not generate api file for 'Challenge'
[[api-client-r] #{cwd}/../api-description/build/openapi.yaml]   at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:717)
[[api-client-r] #{cwd}/../api-description/build/openapi.yaml]   at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:949)
[[api-client-r] #{cwd}/../api-description/build/openapi.yaml]   at org.openapitools.codegen.cmd.Generate.execute(Generate.java:487)
[[api-client-r] #{cwd}/../api-description/build/openapi.yaml]   at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
[[api-client-r] #{cwd}/../api-description/build/openapi.yaml]   at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
[[api-client-r] #{cwd}/../api-description/build/openapi.yaml] Caused by: java.lang.NullPointerException: Cannot read field "isArray" because "codegenProperty" is null
[[api-client-r] #{cwd}/../api-description/build/openapi.yaml]   at org.openapitools.codegen.languages.RClientCodegen.constructExampleCode(RClientCodegen.java:950)
[[api-client-r] #{cwd}/../api-description/build/openapi.yaml]   at org.openapitools.codegen.languages.RClientCodegen.constructExampleCode(RClientCodegen.java:932)
[[api-client-r] #{cwd}/../api-description/build/openapi.yaml]   at org.openapitools.codegen.languages.RClientCodegen.postProcessOperationsWithModels(RClientCodegen.java:903)
[[api-client-r] #{cwd}/../api-description/build/openapi.yaml]   at org.openapitools.codegen.DefaultGenerator.processOperations(DefaultGenerator.java:1271)
[[api-client-r] #{cwd}/../api-description/build/openapi.yaml]   at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:605)
[[api-client-r] #{cwd}/../api-description/build/openapi.yaml]   ... 4 more
[[api-client-r] #{cwd}/../api-description/build/openapi.yaml] java -jar "/workspaces/sage-monorepo/node_modules/@openapitools/openapi-generator-cli/versions/6.6.0.jar" generate --input-spec="/workspaces/sage-monorepo/libs/openchallenges/api-client-r/../api-description/build/openapi.yaml" --generator-name="r" --output="/workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/" exited with code 1
[api-client-r] #{cwd}/../api-description/build/openapi.yaml
  java -jar "/workspaces/sage-monorepo/node_modules/@openapitools/openapi-generator-cli/versions/6.6.0.jar" generate --input-spec="/workspaces/sage-monorepo/libs/openchallenges/api-client-r/../api-description/build/openapi.yaml" --generator-name="r" --output="/workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/"

The generator configuration is available here.

openapi-generator version

6.6.0

OpenAPI declaration file content or url

openapi.yaml

Generation Details

See above for the command used, the generator config file and openapi file.

Steps to reproduce
  1. Install the openapi-generator-cli (see the README of this repo)
  2. Create the folder api-client-r
  3. Add the following files to this folder
  4. From inside the folder api-client-r, generate the API client for R with openapi-generator-cli generate
Related issues/PRs
Suggest a fix
@tschaffter
Copy link
Author

The OA Generator (v6.6.0) for R works when fed with the Pet Store API description.

I can reproduce the error reported by doing the following modification to the Pet Store API description, where the commented code is replaced by $ref: '#/components/schemas/Customer':

...
  /pet/findByStatus:
    get:
      tags:
        - pet
      summary: Finds Pets by status
      description: Multiple status values can be provided with comma separated strings
      operationId: findPetsByStatus
      parameters:
        - name: status
          in: query
          description: Status values that need to be considered for filter
          required: false
          explode: true
          schema:
            $ref: '#/components/schemas/Customer'
            # type: string
            # enum:
            #   - available
            #   - pending
            #   - sold
            # default: available
      responses:
...

Error:

> nx run openchallenges-api-client-r:openapi-generate

[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.DefaultGenerator - Generating with dryRun=false
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.DefaultGenerator - OpenAPI Generator: r (client)
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.DefaultGenerator - Generator 'r' is considered stable.
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/v3]
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.languages.RClientCodegen - ApiResponse (reserved word) cannot be used as model name. Renamed to ModelApiResponse
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/address.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_address.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/Address.md
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/category.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_category.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/Category.md
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/customer.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_customer.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/Customer.md
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/model_api_response.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_model_api_response.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/ModelApiResponse.md
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/order.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_order.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/Order.md
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/pet.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_pet.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/Pet.md
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/tag.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_tag.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/Tag.md
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/user.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_user.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/User.md
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.DefaultCodegen - Multiple MediaTypes found, using only the first one
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[[api-client-r] #{cwd}/petstore.yaml] Exception in thread "main" java.lang.RuntimeException: Could not generate api file for 'Pet'
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:717)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:949)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.cmd.Generate.execute(Generate.java:487)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
[[api-client-r] #{cwd}/petstore.yaml] Caused by: java.lang.NullPointerException: Cannot read field "isArray" because "codegenProperty" is null
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.languages.RClientCodegen.constructExampleCode(RClientCodegen.java:950)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.languages.RClientCodegen.constructExampleCode(RClientCodegen.java:932)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.languages.RClientCodegen.postProcessOperationsWithModels(RClientCodegen.java:903)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.DefaultGenerator.processOperations(DefaultGenerator.java:1271)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:605)
[[api-client-r] #{cwd}/petstore.yaml]   ... 4 more
[[api-client-r] #{cwd}/petstore.yaml] java -jar "/workspaces/sage-monorepo/node_modules/@openapitools/openapi-generator-cli/versions/6.6.0.jar" generate --input-spec="/workspaces/sage-monorepo/libs/openchallenges/api-client-r/petstore.yaml" --generator-name="r" --output="/workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/" --additional-properties="disallowAdditionalPropertiesIfNotPresent=false,library=httr" exited with code 1
[api-client-r] #{cwd}/petstore.yaml
  java -jar "/workspaces/sage-monorepo/node_modules/@openapitools/openapi-generator-cli/versions/6.6.0.jar" generate --input-spec="/workspaces/sage-monorepo/libs/openchallenges/api-client-r/petstore.yaml" --generator-name="r" --output="/workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/" --additional-properties="disallowAdditionalPropertiesIfNotPresent=false,library=httr"

Code generation failed

@tschaffter
Copy link
Author

tschaffter commented Jun 26, 2023

Follow on the above example, turning the Customer component into type: string no longer throws an error:

    Customer:
      # properties:
      #   id:
      #     type: integer
      #     format: int64
      #     example: 100000
      #   username:
      #     type: string
      #     example: fehguy
      #   address:
      #     type: array
      #     items:
      #       $ref: '#/components/schemas/Address'
      #     xml:
      #       wrapped: true
      #       name: addresses
      # xml:
      #   name: customer
      type: string

OA Generator output:

> nx run openchallenges-api-client-r:openapi-generate

[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.DefaultGenerator - Generating with dryRun=false
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.DefaultGenerator - OpenAPI Generator: r (client)
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.DefaultGenerator - Generator 'r' is considered stable.
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/v3]
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.languages.RClientCodegen - ApiResponse (reserved word) cannot be used as model name. Renamed to ModelApiResponse
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.DefaultGenerator - Model Customer not generated since it's a free-form object
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/address.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_address.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/Address.md
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/category.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_category.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/Category.md
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/model_api_response.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_model_api_response.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/ModelApiResponse.md
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/order.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_order.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/Order.md
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/pet.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_pet.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/Pet.md
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/tag.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_tag.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/Tag.md
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/R/user.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/tests/testthat/test_user.R
[[api-client-r] #{cwd}/petstore.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/docs/User.md
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.DefaultCodegen - Multiple MediaTypes found, using only the first one
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/xml)
[[api-client-r] #{cwd}/petstore.yaml] [main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[[api-client-r] #{cwd}/petstore.yaml] Exception in thread "main" java.lang.RuntimeException: Could not generate api file for 'Pet'
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:717)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:949)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.cmd.Generate.execute(Generate.java:487)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
[[api-client-r] #{cwd}/petstore.yaml] Caused by: java.lang.NullPointerException: Cannot read field "isArray" because "codegenProperty" is null
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.languages.RClientCodegen.constructExampleCode(RClientCodegen.java:950)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.languages.RClientCodegen.constructExampleCode(RClientCodegen.java:932)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.languages.RClientCodegen.postProcessOperationsWithModels(RClientCodegen.java:903)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.DefaultGenerator.processOperations(DefaultGenerator.java:1271)
[[api-client-r] #{cwd}/petstore.yaml]   at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:605)
[[api-client-r] #{cwd}/petstore.yaml]   ... 4 more
[[api-client-r] #{cwd}/petstore.yaml] java -jar "/workspaces/sage-monorepo/node_modules/@openapitools/openapi-generator-cli/versions/6.6.0.jar" generate --input-spec="/workspaces/sage-monorepo/libs/openchallenges/api-client-r/petstore.yaml" --generator-name="r" --output="/workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/" --additional-properties="disallowAdditionalPropertiesIfNotPresent=false,library=httr" exited with code 1
[api-client-r] #{cwd}/petstore.yaml
  java -jar "/workspaces/sage-monorepo/node_modules/@openapitools/openapi-generator-cli/versions/6.6.0.jar" generate --input-spec="/workspaces/sage-monorepo/libs/openchallenges/api-client-r/petstore.yaml" --generator-name="r" --output="/workspaces/sage-monorepo/libs/openchallenges/api-client-r/src/lib/" --additional-properties="disallowAdditionalPropertiesIfNotPresent=false,library=httr"

Code generation failed

The error is triggerd by the type associated to Customer. Setting it to type: object triggers the error; setting it to type: string or type: integer does not generate any error.

@tschaffter
Copy link
Author

tschaffter commented Jun 26, 2023

The OA Spec 3.0 says:

Query parameters can be primitive values, arrays and objects.

The Pet Store example does not include an example of query parameter that has type: object.

@wing328 I'm wondering whether what I'm experiencing is a bug or an unsupported feature even after looking at the page Documentation for the r Generator. There is a config option "errorObjectType" that may be related but its description is unclear.

@wing328
Copy link
Member

wing328 commented Jun 30, 2023

fixed via #15953

please give it a try with the latest master (URL to snapshot version is in the readme)

@tschaffter
Copy link
Author

@wing328 My setup consists in the config file openapitools.json and openapi-generator-cli generate.

{
  "$schema": "../../../node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "6.6.0",
    "generators": {
      "api-client-r": {
        "generatorName": "r",
        "inputSpec": "#{cwd}/../api-description/build/openapi.yaml",
        "output": "#{cwd}/src/lib/",
        "additionalProperties": {
          "disallowAdditionalPropertiesIfNotPresent": false,
          "library": "httr"
        }
      }
    }
  }
}

What I tried to use the snapshot version:

  • In the config file, set the version to 7.0.0-SNAPSHOT or 7.0.0-20230630.114249-154 (taken from here). Based on the logs generated by OA Generator, my understanding is that these are not valid values because they don't exist on Mave (here).
  • I tried this command from the README, but the version specified in the config file (6.6.0) is still used: OPENAPI_GENERATOR_VERSION=7.0.0-SNAPSHOT openapi-generator-cli generate

What is the recommended way to try the snapshot version in this context?

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