Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into generator_problems_with_spring_…
Browse files Browse the repository at this point in the history
…reactive
  • Loading branch information
Kathrin Geilmann committed Feb 12, 2025
2 parents fd59e50 + dd67423 commit 058f526
Show file tree
Hide file tree
Showing 115 changed files with 818 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,18 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
List<CodegenOperation> operations = objectMap.getOperation();
for (CodegenOperation operation : operations) {
if (operation.pathParams != null && operation.pathParams.size() > 0) {

// For types with `isAnyType` we assume it's a `serde_json::Value` type.
// However for path, query, and headers it's unlikely to be JSON so we default to `String`.
// Note that we keep the default `serde_json::Value` for body parameters.
for (var param : operation.allParams) {
if (param.isAnyType && (param.isPathParam || param.isQueryParam || param.isHeaderParam)) {
param.dataType = "String";
param.isPrimitiveType = true;
param.isString = true;
}
}

for (var pathParam : operation.pathParams) {
if (!pathParam.baseName.contains("-")) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@

<build>
<sourceDirectory>src/main/java</sourceDirectory>
{{^interfaceOnly}}
<plugins>
{{^interfaceOnly}}
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand All @@ -76,6 +76,21 @@
{{/lombok}}
</configuration>
</plugin>
{{/interfaceOnly}}
{{#interfaceOnly}}
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
{{/interfaceOnly}}
{{#apiFirst}}
<plugin>
<groupId>org.openapitools</groupId>
Expand Down Expand Up @@ -109,7 +124,6 @@
</plugin>
{{/apiFirst}}
</plugins>
{{/interfaceOnly}}
</build>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
{{/parentOverridden}}
<build>
<sourceDirectory>src/main/java</sourceDirectory>
{{^interfaceOnly}}
<plugins>
{{^interfaceOnly}}
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
Expand All @@ -69,6 +69,21 @@
{{/lombok}}
</configuration>
</plugin>
{{/interfaceOnly}}
{{#interfaceOnly}}
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
{{/interfaceOnly}}
{{#apiFirst}}
<plugin>
<groupId>org.openapitools</groupId>
Expand Down Expand Up @@ -102,7 +117,6 @@
</plugin>
{{/apiFirst}}
</plugins>
{{/interfaceOnly}}
</build>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@

<build>
<sourceDirectory>src/main/java</sourceDirectory>
{{#interfaceOnly}}<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>{{/interfaceOnly}}
</build>

{{^parentOverridden}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@
{{/parentOverridden}}
<build>
<sourceDirectory>src/main/java</sourceDirectory>
{{#interfaceOnly}}<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>{{/interfaceOnly}}
</build>

{{^parentOverridden}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@
</execution>
</executions>
</plugin>{{/interfaceOnly}}
{{#interfaceOnly}}<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>{{/interfaceOnly}}
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@
</execution>
</executions>
</plugin>{{/interfaceOnly}}
{{#interfaceOnly}}<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>{{/interfaceOnly}}
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@
</execution>
</executions>
</plugin>{{/interfaceOnly}}
{{#interfaceOnly}}<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>{{/interfaceOnly}}
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@
</execution>
</executions>
</plugin>{{/interfaceOnly}}
{{#interfaceOnly}}<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>{{/interfaceOnly}}
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,11 @@ paths:
description: To test escaping of parameters in rust code works
schema:
type: string
# For testing `isAnyType` types
- name: anyType
in: query
required: true
schema: {}
responses:
'200':
description: successful operation
Expand Down Expand Up @@ -996,3 +1001,9 @@ components:
properties:
dummy:
type: string
AnyTypeTest:
type: object
properties:
foo: {}
required: ["foo"]

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Cargo.toml
README.md
docs/ActionContainer.md
docs/AnyTypeTest.md
docs/ApiResponse.md
docs/ArrayItemRefTest.md
docs/Baz.md
Expand Down Expand Up @@ -37,6 +38,7 @@ src/apis/testing_api.rs
src/apis/user_api.rs
src/lib.rs
src/models/action_container.rs
src/models/any_type_test.rs
src/models/api_response.rs
src/models/array_item_ref_test.rs
src/models/baz.rs
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/rust/hyper/petstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Class | Method | HTTP request | Description
## Documentation For Models

- [ActionContainer](docs/ActionContainer.md)
- [AnyTypeTest](docs/AnyTypeTest.md)
- [ApiResponse](docs/ApiResponse.md)
- [ArrayItemRefTest](docs/ArrayItemRefTest.md)
- [Baz](docs/Baz.md)
Expand Down
11 changes: 11 additions & 0 deletions samples/client/petstore/rust/hyper/petstore/docs/AnyTypeTest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# AnyTypeTest

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**foo** | Option<[**serde_json::Value**](.md)> | |

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


3 changes: 2 additions & 1 deletion samples/client/petstore/rust/hyper/petstore/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Method | HTTP request | Description

## test_nullable_required_param

> test_nullable_required_param(user_name, dummy_required_nullable_param, uppercase, content)
> test_nullable_required_param(user_name, dummy_required_nullable_param, any_type, uppercase, content)
To test nullable required parameters


Expand All @@ -22,6 +22,7 @@ Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**user_name** | **String** | The name that needs to be fetched. Use user1 for testing. | [required] |
**dummy_required_nullable_param** | Option<**String**> | To test nullable required parameters | [required] |
**any_type** | **String** | | [required] |
**uppercase** | Option<**String**> | To test parameter names in upper case | |
**content** | Option<**String**> | To test escaping of parameters in rust code works | |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,20 @@ impl<C: Connect> FakeApiClient<C>
}

pub trait FakeApi: Send + Sync {
fn test_nullable_required_param(&self, user_name: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>, content: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
fn test_nullable_required_param(&self, user_name: &str, dummy_required_nullable_param: Option<&str>, any_type: &str, uppercase: Option<&str>, content: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
}

impl<C: Connect>FakeApi for FakeApiClient<C>
where C: Clone + std::marker::Send + Sync {
#[allow(unused_mut)]
fn test_nullable_required_param(&self, user_name: &str, dummy_required_nullable_param: Option<&str>, uppercase: Option<&str>, content: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
fn test_nullable_required_param(&self, user_name: &str, dummy_required_nullable_param: Option<&str>, any_type: &str, uppercase: Option<&str>, content: Option<&str>) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
let mut req = __internal_request::Request::new(hyper::Method::GET, "/fake/user/{user_name}".to_string())
;
if let Some(ref s) = content {
let query_value = s.to_string();
req = req.with_query_param("content".to_string(), query_value);
}
req = req.with_query_param("anyType".to_string(), any_type.to_string());
req = req.with_path_param("user_name".to_string(), user_name.to_string());
match dummy_required_nullable_param {
Some(param_value) => { req = req.with_header_param("dummy_required_nullable_param".to_string(), param_value.to_string()); },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-generator.tech
*/

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct AnyTypeTest {
#[serde(rename = "foo", deserialize_with = "Option::deserialize")]
pub foo: Option<serde_json::Value>,
}

impl AnyTypeTest {
pub fn new(foo: Option<serde_json::Value>) -> AnyTypeTest {
AnyTypeTest {
foo,
}
}
}

2 changes: 2 additions & 0 deletions samples/client/petstore/rust/hyper/petstore/src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
pub mod action_container;
pub use self::action_container::ActionContainer;
pub mod any_type_test;
pub use self::any_type_test::AnyTypeTest;
pub mod api_response;
pub use self::api_response::ApiResponse;
pub mod array_item_ref_test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod tests {
let handle = thread::spawn(move || {
let _ = client
.fake_api()
.test_nullable_required_param("username", None, None, None);
.test_nullable_required_param("username", None, "any_type", None, None);
});

handle.join().expect("Thread panicked!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Cargo.toml
README.md
docs/ActionContainer.md
docs/AnyTypeTest.md
docs/ApiResponse.md
docs/ArrayItemRefTest.md
docs/Baz.md
Expand Down Expand Up @@ -35,6 +36,7 @@ src/apis/testing_api.rs
src/apis/user_api.rs
src/lib.rs
src/models/action_container.rs
src/models/any_type_test.rs
src/models/api_response.rs
src/models/array_item_ref_test.rs
src/models/baz.rs
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/rust/hyper0x/petstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Class | Method | HTTP request | Description
## Documentation For Models

- [ActionContainer](docs/ActionContainer.md)
- [AnyTypeTest](docs/AnyTypeTest.md)
- [ApiResponse](docs/ApiResponse.md)
- [ArrayItemRefTest](docs/ArrayItemRefTest.md)
- [Baz](docs/Baz.md)
Expand Down
11 changes: 11 additions & 0 deletions samples/client/petstore/rust/hyper0x/petstore/docs/AnyTypeTest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# AnyTypeTest

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**foo** | Option<[**serde_json::Value**](.md)> | |

[[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

0 comments on commit 058f526

Please sign in to comment.