Better Rust client imports (#3332)

* Better Rust client imports.

* No more "unused_imports" in models for serde_json::Value.
* No more compilation problem for apis requiring serde_json::Value.
* "crate::" prefix for models and apis imports, for compatibility with Rust 2018 edition.

* Rust samples regeneration using new code.
This commit is contained in:
Benoît Courtine 2019-07-18 11:08:48 +02:00 committed by Benjamin Gill
parent 0fec25e92e
commit 26b8d1f4c2
36 changed files with 126 additions and 165 deletions

View File

@ -124,9 +124,9 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
// I tried to map as "std::io::File", but Reqwest multipart file requires a "AsRef<Path>" param.
// Getting a file from a Path is simple, but the opposite is difficult. So I map as "std::path::Path".
typeMapping.put("file", "std::path::PathBuf");
typeMapping.put("binary", "::models::File");
typeMapping.put("binary", "crate::models::File");
typeMapping.put("ByteArray", "String");
typeMapping.put("object", "Value");
typeMapping.put("object", "serde_json::Value");
// no need for rust
//importMapping = new HashMap<String, String>();
@ -352,8 +352,8 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
}
// return fully-qualified model name
// ::models::{{classnameFile}}::{{classname}}
return "::models::" + toModelName(schemaType);
// crate::models::{{classnameFile}}::{{classname}}
return "crate::models::" + toModelName(schemaType);
}
@Override

View File

@ -24,7 +24,7 @@ impl<C: hyper::client::Connect> {{{classname}}}Client<C> {
pub trait {{{classname}}} {
{{#operations}}
{{#operation}}
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box<Future<Item = {{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error = Error<serde_json::Value>>>;
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box<Future<Item = {{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error = Error<serde_json::Value>>>;
{{/operation}}
{{/operations}}
}
@ -33,7 +33,7 @@ pub trait {{{classname}}} {
impl<C: hyper::client::Connect>{{{classname}}} for {{{classname}}}Client<C> {
{{#operations}}
{{#operation}}
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box<Future<Item = {{^returnType}}(){{/returnType}}{{#returnType}}{{{.}}}{{/returnType}}, Error = Error<serde_json::Value>>> {
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Box<Future<Item = {{^returnType}}(){{/returnType}}{{#returnType}}{{{.}}}{{/returnType}}, Error = Error<serde_json::Value>>> {
__internal_request::Request::new(hyper::Method::{{{httpMethod}}}, "{{{path}}}".to_string())
{{#hasAuthMethods}}
{{#authMethods}}

View File

@ -10,7 +10,7 @@ pub struct APIClient<C: hyper::client::Connect> {
{{#operations}}
{{#operation}}
{{#-last}}
{{{classFilename}}}: Box<::apis::{{{classname}}}>,
{{{classFilename}}}: Box<crate::apis::{{{classname}}}>,
{{/-last}}
{{/operation}}
{{/operations}}
@ -29,7 +29,7 @@ impl<C: hyper::client::Connect> APIClient<C> {
{{#operations}}
{{#operation}}
{{#-last}}
{{{classFilename}}}: Box::new(::apis::{{{classname}}}Client::new(rc.clone())),
{{{classFilename}}}: Box::new(crate::apis::{{{classname}}}Client::new(rc.clone())),
{{/-last}}
{{/operation}}
{{/operations}}
@ -43,7 +43,7 @@ impl<C: hyper::client::Connect> APIClient<C> {
{{#operations}}
{{#operation}}
{{#-last}}
pub fn {{{classFilename}}}(&self) -> &::apis::{{{classname}}}{
pub fn {{{classFilename}}}(&self) -> &crate::apis::{{{classname}}}{
self.{{{classFilename}}}.as_ref()
}

View File

@ -5,9 +5,6 @@
/// {{{classname}}} : {{{description}}}
{{/description}}
#[allow(unused_imports)]
use serde_json::Value;
{{!-- for enum schemas --}}
{{#isEnum}}
/// {{{description}}}

View File

@ -21,7 +21,7 @@ impl {{{classname}}}Client {
pub trait {{{classname}}} {
{{#operations}}
{{#operation}}
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>;
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>;
{{/operation}}
{{/operations}}
}
@ -29,7 +29,7 @@ pub trait {{{classname}}} {
impl {{{classname}}} for {{{classname}}}Client {
{{#operations}}
{{#operation}}
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> {
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;

View File

@ -9,7 +9,7 @@ pub struct APIClient {
{{#operations}}
{{#operation}}
{{#-last}}
{{{classFilename}}}: Box<::apis::{{{classname}}}>,
{{{classFilename}}}: Box<crate::apis::{{{classname}}}>,
{{/-last}}
{{/operation}}
{{/operations}}
@ -28,7 +28,7 @@ impl APIClient {
{{#operations}}
{{#operation}}
{{#-last}}
{{{classFilename}}}: Box::new(::apis::{{{classname}}}Client::new(rc.clone())),
{{{classFilename}}}: Box::new(crate::apis::{{{classname}}}Client::new(rc.clone())),
{{/-last}}
{{/operation}}
{{/operations}}
@ -42,7 +42,7 @@ impl APIClient {
{{#operations}}
{{#operation}}
{{#-last}}
pub fn {{{classFilename}}}(&self) -> &::apis::{{{classname}}}{
pub fn {{{classFilename}}}(&self) -> &crate::apis::{{{classname}}}{
self.{{{classFilename}}}.as_ref()
}

View File

@ -1 +1 @@
4.0.2-SNAPSHOT
4.1.0-SNAPSHOT

View File

@ -5,10 +5,10 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **i64** | | [optional]
**category** | [***::models::Category**](Category.md) | | [optional]
**category** | [***crate::models::Category**](Category.md) | | [optional]
**name** | **String** | |
**photo_urls** | **Vec<String>** | |
**tags** | [**Vec<::models::Tag>**](Tag.md) | | [optional]
**tags** | [**Vec<crate::models::Tag>**](Tag.md) | | [optional]
**status** | **String** | pet status in the store | [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)

View File

@ -85,7 +85,7 @@ Name | Type | Description | Notes
## find_pets_by_status
> Vec<::models::Pet> find_pets_by_status(ctx, status)
> Vec<crate::models::Pet> find_pets_by_status(ctx, status)
Finds Pets by status
Multiple status values can be provided with comma separated strings
@ -100,7 +100,7 @@ Name | Type | Description | Notes
### Return type
[**Vec<::models::Pet>**](Pet.md)
[**Vec<crate::models::Pet>**](Pet.md)
### Authorization
@ -116,7 +116,7 @@ Name | Type | Description | Notes
## find_pets_by_tags
> Vec<::models::Pet> find_pets_by_tags(ctx, tags)
> Vec<crate::models::Pet> find_pets_by_tags(ctx, tags)
Finds Pets by tags
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
@ -131,7 +131,7 @@ Name | Type | Description | Notes
### Return type
[**Vec<::models::Pet>**](Pet.md)
[**Vec<crate::models::Pet>**](Pet.md)
### Authorization
@ -147,7 +147,7 @@ Name | Type | Description | Notes
## get_pet_by_id
> ::models::Pet get_pet_by_id(ctx, pet_id)
> crate::models::Pet get_pet_by_id(ctx, pet_id)
Find pet by ID
Returns a single pet
@ -162,7 +162,7 @@ Name | Type | Description | Notes
### Return type
[**::models::Pet**](Pet.md)
[**crate::models::Pet**](Pet.md)
### Authorization
@ -247,7 +247,7 @@ Name | Type | Description | Notes
## upload_file
> ::models::ApiResponse upload_file(ctx, pet_id, optional)
> crate::models::ApiResponse upload_file(ctx, pet_id, optional)
uploads an image
### Required Parameters
@ -271,7 +271,7 @@ Name | Type | Description | Notes
### Return type
[**::models::ApiResponse**](ApiResponse.md)
[**crate::models::ApiResponse**](ApiResponse.md)
### Authorization

View File

@ -70,7 +70,7 @@ This endpoint does not need any parameter.
## get_order_by_id
> ::models::Order get_order_by_id(order_id)
> crate::models::Order get_order_by_id(order_id)
Find purchase order by ID
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
@ -84,7 +84,7 @@ Name | Type | Description | Notes
### Return type
[**::models::Order**](Order.md)
[**crate::models::Order**](Order.md)
### Authorization
@ -100,7 +100,7 @@ No authorization required
## place_order
> ::models::Order place_order(body)
> crate::models::Order place_order(body)
Place an order for a pet
### Required Parameters
@ -112,7 +112,7 @@ Name | Type | Description | Notes
### Return type
[**::models::Order**](Order.md)
[**crate::models::Order**](Order.md)
### Authorization

View File

@ -55,7 +55,7 @@ Creates list of users with given input array
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Vec<::models::User>**](User.md)| List of user object |
**body** | [**Vec<crate::models::User>**](User.md)| List of user object |
### Return type
@ -83,7 +83,7 @@ Creates list of users with given input array
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Vec<::models::User>**](User.md)| List of user object |
**body** | [**Vec<crate::models::User>**](User.md)| List of user object |
### Return type
@ -133,7 +133,7 @@ No authorization required
## get_user_by_name
> ::models::User get_user_by_name(username)
> crate::models::User get_user_by_name(username)
Get user by user name
### Required Parameters
@ -145,7 +145,7 @@ Name | Type | Description | Notes
### Return type
[**::models::User**](User.md)
[**crate::models::User**](User.md)
### Authorization

View File

@ -4,9 +4,9 @@ use super::configuration::Configuration;
pub struct APIClient {
configuration: Rc<Configuration>,
pet_api: Box<::apis::PetApi>,
store_api: Box<::apis::StoreApi>,
user_api: Box<::apis::UserApi>,
pet_api: Box<crate::apis::PetApi>,
store_api: Box<crate::apis::StoreApi>,
user_api: Box<crate::apis::UserApi>,
}
impl APIClient {
@ -15,21 +15,21 @@ impl APIClient {
APIClient {
configuration: rc.clone(),
pet_api: Box::new(::apis::PetApiClient::new(rc.clone())),
store_api: Box::new(::apis::StoreApiClient::new(rc.clone())),
user_api: Box::new(::apis::UserApiClient::new(rc.clone())),
pet_api: Box::new(crate::apis::PetApiClient::new(rc.clone())),
store_api: Box::new(crate::apis::StoreApiClient::new(rc.clone())),
user_api: Box::new(crate::apis::UserApiClient::new(rc.clone())),
}
}
pub fn pet_api(&self) -> &::apis::PetApi{
pub fn pet_api(&self) -> &crate::apis::PetApi{
self.pet_api.as_ref()
}
pub fn store_api(&self) -> &::apis::StoreApi{
pub fn store_api(&self) -> &crate::apis::StoreApi{
self.store_api.as_ref()
}
pub fn user_api(&self) -> &::apis::UserApi{
pub fn user_api(&self) -> &crate::apis::UserApi{
self.user_api.as_ref()
}

View File

@ -28,18 +28,18 @@ impl PetApiClient {
}
pub trait PetApi {
fn add_pet(&self, body: ::models::Pet) -> Result<(), Error>;
fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error>;
fn delete_pet(&self, pet_id: i64, api_key: &str) -> Result<(), Error>;
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<::models::Pet>, Error>;
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<::models::Pet>, Error>;
fn get_pet_by_id(&self, pet_id: i64) -> Result<::models::Pet, Error>;
fn update_pet(&self, body: ::models::Pet) -> Result<(), Error>;
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<crate::models::Pet>, Error>;
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<crate::models::Pet>, Error>;
fn get_pet_by_id(&self, pet_id: i64) -> Result<crate::models::Pet, Error>;
fn update_pet(&self, body: crate::models::Pet) -> Result<(), Error>;
fn update_pet_with_form(&self, pet_id: i64, name: &str, status: &str) -> Result<(), Error>;
fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: std::path::PathBuf) -> Result<::models::ApiResponse, Error>;
fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: std::path::PathBuf) -> Result<crate::models::ApiResponse, Error>;
}
impl PetApi for PetApiClient {
fn add_pet(&self, body: ::models::Pet) -> Result<(), Error> {
fn add_pet(&self, body: crate::models::Pet) -> Result<(), Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;
@ -83,7 +83,7 @@ impl PetApi for PetApiClient {
Ok(())
}
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<::models::Pet>, Error> {
fn find_pets_by_status(&self, status: Vec<String>) -> Result<Vec<crate::models::Pet>, Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;
@ -104,7 +104,7 @@ impl PetApi for PetApiClient {
Ok(client.execute(req)?.error_for_status()?.json()?)
}
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<::models::Pet>, Error> {
fn find_pets_by_tags(&self, tags: Vec<String>) -> Result<Vec<crate::models::Pet>, Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;
@ -125,7 +125,7 @@ impl PetApi for PetApiClient {
Ok(client.execute(req)?.error_for_status()?.json()?)
}
fn get_pet_by_id(&self, pet_id: i64) -> Result<::models::Pet, Error> {
fn get_pet_by_id(&self, pet_id: i64) -> Result<crate::models::Pet, Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;
@ -150,7 +150,7 @@ impl PetApi for PetApiClient {
Ok(client.execute(req)?.error_for_status()?.json()?)
}
fn update_pet(&self, body: ::models::Pet) -> Result<(), Error> {
fn update_pet(&self, body: crate::models::Pet) -> Result<(), Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;
@ -197,7 +197,7 @@ impl PetApi for PetApiClient {
Ok(())
}
fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: std::path::PathBuf) -> Result<::models::ApiResponse, Error> {
fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: std::path::PathBuf) -> Result<crate::models::ApiResponse, Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;

View File

@ -30,8 +30,8 @@ impl StoreApiClient {
pub trait StoreApi {
fn delete_order(&self, order_id: &str) -> Result<(), Error>;
fn get_inventory(&self, ) -> Result<::std::collections::HashMap<String, i32>, Error>;
fn get_order_by_id(&self, order_id: i64) -> Result<::models::Order, Error>;
fn place_order(&self, body: ::models::Order) -> Result<::models::Order, Error>;
fn get_order_by_id(&self, order_id: i64) -> Result<crate::models::Order, Error>;
fn place_order(&self, body: crate::models::Order) -> Result<crate::models::Order, Error>;
}
impl StoreApi for StoreApiClient {
@ -78,7 +78,7 @@ impl StoreApi for StoreApiClient {
Ok(client.execute(req)?.error_for_status()?.json()?)
}
fn get_order_by_id(&self, order_id: i64) -> Result<::models::Order, Error> {
fn get_order_by_id(&self, order_id: i64) -> Result<crate::models::Order, Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;
@ -95,7 +95,7 @@ impl StoreApi for StoreApiClient {
Ok(client.execute(req)?.error_for_status()?.json()?)
}
fn place_order(&self, body: ::models::Order) -> Result<::models::Order, Error> {
fn place_order(&self, body: crate::models::Order) -> Result<crate::models::Order, Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;

View File

@ -28,18 +28,18 @@ impl UserApiClient {
}
pub trait UserApi {
fn create_user(&self, body: ::models::User) -> Result<(), Error>;
fn create_users_with_array_input(&self, body: Vec<::models::User>) -> Result<(), Error>;
fn create_users_with_list_input(&self, body: Vec<::models::User>) -> Result<(), Error>;
fn create_user(&self, body: crate::models::User) -> Result<(), Error>;
fn create_users_with_array_input(&self, body: Vec<crate::models::User>) -> Result<(), Error>;
fn create_users_with_list_input(&self, body: Vec<crate::models::User>) -> Result<(), Error>;
fn delete_user(&self, username: &str) -> Result<(), Error>;
fn get_user_by_name(&self, username: &str) -> Result<::models::User, Error>;
fn get_user_by_name(&self, username: &str) -> Result<crate::models::User, Error>;
fn login_user(&self, username: &str, password: &str) -> Result<String, Error>;
fn logout_user(&self, ) -> Result<(), Error>;
fn update_user(&self, username: &str, body: ::models::User) -> Result<(), Error>;
fn update_user(&self, username: &str, body: crate::models::User) -> Result<(), Error>;
}
impl UserApi for UserApiClient {
fn create_user(&self, body: ::models::User) -> Result<(), Error> {
fn create_user(&self, body: crate::models::User) -> Result<(), Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;
@ -58,7 +58,7 @@ impl UserApi for UserApiClient {
Ok(())
}
fn create_users_with_array_input(&self, body: Vec<::models::User>) -> Result<(), Error> {
fn create_users_with_array_input(&self, body: Vec<crate::models::User>) -> Result<(), Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;
@ -77,7 +77,7 @@ impl UserApi for UserApiClient {
Ok(())
}
fn create_users_with_list_input(&self, body: Vec<::models::User>) -> Result<(), Error> {
fn create_users_with_list_input(&self, body: Vec<crate::models::User>) -> Result<(), Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;
@ -114,7 +114,7 @@ impl UserApi for UserApiClient {
Ok(())
}
fn get_user_by_name(&self, username: &str) -> Result<::models::User, Error> {
fn get_user_by_name(&self, username: &str) -> Result<crate::models::User, Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;
@ -168,7 +168,7 @@ impl UserApi for UserApiClient {
Ok(())
}
fn update_user(&self, username: &str, body: ::models::User) -> Result<(), Error> {
fn update_user(&self, username: &str, body: crate::models::User) -> Result<(), Error> {
let configuration: &configuration::Configuration = self.configuration.borrow();
let client = &configuration.client;

View File

@ -10,9 +10,6 @@
/// ApiResponse : Describes the result of uploading an image resource
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct ApiResponse {

View File

@ -10,9 +10,6 @@
/// Category : A category for a pet
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct Category {

View File

@ -10,9 +10,6 @@
/// Order : An order for a pets from the pet store
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct Order {

View File

@ -10,22 +10,19 @@
/// Pet : A pet for sale in the pet store
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct Pet {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<i64>,
#[serde(rename = "category", skip_serializing_if = "Option::is_none")]
pub category: Option<::models::Category>,
pub category: Option<crate::models::Category>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "photoUrls")]
pub photo_urls: Vec<String>,
#[serde(rename = "tags", skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<::models::Tag>>,
pub tags: Option<Vec<crate::models::Tag>>,
/// pet status in the store
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
pub status: Option<String>,

View File

@ -10,9 +10,6 @@
/// Tag : A tag for a pet
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct Tag {

View File

@ -10,9 +10,6 @@
/// User : A User who is purchasing from the pet store
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct User {

View File

@ -1 +1 @@
4.0.2-SNAPSHOT
4.1.0-SNAPSHOT

View File

@ -5,10 +5,10 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **i64** | | [optional]
**category** | [***::models::Category**](Category.md) | | [optional]
**category** | [***crate::models::Category**](Category.md) | | [optional]
**name** | **String** | |
**photo_urls** | **Vec<String>** | |
**tags** | [**Vec<::models::Tag>**](Tag.md) | | [optional]
**tags** | [**Vec<crate::models::Tag>**](Tag.md) | | [optional]
**status** | **String** | pet status in the store | [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)

View File

@ -85,7 +85,7 @@ Name | Type | Description | Notes
## find_pets_by_status
> Vec<::models::Pet> find_pets_by_status(ctx, status)
> Vec<crate::models::Pet> find_pets_by_status(ctx, status)
Finds Pets by status
Multiple status values can be provided with comma separated strings
@ -100,7 +100,7 @@ Name | Type | Description | Notes
### Return type
[**Vec<::models::Pet>**](Pet.md)
[**Vec<crate::models::Pet>**](Pet.md)
### Authorization
@ -116,7 +116,7 @@ Name | Type | Description | Notes
## find_pets_by_tags
> Vec<::models::Pet> find_pets_by_tags(ctx, tags)
> Vec<crate::models::Pet> find_pets_by_tags(ctx, tags)
Finds Pets by tags
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
@ -131,7 +131,7 @@ Name | Type | Description | Notes
### Return type
[**Vec<::models::Pet>**](Pet.md)
[**Vec<crate::models::Pet>**](Pet.md)
### Authorization
@ -147,7 +147,7 @@ Name | Type | Description | Notes
## get_pet_by_id
> ::models::Pet get_pet_by_id(ctx, pet_id)
> crate::models::Pet get_pet_by_id(ctx, pet_id)
Find pet by ID
Returns a single pet
@ -162,7 +162,7 @@ Name | Type | Description | Notes
### Return type
[**::models::Pet**](Pet.md)
[**crate::models::Pet**](Pet.md)
### Authorization
@ -247,7 +247,7 @@ Name | Type | Description | Notes
## upload_file
> ::models::ApiResponse upload_file(ctx, pet_id, optional)
> crate::models::ApiResponse upload_file(ctx, pet_id, optional)
uploads an image
### Required Parameters
@ -271,7 +271,7 @@ Name | Type | Description | Notes
### Return type
[**::models::ApiResponse**](ApiResponse.md)
[**crate::models::ApiResponse**](ApiResponse.md)
### Authorization

View File

@ -70,7 +70,7 @@ This endpoint does not need any parameter.
## get_order_by_id
> ::models::Order get_order_by_id(order_id)
> crate::models::Order get_order_by_id(order_id)
Find purchase order by ID
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
@ -84,7 +84,7 @@ Name | Type | Description | Notes
### Return type
[**::models::Order**](Order.md)
[**crate::models::Order**](Order.md)
### Authorization
@ -100,7 +100,7 @@ No authorization required
## place_order
> ::models::Order place_order(body)
> crate::models::Order place_order(body)
Place an order for a pet
### Required Parameters
@ -112,7 +112,7 @@ Name | Type | Description | Notes
### Return type
[**::models::Order**](Order.md)
[**crate::models::Order**](Order.md)
### Authorization

View File

@ -55,7 +55,7 @@ Creates list of users with given input array
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Vec<::models::User>**](User.md)| List of user object |
**body** | [**Vec<crate::models::User>**](User.md)| List of user object |
### Return type
@ -83,7 +83,7 @@ Creates list of users with given input array
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**Vec<::models::User>**](User.md)| List of user object |
**body** | [**Vec<crate::models::User>**](User.md)| List of user object |
### Return type
@ -133,7 +133,7 @@ No authorization required
## get_user_by_name
> ::models::User get_user_by_name(username)
> crate::models::User get_user_by_name(username)
Get user by user name
### Required Parameters
@ -145,7 +145,7 @@ Name | Type | Description | Notes
### Return type
[**::models::User**](User.md)
[**crate::models::User**](User.md)
### Authorization

View File

@ -5,9 +5,9 @@ use super::configuration::Configuration;
pub struct APIClient<C: hyper::client::Connect> {
configuration: Rc<Configuration<C>>,
pet_api: Box<::apis::PetApi>,
store_api: Box<::apis::StoreApi>,
user_api: Box<::apis::UserApi>,
pet_api: Box<crate::apis::PetApi>,
store_api: Box<crate::apis::StoreApi>,
user_api: Box<crate::apis::UserApi>,
}
impl<C: hyper::client::Connect> APIClient<C> {
@ -16,21 +16,21 @@ impl<C: hyper::client::Connect> APIClient<C> {
APIClient {
configuration: rc.clone(),
pet_api: Box::new(::apis::PetApiClient::new(rc.clone())),
store_api: Box::new(::apis::StoreApiClient::new(rc.clone())),
user_api: Box::new(::apis::UserApiClient::new(rc.clone())),
pet_api: Box::new(crate::apis::PetApiClient::new(rc.clone())),
store_api: Box::new(crate::apis::StoreApiClient::new(rc.clone())),
user_api: Box::new(crate::apis::UserApiClient::new(rc.clone())),
}
}
pub fn pet_api(&self) -> &::apis::PetApi{
pub fn pet_api(&self) -> &crate::apis::PetApi{
self.pet_api.as_ref()
}
pub fn store_api(&self) -> &::apis::StoreApi{
pub fn store_api(&self) -> &crate::apis::StoreApi{
self.store_api.as_ref()
}
pub fn user_api(&self) -> &::apis::UserApi{
pub fn user_api(&self) -> &crate::apis::UserApi{
self.user_api.as_ref()
}

View File

@ -31,19 +31,19 @@ impl<C: hyper::client::Connect> PetApiClient<C> {
}
pub trait PetApi {
fn add_pet(&self, body: ::models::Pet) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn add_pet(&self, body: crate::models::Pet) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn delete_pet(&self, pet_id: i64, api_key: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn find_pets_by_status(&self, status: Vec<String>) -> Box<Future<Item = Vec<::models::Pet>, Error = Error<serde_json::Value>>>;
fn find_pets_by_tags(&self, tags: Vec<String>) -> Box<Future<Item = Vec<::models::Pet>, Error = Error<serde_json::Value>>>;
fn get_pet_by_id(&self, pet_id: i64) -> Box<Future<Item = ::models::Pet, Error = Error<serde_json::Value>>>;
fn update_pet(&self, body: ::models::Pet) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn find_pets_by_status(&self, status: Vec<String>) -> Box<Future<Item = Vec<crate::models::Pet>, Error = Error<serde_json::Value>>>;
fn find_pets_by_tags(&self, tags: Vec<String>) -> Box<Future<Item = Vec<crate::models::Pet>, Error = Error<serde_json::Value>>>;
fn get_pet_by_id(&self, pet_id: i64) -> Box<Future<Item = crate::models::Pet, Error = Error<serde_json::Value>>>;
fn update_pet(&self, body: crate::models::Pet) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn update_pet_with_form(&self, pet_id: i64, name: &str, status: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: std::path::PathBuf) -> Box<Future<Item = ::models::ApiResponse, Error = Error<serde_json::Value>>>;
fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: std::path::PathBuf) -> Box<Future<Item = crate::models::ApiResponse, Error = Error<serde_json::Value>>>;
}
impl<C: hyper::client::Connect>PetApi for PetApiClient<C> {
fn add_pet(&self, body: ::models::Pet) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
fn add_pet(&self, body: crate::models::Pet) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
__internal_request::Request::new(hyper::Method::Post, "/pet".to_string())
.with_auth(__internal_request::Auth::Oauth)
.with_body_param(body)
@ -60,21 +60,21 @@ impl<C: hyper::client::Connect>PetApi for PetApiClient<C> {
.execute(self.configuration.borrow())
}
fn find_pets_by_status(&self, status: Vec<String>) -> Box<Future<Item = Vec<::models::Pet>, Error = Error<serde_json::Value>>> {
fn find_pets_by_status(&self, status: Vec<String>) -> Box<Future<Item = Vec<crate::models::Pet>, Error = Error<serde_json::Value>>> {
__internal_request::Request::new(hyper::Method::Get, "/pet/findByStatus".to_string())
.with_auth(__internal_request::Auth::Oauth)
.with_query_param("status".to_string(), status.join(",").to_string())
.execute(self.configuration.borrow())
}
fn find_pets_by_tags(&self, tags: Vec<String>) -> Box<Future<Item = Vec<::models::Pet>, Error = Error<serde_json::Value>>> {
fn find_pets_by_tags(&self, tags: Vec<String>) -> Box<Future<Item = Vec<crate::models::Pet>, Error = Error<serde_json::Value>>> {
__internal_request::Request::new(hyper::Method::Get, "/pet/findByTags".to_string())
.with_auth(__internal_request::Auth::Oauth)
.with_query_param("tags".to_string(), tags.join(",").to_string())
.execute(self.configuration.borrow())
}
fn get_pet_by_id(&self, pet_id: i64) -> Box<Future<Item = ::models::Pet, Error = Error<serde_json::Value>>> {
fn get_pet_by_id(&self, pet_id: i64) -> Box<Future<Item = crate::models::Pet, Error = Error<serde_json::Value>>> {
__internal_request::Request::new(hyper::Method::Get, "/pet/{petId}".to_string())
.with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{
in_header: true,
@ -85,7 +85,7 @@ impl<C: hyper::client::Connect>PetApi for PetApiClient<C> {
.execute(self.configuration.borrow())
}
fn update_pet(&self, body: ::models::Pet) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
fn update_pet(&self, body: crate::models::Pet) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
__internal_request::Request::new(hyper::Method::Put, "/pet".to_string())
.with_auth(__internal_request::Auth::Oauth)
.with_body_param(body)
@ -103,7 +103,7 @@ impl<C: hyper::client::Connect>PetApi for PetApiClient<C> {
.execute(self.configuration.borrow())
}
fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: std::path::PathBuf) -> Box<Future<Item = ::models::ApiResponse, Error = Error<serde_json::Value>>> {
fn upload_file(&self, pet_id: i64, additional_metadata: &str, file: std::path::PathBuf) -> Box<Future<Item = crate::models::ApiResponse, Error = Error<serde_json::Value>>> {
__internal_request::Request::new(hyper::Method::Post, "/pet/{petId}/uploadImage".to_string())
.with_auth(__internal_request::Auth::Oauth)
.with_path_param("petId".to_string(), pet_id.to_string())

View File

@ -33,8 +33,8 @@ impl<C: hyper::client::Connect> StoreApiClient<C> {
pub trait StoreApi {
fn delete_order(&self, order_id: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn get_inventory(&self, ) -> Box<Future<Item = ::std::collections::HashMap<String, i32>, Error = Error<serde_json::Value>>>;
fn get_order_by_id(&self, order_id: i64) -> Box<Future<Item = ::models::Order, Error = Error<serde_json::Value>>>;
fn place_order(&self, body: ::models::Order) -> Box<Future<Item = ::models::Order, Error = Error<serde_json::Value>>>;
fn get_order_by_id(&self, order_id: i64) -> Box<Future<Item = crate::models::Order, Error = Error<serde_json::Value>>>;
fn place_order(&self, body: crate::models::Order) -> Box<Future<Item = crate::models::Order, Error = Error<serde_json::Value>>>;
}
@ -56,13 +56,13 @@ impl<C: hyper::client::Connect>StoreApi for StoreApiClient<C> {
.execute(self.configuration.borrow())
}
fn get_order_by_id(&self, order_id: i64) -> Box<Future<Item = ::models::Order, Error = Error<serde_json::Value>>> {
fn get_order_by_id(&self, order_id: i64) -> Box<Future<Item = crate::models::Order, Error = Error<serde_json::Value>>> {
__internal_request::Request::new(hyper::Method::Get, "/store/order/{orderId}".to_string())
.with_path_param("orderId".to_string(), order_id.to_string())
.execute(self.configuration.borrow())
}
fn place_order(&self, body: ::models::Order) -> Box<Future<Item = ::models::Order, Error = Error<serde_json::Value>>> {
fn place_order(&self, body: crate::models::Order) -> Box<Future<Item = crate::models::Order, Error = Error<serde_json::Value>>> {
__internal_request::Request::new(hyper::Method::Post, "/store/order".to_string())
.with_body_param(body)
.execute(self.configuration.borrow())

View File

@ -31,33 +31,33 @@ impl<C: hyper::client::Connect> UserApiClient<C> {
}
pub trait UserApi {
fn create_user(&self, body: ::models::User) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn create_users_with_array_input(&self, body: Vec<::models::User>) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn create_users_with_list_input(&self, body: Vec<::models::User>) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn create_user(&self, body: crate::models::User) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn create_users_with_array_input(&self, body: Vec<crate::models::User>) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn create_users_with_list_input(&self, body: Vec<crate::models::User>) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn delete_user(&self, username: &str) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn get_user_by_name(&self, username: &str) -> Box<Future<Item = ::models::User, Error = Error<serde_json::Value>>>;
fn get_user_by_name(&self, username: &str) -> Box<Future<Item = crate::models::User, Error = Error<serde_json::Value>>>;
fn login_user(&self, username: &str, password: &str) -> Box<Future<Item = String, Error = Error<serde_json::Value>>>;
fn logout_user(&self, ) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn update_user(&self, username: &str, body: ::models::User) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
fn update_user(&self, username: &str, body: crate::models::User) -> Box<Future<Item = (), Error = Error<serde_json::Value>>>;
}
impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
fn create_user(&self, body: ::models::User) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
fn create_user(&self, body: crate::models::User) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
__internal_request::Request::new(hyper::Method::Post, "/user".to_string())
.with_body_param(body)
.returns_nothing()
.execute(self.configuration.borrow())
}
fn create_users_with_array_input(&self, body: Vec<::models::User>) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
fn create_users_with_array_input(&self, body: Vec<crate::models::User>) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
__internal_request::Request::new(hyper::Method::Post, "/user/createWithArray".to_string())
.with_body_param(body)
.returns_nothing()
.execute(self.configuration.borrow())
}
fn create_users_with_list_input(&self, body: Vec<::models::User>) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
fn create_users_with_list_input(&self, body: Vec<crate::models::User>) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
__internal_request::Request::new(hyper::Method::Post, "/user/createWithList".to_string())
.with_body_param(body)
.returns_nothing()
@ -71,7 +71,7 @@ impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
.execute(self.configuration.borrow())
}
fn get_user_by_name(&self, username: &str) -> Box<Future<Item = ::models::User, Error = Error<serde_json::Value>>> {
fn get_user_by_name(&self, username: &str) -> Box<Future<Item = crate::models::User, Error = Error<serde_json::Value>>> {
__internal_request::Request::new(hyper::Method::Get, "/user/{username}".to_string())
.with_path_param("username".to_string(), username.to_string())
.execute(self.configuration.borrow())
@ -90,7 +90,7 @@ impl<C: hyper::client::Connect>UserApi for UserApiClient<C> {
.execute(self.configuration.borrow())
}
fn update_user(&self, username: &str, body: ::models::User) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
fn update_user(&self, username: &str, body: crate::models::User) -> Box<Future<Item = (), Error = Error<serde_json::Value>>> {
__internal_request::Request::new(hyper::Method::Put, "/user/{username}".to_string())
.with_path_param("username".to_string(), username.to_string())
.with_body_param(body)

View File

@ -10,9 +10,6 @@
/// ApiResponse : Describes the result of uploading an image resource
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct ApiResponse {

View File

@ -10,9 +10,6 @@
/// Category : A category for a pet
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct Category {

View File

@ -10,9 +10,6 @@
/// Order : An order for a pets from the pet store
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct Order {

View File

@ -10,22 +10,19 @@
/// Pet : A pet for sale in the pet store
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct Pet {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<i64>,
#[serde(rename = "category", skip_serializing_if = "Option::is_none")]
pub category: Option<::models::Category>,
pub category: Option<crate::models::Category>,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "photoUrls")]
pub photo_urls: Vec<String>,
#[serde(rename = "tags", skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<::models::Tag>>,
pub tags: Option<Vec<crate::models::Tag>>,
/// pet status in the store
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
pub status: Option<String>,

View File

@ -10,9 +10,6 @@
/// Tag : A tag for a pet
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct Tag {

View File

@ -10,9 +10,6 @@
/// User : A User who is purchasing from the pet store
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct User {