-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[Rust] Apply the isAnyType param fallback to operations without path params #24570
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
Open
emilbonnek
wants to merge
1
commit into
OpenAPITools:master
Choose a base branch
from
emilbonnek:rust-anytype-query-params-without-path-params
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| generatorName: rust | ||
| outputDir: samples/client/others/rust/reqwest/nullable-enum-query-params | ||
| library: reqwest | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_1/rust/nullable-enum-query-params.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/rust | ||
| additionalProperties: | ||
| supportAsync: true | ||
| packageName: nullable-enum-query-params-reqwest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
modules/openapi-generator/src/test/resources/3_1/rust/nullable-enum-query-params.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| openapi: 3.1.0 | ||
| info: | ||
| title: Nullable Enum Query Parameter Test | ||
| description: >- | ||
| Test spec for enum query parameters whose schema is not a bare $ref, as | ||
| emitted by FastAPI and other 3.1 producers. The same operation is defined | ||
| with and without a path parameter, because the two used to be generated | ||
| differently. | ||
| version: 1.0.0 | ||
| paths: | ||
| /widgets/summary: | ||
| get: | ||
| operationId: getWidgetSummary | ||
| summary: Get a widget summary | ||
| parameters: | ||
| - name: kind | ||
| in: query | ||
| description: Kind filter, expressed as an anyOf with null | ||
| required: false | ||
| schema: | ||
| anyOf: | ||
| - $ref: '#/components/schemas/WidgetKind' | ||
| - type: 'null' | ||
| title: Kind | ||
| - name: sort | ||
| in: query | ||
| description: Sort order, expressed as a $ref with sibling keywords | ||
| required: false | ||
| schema: | ||
| $ref: '#/components/schemas/SortDirection' | ||
| title: Sort | ||
| responses: | ||
| '200': | ||
| description: Successful response | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/WidgetSummary' | ||
| /widgets/{widget_id}/summary: | ||
| get: | ||
| operationId: getWidgetSummaryById | ||
| summary: Get a widget summary for a single widget | ||
| parameters: | ||
| - name: widget_id | ||
| in: path | ||
| required: true | ||
| schema: | ||
| type: string | ||
| - name: kind | ||
| in: query | ||
| description: Kind filter, expressed as an anyOf with null | ||
| required: false | ||
| schema: | ||
| anyOf: | ||
| - $ref: '#/components/schemas/WidgetKind' | ||
| - type: 'null' | ||
| title: Kind | ||
| responses: | ||
| '200': | ||
| description: Successful response | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/WidgetSummary' | ||
| components: | ||
| schemas: | ||
| WidgetKind: | ||
| type: string | ||
| description: Widget kind | ||
| enum: | ||
| - basic | ||
| - premium | ||
| SortDirection: | ||
| type: string | ||
| description: Sort direction options | ||
| enum: | ||
| - asc | ||
| - desc | ||
| WidgetSummary: | ||
| type: object | ||
| properties: | ||
| kind: | ||
| $ref: '#/components/schemas/WidgetKind' | ||
| total: | ||
| type: integer | ||
| required: | ||
| - kind | ||
| - total |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
samples/client/others/rust/reqwest/nullable-enum-query-params/.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| /target/ | ||
| **/*.rs.bk | ||
| Cargo.lock |
23 changes: 23 additions & 0 deletions
23
samples/client/others/rust/reqwest/nullable-enum-query-params/.openapi-generator-ignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # OpenAPI Generator Ignore | ||
| # Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
|
||
| # Use this file to prevent files from being overwritten by the generator. | ||
| # The patterns follow closely to .gitignore or .dockerignore. | ||
|
|
||
| # As an example, the C# client generator defines ApiClient.cs. | ||
| # You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
| #ApiClient.cs | ||
|
|
||
| # You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
| #foo/*/qux | ||
| # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
|
||
| # You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
| #foo/**/qux | ||
| # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
|
||
| # You can also negate patterns with an exclamation (!). | ||
| # For example, you can ignore all files in a docs folder with the file extension .md: | ||
| #docs/*.md | ||
| # Then explicitly reverse the ignore rule for a single file: | ||
| #!docs/README.md |
18 changes: 18 additions & 0 deletions
18
samples/client/others/rust/reqwest/nullable-enum-query-params/.openapi-generator/FILES
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| .gitignore | ||
| .openapi-generator-ignore | ||
| .travis.yml | ||
| Cargo.toml | ||
| README.md | ||
| docs/DefaultApi.md | ||
| docs/SortDirection.md | ||
| docs/WidgetKind.md | ||
| docs/WidgetSummary.md | ||
| git_push.sh | ||
| src/apis/configuration.rs | ||
| src/apis/default_api.rs | ||
| src/apis/mod.rs | ||
| src/lib.rs | ||
| src/models/mod.rs | ||
| src/models/sort_direction.rs | ||
| src/models/widget_kind.rs | ||
| src/models/widget_summary.rs |
1 change: 1 addition & 0 deletions
1
samples/client/others/rust/reqwest/nullable-enum-query-params/.openapi-generator/VERSION
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 7.25.0-SNAPSHOT |
1 change: 1 addition & 0 deletions
1
samples/client/others/rust/reqwest/nullable-enum-query-params/.travis.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| language: rust |
20 changes: 20 additions & 0 deletions
20
samples/client/others/rust/reqwest/nullable-enum-query-params/Cargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| [package] | ||
| name = "nullable-enum-query-params-reqwest" | ||
| version = "1.0.0" | ||
| authors = ["OpenAPI Generator team and contributors"] | ||
| description = "Test spec for enum query parameters whose schema is not a bare $ref, as emitted by FastAPI and other 3.1 producers. The same operation is defined with and without a path parameter, because the two used to be generated differently." | ||
| # Override this license by providing a License Object in the OpenAPI. | ||
| license = "Unlicense" | ||
| edition = "2021" | ||
|
|
||
| [dependencies] | ||
| serde = { version = "^1.0", features = ["derive"] } | ||
| serde_json = "^1.0" | ||
| serde_repr = "^0.1" | ||
| url = "^2.5" | ||
| reqwest = { version = "^0.13", default-features = false, features = ["json", "multipart", "query", "form"] } | ||
|
|
||
| [features] | ||
| default = ["native-tls"] | ||
| native-tls = ["reqwest/native-tls"] | ||
| rustls = ["reqwest/rustls"] |
49 changes: 49 additions & 0 deletions
49
samples/client/others/rust/reqwest/nullable-enum-query-params/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Rust API client for nullable-enum-query-params-reqwest | ||
|
|
||
| Test spec for enum query parameters whose schema is not a bare $ref, as emitted by FastAPI and other 3.1 producers. The same operation is defined with and without a path parameter, because the two used to be generated differently. | ||
|
|
||
|
|
||
| ## Overview | ||
|
|
||
| This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. | ||
|
|
||
| - API version: 1.0.0 | ||
| - Package version: 1.0.0 | ||
| - Generator version: 7.25.0-SNAPSHOT | ||
| - Build package: `org.openapitools.codegen.languages.RustClientCodegen` | ||
|
|
||
| ## Installation | ||
|
|
||
| Put the package under your project folder in a directory named `nullable-enum-query-params-reqwest` and add the following to `Cargo.toml` under `[dependencies]`: | ||
|
|
||
| ``` | ||
| nullable-enum-query-params-reqwest = { path = "./nullable-enum-query-params-reqwest" } | ||
| ``` | ||
|
|
||
| ## Documentation for API Endpoints | ||
|
|
||
| All URIs are relative to *http://localhost* | ||
|
|
||
| Class | Method | HTTP request | Description | ||
| ------------ | ------------- | ------------- | ------------- | ||
| *DefaultApi* | [**get_widget_summary**](docs/DefaultApi.md#get_widget_summary) | **GET** /widgets/summary | Get a widget summary | ||
| *DefaultApi* | [**get_widget_summary_by_id**](docs/DefaultApi.md#get_widget_summary_by_id) | **GET** /widgets/{widget_id}/summary | Get a widget summary for a single widget | ||
|
|
||
|
|
||
| ## Documentation For Models | ||
|
|
||
| - [SortDirection](docs/SortDirection.md) | ||
| - [WidgetKind](docs/WidgetKind.md) | ||
| - [WidgetSummary](docs/WidgetSummary.md) | ||
|
|
||
|
|
||
| To get access to the crate's generated documentation, use: | ||
|
|
||
| ``` | ||
| cargo doc --open | ||
| ``` | ||
|
|
||
| ## Author | ||
|
|
||
|
|
||
|
|
68 changes: 68 additions & 0 deletions
68
samples/client/others/rust/reqwest/nullable-enum-query-params/docs/DefaultApi.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # \DefaultApi | ||
|
|
||
| All URIs are relative to *http://localhost* | ||
|
|
||
| Method | HTTP request | Description | ||
| ------------- | ------------- | ------------- | ||
| [**get_widget_summary**](DefaultApi.md#get_widget_summary) | **GET** /widgets/summary | Get a widget summary | ||
| [**get_widget_summary_by_id**](DefaultApi.md#get_widget_summary_by_id) | **GET** /widgets/{widget_id}/summary | Get a widget summary for a single widget | ||
|
|
||
|
|
||
|
|
||
| ## get_widget_summary | ||
|
|
||
| > models::WidgetSummary get_widget_summary(kind, sort) | ||
| Get a widget summary | ||
|
|
||
| ### Parameters | ||
|
|
||
|
|
||
| Name | Type | Description | Required | Notes | ||
| ------------- | ------------- | ------------- | ------------- | ------------- | ||
| **kind** | Option<**String**> | Kind filter, expressed as an anyOf with null | | | ||
| **sort** | Option<**String**> | Sort order, expressed as a $ref with sibling keywords | | | ||
|
|
||
| ### Return type | ||
|
|
||
| [**models::WidgetSummary**](WidgetSummary.md) | ||
|
|
||
| ### Authorization | ||
|
|
||
| No authorization required | ||
|
|
||
| ### HTTP request headers | ||
|
|
||
| - **Content-Type**: Not defined | ||
| - **Accept**: application/json | ||
|
|
||
| [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) | ||
|
|
||
|
|
||
| ## get_widget_summary_by_id | ||
|
|
||
| > models::WidgetSummary get_widget_summary_by_id(widget_id, kind) | ||
| Get a widget summary for a single widget | ||
|
|
||
| ### Parameters | ||
|
|
||
|
|
||
| Name | Type | Description | Required | Notes | ||
| ------------- | ------------- | ------------- | ------------- | ------------- | ||
| **widget_id** | **String** | | [required] | | ||
| **kind** | Option<**String**> | Kind filter, expressed as an anyOf with null | | | ||
|
|
||
| ### Return type | ||
|
|
||
| [**models::WidgetSummary**](WidgetSummary.md) | ||
|
|
||
| ### Authorization | ||
|
|
||
| No authorization required | ||
|
|
||
| ### HTTP request headers | ||
|
|
||
| - **Content-Type**: Not defined | ||
| - **Accept**: application/json | ||
|
|
||
| [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) | ||
|
|
13 changes: 13 additions & 0 deletions
13
...les/client/others/rust/reqwest/nullable-enum-query-params/docs/SortDirection.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # SortDirection | ||
|
|
||
| ## Enum Variants | ||
|
|
||
| | Name | Value | | ||
| |---- | -----| | ||
| | Asc | asc | | ||
| | Desc | desc | | ||
|
|
||
|
|
||
| [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
|
||
|
|
13 changes: 13 additions & 0 deletions
13
samples/client/others/rust/reqwest/nullable-enum-query-params/docs/WidgetKind.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # WidgetKind | ||
|
|
||
| ## Enum Variants | ||
|
|
||
| | Name | Value | | ||
| |---- | -----| | ||
| | Basic | basic | | ||
| | Premium | premium | | ||
|
|
||
|
|
||
| [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
|
||
|
|
12 changes: 12 additions & 0 deletions
12
...les/client/others/rust/reqwest/nullable-enum-query-params/docs/WidgetSummary.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # WidgetSummary | ||
|
|
||
| ## Properties | ||
|
|
||
| Name | Type | Description | Notes | ||
| ------------ | ------------- | ------------- | ------------- | ||
| **kind** | [**models::WidgetKind**](WidgetKind.md) | | | ||
| **total** | **i32** | | | ||
|
|
||
| [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
|
||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: JSON-content query parameters with an unconstrained schema now become
Option<&str>rather thanOption<serde_json::Value>when the operation has no path params. Preserveserde_json::ValueforqueryIsJsonMimeTypeparameters so callers can still supply and serialize arbitrary JSON values.Prompt for AI agents