Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bin/configs/rust-reqwest-enum-query-params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
generatorName: rust
outputDir: samples/client/others/rust/reqwest/enum-query-params
library: reqwest
inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/enum-query-params.yaml
templateDir: modules/openapi-generator/src/main/resources/rust
additionalProperties:
supportAsync: true
packageName: enum-query-params-reqwest
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,18 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{/isDeepObject}}
{{^isObject}}
{{^isModel}}
{{^isEnum}}
{{#isPrimitiveType}}
if let Some(ref param_value) = {{{vendorExtensions.x-rust-param-identifier}}} {
req_builder = req_builder.query(&[("{{{baseName}}}", &param_value.to_string())]);
};
{{/isPrimitiveType}}
{{^isPrimitiveType}}
if let Some(ref param_value) = {{{vendorExtensions.x-rust-param-identifier}}} {
req_builder = req_builder.query(&[("{{{baseName}}}", &serde_json::to_string(param_value)?)]);
};
{{/isPrimitiveType}}
{{/isEnum}}
{{/isModel}}
{{/isObject}}
{{/isNullable}}
Expand Down Expand Up @@ -245,9 +254,19 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{#isModel}}
req_builder = req_builder.query(&[("{{{baseName}}}", &serde_json::to_string(param_value)?)]);
{{/isModel}}
{{#isEnum}}
req_builder = req_builder.query(&[("{{{baseName}}}", &serde_json::to_string(param_value)?)]);
{{/isEnum}}
{{^isObject}}
{{^isModel}}
{{^isEnum}}
{{#isPrimitiveType}}
req_builder = req_builder.query(&[("{{{baseName}}}", &param_value.to_string())]);
{{/isPrimitiveType}}
{{^isPrimitiveType}}
req_builder = req_builder.query(&[("{{{baseName}}}", &serde_json::to_string(param_value)?)]);
{{/isPrimitiveType}}
{{/isEnum}}
{{/isModel}}
{{/isObject}}
{{/isDeepObject}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
openapi: 3.0.3
info:
title: Enum Query Parameter Test
description: Test spec for enum and non-primitive query parameters
version: 1.0.0
paths:
/aggregate:
get:
operationId: getAggregateData
summary: Get aggregated data
description: Test endpoint with enum query parameters referenced via $ref
parameters:
- name: timeBucket
in: query
description: Time aggregation bucket
required: false
schema:
$ref: '#/components/schemas/TimeBucket'
- name: sortDirection
in: query
description: Sort direction
required: false
schema:
$ref: '#/components/schemas/SortDirection'
- name: status
in: query
description: Status filter
required: true
schema:
$ref: '#/components/schemas/Status'
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/AggregateResponse'
'400':
description: Bad request
/items:
get:
operationId: getItems
summary: Get items with filters
parameters:
- name: category
in: query
description: Item category (inline enum)
required: false
schema:
type: string
enum:
- electronics
- clothing
- food
- name: priority
in: query
description: Priority level (enum via ref)
required: false
schema:
$ref: '#/components/schemas/Priority'
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Item'
components:
schemas:
TimeBucket:
type: string
description: Time aggregation bucket options
enum:
- hour
- day
- week
- month
- year
SortDirection:
type: string
description: Sort direction options
enum:
- asc
- desc
default: asc
Status:
type: string
description: Status filter options
enum:
- active
- inactive
- pending
- completed
Priority:
type: string
description: Priority level
enum:
- low
- medium
- high
- critical
AggregateResponse:
type: object
properties:
count:
type: integer
format: int64
data:
type: array
items:
type: object
additionalProperties: true
Item:
type: object
properties:
id:
type: string
name:
type: string
category:
type: string
11 changes: 11 additions & 0 deletions samples/client/others/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target/
**/*.rs.bk
Cargo.lock
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.gitignore
.travis.yml
Cargo.toml
README.md
docs/AggregateResponse.md
docs/DefaultApi.md
docs/Item.md
docs/Priority.md
docs/SortDirection.md
docs/Status.md
docs/TimeBucket.md
git_push.sh
src/apis/configuration.rs
src/apis/default_api.rs
src/apis/mod.rs
src/lib.rs
src/models/aggregate_response.rs
src/models/item.rs
src/models/mod.rs
src/models/priority.rs
src/models/sort_direction.rs
src/models/status.rs
src/models/time_bucket.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.18.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: rust
20 changes: 20 additions & 0 deletions samples/client/others/rust/reqwest/enum-query-params/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "enum-query-params-reqwest"
version = "1.0.0"
authors = ["OpenAPI Generator team and contributors"]
description = "Test spec for enum and non-primitive query parameters"
# 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.12", default-features = false, features = ["json", "multipart"] }

[features]
default = ["native-tls"]
native-tls = ["reqwest/native-tls"]
rustls-tls = ["reqwest/rustls-tls"]
52 changes: 52 additions & 0 deletions samples/client/others/rust/reqwest/enum-query-params/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Rust API client for enum-query-params-reqwest

Test spec for enum and non-primitive query parameters


## 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.18.0-SNAPSHOT
- Build package: `org.openapitools.codegen.languages.RustClientCodegen`

## Installation

Put the package under your project folder in a directory named `enum-query-params-reqwest` and add the following to `Cargo.toml` under `[dependencies]`:

```
enum-query-params-reqwest = { path = "./enum-query-params-reqwest" }
```

## Documentation for API Endpoints

All URIs are relative to *http://localhost*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**get_aggregate_data**](docs/DefaultApi.md#get_aggregate_data) | **GET** /aggregate | Get aggregated data
*DefaultApi* | [**get_items**](docs/DefaultApi.md#get_items) | **GET** /items | Get items with filters


## Documentation For Models

- [AggregateResponse](docs/AggregateResponse.md)
- [Item](docs/Item.md)
- [Priority](docs/Priority.md)
- [SortDirection](docs/SortDirection.md)
- [Status](docs/Status.md)
- [TimeBucket](docs/TimeBucket.md)


To get access to the crate's generated documentation, use:

```
cargo doc --open
```

## Author



Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# AggregateResponse

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**count** | Option<**i64**> | | [optional]
**data** | Option<[**Vec<std::collections::HashMap<String, serde_json::Value>>**](std::collections::HashMap.md)> | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


Loading
Loading