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

[Rust][reqwest] Fixed parameters of Array type #7049

Merged
merged 6 commits into from
Sep 9, 2020
Merged

[Rust][reqwest] Fixed parameters of Array type #7049

merged 6 commits into from
Sep 9, 2020

Conversation

JRAndreassen
Copy link
Contributor

@frol / @farcaller / @richardwhiuk / @paladinzh

Fixed parameters of Array type in "rust/reqwest/api.mustache"

the following definition:

        - description: Secret Mode. Mandatory for 'Node-Locked' licensing model.
          in: formData
          items:
            default: PREDEFINED
            enum:
              - PREDEFINED
              - CLIENT
            type: string
          name: nodeSecretMode
          required: false
          type: array

Fix for api_mustache ignoring Array's in parameters...
error[E0599]: no method named join found for reference &str in the current scope
--> src\apis\product_module_api.rs:110:62
|
110 | form_params.insert("nodeSecretMode", param_value.join(",").to_string());
| ^^^^ method not found in &str
Not using #isListContainer in parameters

Fixed for both standard and "vendorExtensions.x-group-parameters=true"
and compiles under both

Not using #isListContainer in parameters
@wing328
Copy link
Member

wing328 commented Jul 26, 2020

@JRAndreassen thanks for the PR. Please run the following to update the samples so that the CI can verify the result:

./bin/generate-samples.sh ./bin/configs/rust-reqwest-petstore*

(On Windows, please install Git bash to run the above)

supportAsync set to "false" should be false
Only check for special case...  "dataType" case includes Vec
@JRAndreassen
Copy link
Contributor Author

JRAndreassen commented Jul 26, 2020

I've fixed the errors I can, and ran the script.
I saw a couple of other places where there are [supportAsync: "false"], but did not change them...

There are errors in the build that I'm not sure how to fix...

# START SCRIPT: /home/circleci/OpenAPITools/openapi-generator/bin/utils/export_generators_readme.sh
Wrote /home/circleci/OpenAPITools/openapi-generator/docs/generators.md
Executed /home/circleci/OpenAPITools/openapi-generator/bin/utils/export_generators_readme.sh successfully!
UNCOMMITTED CHANGES ERROR

I tried to run the "ensure-up-to-date", but it fails locally

$ bin/utils/ensure-up-to-date
# START SCRIPT: bin/utils/ensure-up-to-date
...
[pool-1-thread-16] Generating elm (outputs to C:\Development\Tools\openapi-generator\samples\openapi3\client\elm)?
[pool-1-thread-30] Generation failed: (RuntimeException) Could not process model 'mammal'.Please make sure that your schema is correct!
java.lang.RuntimeException: Could not process model 'mammal'.Please make sure that your schema is correct!
        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:472)
        at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:923)
        at org.openapitools.codegen.cmd.GenerateBatch$GenerationRunner.run(GenerateBatch.java:215)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
        at org.openapitools.codegen.DefaultCodegen.addProperties(DefaultCodegen.java:2174)
        at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:1999)
        at org.openapitools.codegen.languages.AbstractJavaCodegen.fromModel(AbstractJavaCodegen.java:978)
        at org.openapitools.codegen.languages.JavaClientCodegen.fromModel(JavaClientCodegen.java:680)
        at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1166)
        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:467)
        ... 5 more
ERROR: One or more generators failed to generate. Halting ensure-up-to-date scripts.

Thoughts ?

JR

@JRAndreassen
Copy link
Contributor Author

@frol / @farcaller / @richardwhiuk / @paladinzh
While I'm waiting for the CI...

I have a couple of things I'd like to change / add to the rust/reqwest client...

  1. Split the API methods into:
    • {{{operationId}}}_setparameters(builder, ...)
      -- Set all parameters
    • {{{operationId}}}(config, ...)
      -create builder
      • call setparams
      • execute
  2. "vendorExtensions.x-group-parameters"
    • add interface to make it more "map" like..
      • Add ability to set by name: params.Set(name, value)
  3. Add "vendorExtensions.x-derive-?" for struct/enum for adding derived methods
  4. Add "vendorExtensions.x-api_trait" that generates Trait for API methods
  5. Generate #[tests] based on examples in spec file

@wing328
Copy link
Member

wing328 commented Jul 26, 2020

For the errors, I'll take a look in the coming week.

For the suggestions, please open an issue to start the discussion and for tracking purpose.

@wing328
Copy link
Member

wing328 commented Jul 31, 2020

All CI tests passed.

Are the following files added manually?

  • samples/client/petstore/rust/reqwest/petstore-async/src/apis/client.rs
  • samples/client/petstore/rust/reqwest/petstore/src/apis/client.rs

If yes, what's the purpose of these files?

@JRAndreassen
Copy link
Contributor Author

Hi...
I did not add those...
They must be generated or left-overs from a previous generation..
Sorry
JR

@wing328
Copy link
Member

wing328 commented Jul 31, 2020

@JRAndreassen No need to sorry. Let me investigate.

@wing328
Copy link
Member

wing328 commented Sep 9, 2020

Tested manually and no compilation issue found: https://travis-ci.org/github/OpenAPITools/openapi-generator/builds/724698912

@wing328 wing328 merged commit 37de486 into OpenAPITools:master Sep 9, 2020
@wing328 wing328 added this to the 5.0.0 milestone Sep 9, 2020
@wing328 wing328 changed the title Rust reqwest/api_mustache Missing api Vec in parameter [Rust][reqwest] Fixed parameters of Array type Sep 9, 2020
jimschubert added a commit to lwlee2608/openapi-generator that referenced this pull request Sep 12, 2020
* master: (1557 commits)
  [docs] Add notes on Windows classpath modification (OpenAPITools#7404)
  [C#][netcore] better support for additional properties in the payload (OpenAPITools#7396)
  Fix the ECDSA signature issue for PowerShellSDK (OpenAPITools#7386)
  Fix the new package that deal with Configuration (the old one is depecrated) (OpenAPITools#7391)
  update vonage logo (OpenAPITools#7387)
  [gradle][plugin] Fix tests (OpenAPITools#7384)
  [typescript] Fix incorrect enum literal case (OpenAPITools#7378)
  Rust reqwest/api_mustache Missing api Vec in parameter (OpenAPITools#7049)
  [kotlin] Fix imports of generated class (OpenAPITools#7314)
  Properly decode $ref (OpenAPITools#7191)
  fix typo, update caption
  feat(r): retry configuration for status codes (OpenAPITools#5925)
  [json][codegen] Add option: outputFileName (OpenAPITools#7348)
  RSACng class is not supported on linux replacing it by RSA (OpenAPITools#7349)
  Adds cookie auth support to ApiKeyAuth in dart2 templates (OpenAPITools#7346)
  [js][flowtype] Bump lodash from 4.17.15 to 4.17.19 (OpenAPITools#7359)
  Bugfix swift5 code generation 2966 (OpenAPITools#7301)
  Syncs validation properties for arraymodels (OpenAPITools#7357)
  Subclass Python exceptions (OpenAPITools#7321)
  Adds fix for issue7262 and a test of it (OpenAPITools#7328)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants