mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
[rust] basic oneOf support (#13970)
* [rust] basic oneOf support Suport oneOf as a rust struct enum. Details: Enum without a discriminator is untagged being "untagged" simply means serde won't attempt to store the name of the enum inside the serialized object. See https://serde.rs/enum-representations.html#untagged for more Also check to make sure the mapping values are not an empty object (aka null). Co-authored-by: Nikita Puzankov <git@bshn.rs> * refactor: fix clippy lints No longer needed as of reqwest 0.10, it now takes the response as owned instead of mut ref. Is not empty is more clear * fix: discriminator and oneof case Will show as a struct enum when there are additional fields, otherwise will be a tuple enum. not sure the purpose of x-mapped-models, perhaps legacy code? mappedModels appears to do the same thing. Also add default implementation for quality of life * chore: update samples --------- Co-authored-by: Nikita Puzankov <git@bshn.rs>
This commit is contained in:
parent
4fb97b1003
commit
c30d3696b0
@ -9,6 +9,7 @@
|
||||
"ghcr.io/devcontainers/features/node:1": {
|
||||
"version": "lts"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/rust:1": {},
|
||||
"ghcr.io/snebjorn/devcontainer-feature/chromium:latest": {},
|
||||
"docker-in-docker": {
|
||||
"version": "latest",
|
||||
|
8
bin/configs/rust-hyper-composed-oneof.yaml
Normal file
8
bin/configs/rust-hyper-composed-oneof.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
generatorName: rust
|
||||
outputDir: samples/client/others/rust/hyper/composed-oneof
|
||||
library: hyper
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/composed-oneof.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/rust
|
||||
additionalProperties:
|
||||
supportAsync: "false"
|
||||
packageName: composed-oneof-hyper
|
8
bin/configs/rust-hyper-oneOf.yaml
Normal file
8
bin/configs/rust-hyper-oneOf.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
generatorName: rust
|
||||
outputDir: samples/client/others/rust/hyper/oneOf
|
||||
library: hyper
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneof_polymorphism_and_inheritance.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/rust
|
||||
additionalProperties:
|
||||
supportAsync: "false"
|
||||
packageName: oneof-hyper
|
8
bin/configs/rust-reqwest-composed-oneof.yaml
Normal file
8
bin/configs/rust-reqwest-composed-oneof.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
generatorName: rust
|
||||
outputDir: samples/client/others/rust/reqwest/composed-oneof
|
||||
library: reqwest
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/composed-oneof.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/rust
|
||||
additionalProperties:
|
||||
supportAsync: "false"
|
||||
packageName: composed-oneof-reqwest
|
8
bin/configs/rust-reqwest-oneOf.yaml
Normal file
8
bin/configs/rust-reqwest-oneOf.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
generatorName: rust
|
||||
outputDir: samples/client/others/rust/reqwest/oneOf
|
||||
library: reqwest
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneof_polymorphism_and_inheritance.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/rust
|
||||
additionalProperties:
|
||||
supportAsync: false
|
||||
packageName: oneof-reqwest
|
@ -214,7 +214,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|Union|✗|OAS3
|
||||
|allOf|✗|OAS2,OAS3
|
||||
|anyOf|✗|OAS3
|
||||
|oneOf|✗|OAS3
|
||||
|oneOf|✓|OAS3
|
||||
|not|✗|OAS3
|
||||
|
||||
### Security Feature
|
||||
|
@ -108,6 +108,9 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
.excludeParameterFeatures(
|
||||
ParameterFeature.Cookie
|
||||
)
|
||||
.includeSchemaSupportFeatures(
|
||||
SchemaSupportFeature.oneOf
|
||||
)
|
||||
.includeClientModificationFeatures(
|
||||
ClientModificationFeature.BasePath,
|
||||
ClientModificationFeature.UserAgent
|
||||
@ -204,52 +207,22 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
|
||||
@Override
|
||||
public ModelsMap postProcessModels(ModelsMap objs) {
|
||||
// process enum in models
|
||||
return postProcessModelsEnum(objs);
|
||||
}
|
||||
// Remove the discriminator field from the model, serde will take care of this
|
||||
for (ModelMap model : objs.getModels()) {
|
||||
CodegenModel cm = model.getModel();
|
||||
if (cm.discriminator != null) {
|
||||
String reserved_var_name = cm.discriminator.getPropertyBaseName();
|
||||
|
||||
@SuppressWarnings("static-method")
|
||||
public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs) {
|
||||
// Index all CodegenModels by model name.
|
||||
Map<String, CodegenModel> allModels = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, ModelsMap> entry : objs.entrySet()) {
|
||||
String modelName = toModelName(entry.getKey());
|
||||
List<ModelMap> models = entry.getValue().getModels();
|
||||
for (ModelMap mo : models) {
|
||||
CodegenModel cm = mo.getModel();
|
||||
allModels.put(modelName, cm);
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, ModelsMap> entry : objs.entrySet()) {
|
||||
List<ModelMap> models = entry.getValue().getModels();
|
||||
for (ModelMap mo : models) {
|
||||
CodegenModel cm = mo.getModel();
|
||||
if (cm.discriminator != null) {
|
||||
List<Object> discriminatorVars = new ArrayList<>();
|
||||
for (CodegenDiscriminator.MappedModel mappedModel : cm.discriminator.getMappedModels()) {
|
||||
CodegenModel model = allModels.get(mappedModel.getModelName());
|
||||
Map<String, Object> mas = new HashMap<>();
|
||||
mas.put("modelName", camelize(mappedModel.getModelName()));
|
||||
mas.put("mappingName", mappedModel.getMappingName());
|
||||
|
||||
// TODO: deleting the variable from the array was
|
||||
// problematic; I don't know what this is supposed to do
|
||||
// so I'm just cloning it for the moment
|
||||
List<CodegenProperty> vars = new ArrayList<>(model.getVars());
|
||||
vars.removeIf(p -> p.name.equals(cm.discriminator.getPropertyName()));
|
||||
mas.put("vars", vars);
|
||||
discriminatorVars.add(mas);
|
||||
for (CodegenProperty cp : cm.vars) {
|
||||
if (cp.baseName.equals(reserved_var_name)) {
|
||||
cm.vars.remove(cp);
|
||||
break;
|
||||
}
|
||||
// TODO: figure out how to properly have the original property type that didn't go through toVarName
|
||||
String vendorExtensionTagName = cm.discriminator.getPropertyName();
|
||||
cm.vendorExtensions.put("x-tag-name", vendorExtensionTagName);
|
||||
cm.vendorExtensions.put("x-mapped-models", discriminatorVars);
|
||||
}
|
||||
}
|
||||
}
|
||||
return objs;
|
||||
// process enum in models
|
||||
return postProcessModelsEnum(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,9 @@
|
||||
{{#description}}
|
||||
/// {{{classname}}} : {{{description}}}
|
||||
{{/description}}
|
||||
{{#oneOf}}
|
||||
use super::{{{.}}};
|
||||
{{/oneOf}}
|
||||
|
||||
{{!-- for enum schemas --}}
|
||||
{{#isEnum}}
|
||||
@ -41,10 +44,10 @@ impl Default for {{{classname}}} {
|
||||
{{!-- for schemas that have a discriminator --}}
|
||||
{{#discriminator}}
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "{{{vendorExtensions.x-tag-name}}}")]
|
||||
#[serde(tag = "{{{propertyBaseName}}}")]
|
||||
pub enum {{{classname}}} {
|
||||
{{#vendorExtensions}}
|
||||
{{#x-mapped-models}}
|
||||
{{^oneOf}}
|
||||
{{#mappedModels}}
|
||||
#[serde(rename="{{mappingName}}")]
|
||||
{{{modelName}}} {
|
||||
{{#vars}}
|
||||
@ -55,8 +58,24 @@ pub enum {{{classname}}} {
|
||||
{{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{#isModel}}Box<{{{dataType}}}>{{/isModel}}{{^isModel}}{{{dataType}}}{{/isModel}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}},
|
||||
{{/vars}}
|
||||
},
|
||||
{{/x-mapped-models}}
|
||||
{{/vendorExtensions}}
|
||||
{{/mappedModels}}
|
||||
{{/oneOf}}
|
||||
{{#oneOf}}
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
{{{.}}}(Box<{{{.}}}>),
|
||||
{{/oneOf}}
|
||||
}
|
||||
|
||||
impl Default for {{classname}} {
|
||||
fn default() -> Self {
|
||||
{{^oneOf}}{{#mappedModels}}{{#-first}}Self::{{modelName}} {
|
||||
{{#vars}}
|
||||
{{{name}}}: Default::default(),
|
||||
{{/vars}}
|
||||
}{{/-first}}{{/mappedModels}}{{/oneOf}}{{#oneOf}}{{#-first}}Self::{{{.}}}(Box::default()){{/-first}}{{/oneOf}}
|
||||
}
|
||||
}
|
||||
|
||||
{{/discriminator}}
|
||||
@ -64,7 +83,8 @@ pub enum {{{classname}}} {
|
||||
{{!-- for non-enum schemas --}}
|
||||
{{^isEnum}}
|
||||
{{^discriminator}}
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
{{#oneOf.isEmpty}}
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct {{{classname}}} {
|
||||
{{#vars}}
|
||||
{{#description}}
|
||||
@ -87,6 +107,26 @@ impl {{{classname}}} {
|
||||
}
|
||||
}
|
||||
}
|
||||
{{/oneOf.isEmpty}}
|
||||
{{^oneOf.isEmpty}}
|
||||
{{! TODO: add other vars that are not part of the oneOf}}
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum {{classname}} {
|
||||
{{#oneOf}}
|
||||
{{#description}}
|
||||
/// {{{.}}}
|
||||
{{/description}}
|
||||
{{{.}}}(Box<{{{.}}}>),
|
||||
{{/oneOf}}
|
||||
}
|
||||
|
||||
impl Default for {{classname}} {
|
||||
fn default() -> Self {
|
||||
{{#oneOf}}{{#-first}}Self::{{{.}}}(Box::default()){{/-first}}{{/oneOf}}
|
||||
}
|
||||
}
|
||||
{{/oneOf.isEmpty}}
|
||||
{{/discriminator}}
|
||||
{{/isEnum}}
|
||||
|
||||
|
@ -1,4 +1,35 @@
|
||||
{{#models}}{{#model}}# {{{classname}}}
|
||||
{{#isEnum}}
|
||||
|
||||
## Enum Variants
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|{{#allowableValues}}{{#enumVars}}
|
||||
| {{name}} | {{value}} |{{/enumVars}}{{/allowableValues}}
|
||||
|
||||
{{/isEnum}}
|
||||
{{#discriminator}}
|
||||
|
||||
## Enum Variants
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|{{#vendorExtensions}}{{#x-mapped-models}}
|
||||
| {{modelName}} | {{mappingName}} |{{/x-mapped-models}}{{/vendorExtensions}}
|
||||
{{#vendorExtensions}}
|
||||
{{#x-mapped-models}}
|
||||
|
||||
## {{modelName}}
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#vars}}**{{{name}}}** | {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{{complexType}}}.md){{/isPrimitiveType}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}} | {{{description}}} | {{^required}}[optional]{{/required}}{{#isReadOnly}}[readonly]{{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
{{/vars}}
|
||||
{{/x-mapped-models}}
|
||||
{{/vendorExtensions}}
|
||||
{{/discriminator}}
|
||||
{{^discriminator}}
|
||||
{{^isEnum}}
|
||||
{{#oneOf.isEmpty}}
|
||||
|
||||
## Properties
|
||||
|
||||
@ -6,6 +37,17 @@ Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#vars}}**{{{name}}}** | {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{{complexType}}}.md){{/isPrimitiveType}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}} | {{{description}}} | {{^required}}[optional]{{/required}}{{#isReadOnly}}[readonly]{{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||
{{/vars}}
|
||||
{{/oneOf.isEmpty}}
|
||||
{{^oneOf.isEmpty}}
|
||||
|
||||
## Enum Variants
|
||||
|
||||
| Name | Description |
|
||||
|---- | -----|{{#oneOf}}
|
||||
| {{{.}}} | {{description}} |{{/oneOf}}
|
||||
{{/oneOf.isEmpty}}
|
||||
{{/isEnum}}
|
||||
{{/discriminator}}
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -128,7 +128,7 @@ impl Request {
|
||||
let mut uri_str = format!("{}{}", conf.base_path, path);
|
||||
|
||||
let query_string_str = query_string.finish();
|
||||
if query_string_str != "" {
|
||||
if !query_string_str.is_empty() {
|
||||
uri_str += "?";
|
||||
uri_str += &query_string_str;
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
|
||||
{{/hasBodyParam}}
|
||||
|
||||
let local_var_req = local_var_req_builder.build()?;
|
||||
let {{^supportAsync}}mut {{/supportAsync}}local_var_resp = local_var_client.execute(local_var_req){{#supportAsync}}.await{{/supportAsync}}?;
|
||||
let local_var_resp = local_var_client.execute(local_var_req){{#supportAsync}}.await{{/supportAsync}}?;
|
||||
|
||||
let local_var_status = local_var_resp.status();
|
||||
let local_var_content = local_var_resp.text(){{#supportAsync}}.await{{/supportAsync}}?;
|
||||
|
@ -1,7 +1,7 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: oneOf test
|
||||
version: '1.0'
|
||||
version: '1.0.0'
|
||||
servers:
|
||||
- url: 'http://localhost:8000/'
|
||||
paths:
|
||||
@ -23,7 +23,7 @@ paths:
|
||||
mapping:
|
||||
a-type: '#/components/schemas/ObjA'
|
||||
b-type: '#/components/schemas/ObjB'
|
||||
b-type: '#/components/schemas/ObjD'
|
||||
d-type: '#/components/schemas/ObjD'
|
||||
post:
|
||||
operationId: createState
|
||||
requestBody:
|
||||
|
1442
samples/client/others/rust/Cargo.lock
generated
1442
samples/client/others/rust/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,2 +1,2 @@
|
||||
[workspace]
|
||||
members = ["reqwest-regression-16119"]
|
||||
members = ["hyper/*", "reqwest/*", "reqwest-regression-16119"]
|
||||
|
3
samples/client/others/rust/hyper/composed-oneof/.gitignore
vendored
Normal file
3
samples/client/others/rust/hyper/composed-oneof/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/target/
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
@ -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
|
@ -0,0 +1,29 @@
|
||||
.gitignore
|
||||
.travis.yml
|
||||
Cargo.toml
|
||||
README.md
|
||||
docs/CreateStateRequest.md
|
||||
docs/CustomOneOfArraySchemaInner.md
|
||||
docs/CustomOneOfSchema.md
|
||||
docs/DefaultApi.md
|
||||
docs/GetState200Response.md
|
||||
docs/ObjA.md
|
||||
docs/ObjB.md
|
||||
docs/ObjC.md
|
||||
docs/ObjD.md
|
||||
git_push.sh
|
||||
src/apis/client.rs
|
||||
src/apis/configuration.rs
|
||||
src/apis/default_api.rs
|
||||
src/apis/mod.rs
|
||||
src/apis/request.rs
|
||||
src/lib.rs
|
||||
src/models/create_state_request.rs
|
||||
src/models/custom_one_of_array_schema_inner.rs
|
||||
src/models/custom_one_of_schema.rs
|
||||
src/models/get_state_200_response.rs
|
||||
src/models/mod.rs
|
||||
src/models/obj_a.rs
|
||||
src/models/obj_b.rs
|
||||
src/models/obj_c.rs
|
||||
src/models/obj_d.rs
|
@ -0,0 +1 @@
|
||||
7.3.0-SNAPSHOT
|
@ -0,0 +1 @@
|
||||
language: rust
|
20
samples/client/others/rust/hyper/composed-oneof/Cargo.toml
Normal file
20
samples/client/others/rust/hyper/composed-oneof/Cargo.toml
Normal file
@ -0,0 +1,20 @@
|
||||
[package]
|
||||
name = "composed-oneof-hyper"
|
||||
version = "1.0.0"
|
||||
authors = ["OpenAPI Generator team and contributors"]
|
||||
description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
|
||||
# Override this license by providing a License Object in the OpenAPI.
|
||||
license = "Unlicense"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = "^1.0"
|
||||
serde_derive = "^1.0"
|
||||
serde_json = "^1.0"
|
||||
url = "^2.2"
|
||||
uuid = { version = "^1.0", features = ["serde", "v4"] }
|
||||
hyper = { version = "~0.14", features = ["full"] }
|
||||
hyper-tls = "~0.5"
|
||||
http = "~0.2"
|
||||
base64 = "~0.7.0"
|
||||
futures = "^0.3"
|
53
samples/client/others/rust/hyper/composed-oneof/README.md
Normal file
53
samples/client/others/rust/hyper/composed-oneof/README.md
Normal file
@ -0,0 +1,53 @@
|
||||
# Rust API client for composed-oneof-hyper
|
||||
|
||||
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
|
||||
|
||||
## 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
|
||||
- Build package: `org.openapitools.codegen.languages.RustClientCodegen`
|
||||
|
||||
## Installation
|
||||
|
||||
Put the package under your project folder in a directory named `composed-oneof-hyper` and add the following to `Cargo.toml` under `[dependencies]`:
|
||||
|
||||
```
|
||||
composed-oneof-hyper = { path = "./composed-oneof-hyper" }
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *http://localhost:8000*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*DefaultApi* | [**create_state**](docs/DefaultApi.md#create_state) | **Post** /state |
|
||||
*DefaultApi* | [**get_state**](docs/DefaultApi.md#get_state) | **Get** /state |
|
||||
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
- [CreateStateRequest](docs/CreateStateRequest.md)
|
||||
- [CustomOneOfArraySchemaInner](docs/CustomOneOfArraySchemaInner.md)
|
||||
- [CustomOneOfSchema](docs/CustomOneOfSchema.md)
|
||||
- [GetState200Response](docs/GetState200Response.md)
|
||||
- [ObjA](docs/ObjA.md)
|
||||
- [ObjB](docs/ObjB.md)
|
||||
- [ObjC](docs/ObjC.md)
|
||||
- [ObjD](docs/ObjD.md)
|
||||
|
||||
|
||||
To get access to the crate's generated documentation, use:
|
||||
|
||||
```
|
||||
cargo doc --open
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# CreateStateRequest
|
||||
|
||||
## Enum Variants
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# CustomOneOfArraySchemaInner
|
||||
|
||||
## Enum Variants
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# CustomOneOfSchema
|
||||
|
||||
## Enum Variants
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,63 @@
|
||||
# \DefaultApi
|
||||
|
||||
All URIs are relative to *http://localhost:8000*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**create_state**](DefaultApi.md#create_state) | **Post** /state |
|
||||
[**get_state**](DefaultApi.md#get_state) | **Get** /state |
|
||||
|
||||
|
||||
|
||||
## create_state
|
||||
|
||||
> create_state(create_state_request)
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**create_state_request** | [**CreateStateRequest**](CreateStateRequest.md) | | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[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_state
|
||||
|
||||
> crate::models::GetState200Response get_state()
|
||||
|
||||
|
||||
### Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
[**crate::models::GetState200Response**](getState_200_response.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)
|
||||
|
@ -0,0 +1,10 @@
|
||||
# GetState200Response
|
||||
|
||||
## Enum Variants
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
|
||||
[[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
samples/client/others/rust/hyper/composed-oneof/docs/ObjA.md
Normal file
12
samples/client/others/rust/hyper/composed-oneof/docs/ObjA.md
Normal file
@ -0,0 +1,12 @@
|
||||
# ObjA
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**realtype** | Option<**String**> | | [optional]
|
||||
**message** | Option<**String**> | | [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)
|
||||
|
||||
|
13
samples/client/others/rust/hyper/composed-oneof/docs/ObjB.md
Normal file
13
samples/client/others/rust/hyper/composed-oneof/docs/ObjB.md
Normal file
@ -0,0 +1,13 @@
|
||||
# ObjB
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**realtype** | Option<**String**> | | [optional]
|
||||
**description** | Option<**String**> | | [optional]
|
||||
**code** | Option<**i32**> | | [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)
|
||||
|
||||
|
12
samples/client/others/rust/hyper/composed-oneof/docs/ObjC.md
Normal file
12
samples/client/others/rust/hyper/composed-oneof/docs/ObjC.md
Normal file
@ -0,0 +1,12 @@
|
||||
# ObjC
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**realtype** | Option<**String**> | | [optional]
|
||||
**state** | Option<**String**> | | [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)
|
||||
|
||||
|
12
samples/client/others/rust/hyper/composed-oneof/docs/ObjD.md
Normal file
12
samples/client/others/rust/hyper/composed-oneof/docs/ObjD.md
Normal file
@ -0,0 +1,12 @@
|
||||
# ObjD
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**realtype** | Option<**String**> | | [optional]
|
||||
**color** | Option<**String**> | | [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)
|
||||
|
||||
|
57
samples/client/others/rust/hyper/composed-oneof/git_push.sh
Normal file
57
samples/client/others/rust/hyper/composed-oneof/git_push.sh
Normal file
@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="github.com"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=$(git remote)
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
@ -0,0 +1,24 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use hyper;
|
||||
use super::configuration::Configuration;
|
||||
|
||||
pub struct APIClient {
|
||||
default_api: Box<dyn crate::apis::DefaultApi>,
|
||||
}
|
||||
|
||||
impl APIClient {
|
||||
pub fn new<C: hyper::client::connect::Connect>(configuration: Configuration<C>) -> APIClient
|
||||
where C: Clone + std::marker::Send + Sync + 'static {
|
||||
let rc = Rc::new(configuration);
|
||||
|
||||
APIClient {
|
||||
default_api: Box::new(crate::apis::DefaultApiClient::new(rc.clone())),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_api(&self) -> &dyn crate::apis::DefaultApi{
|
||||
self.default_api.as_ref()
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* oneOf test
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use hyper;
|
||||
|
||||
pub struct Configuration<C: hyper::client::connect::Connect>
|
||||
where C: Clone + std::marker::Send + Sync + 'static {
|
||||
pub base_path: String,
|
||||
pub user_agent: Option<String>,
|
||||
pub client: hyper::client::Client<C>,
|
||||
pub basic_auth: Option<BasicAuth>,
|
||||
pub oauth_access_token: Option<String>,
|
||||
pub api_key: Option<ApiKey>,
|
||||
// TODO: take an oauth2 token source, similar to the go one
|
||||
}
|
||||
|
||||
pub type BasicAuth = (String, Option<String>);
|
||||
|
||||
pub struct ApiKey {
|
||||
pub prefix: Option<String>,
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
impl<C: hyper::client::connect::Connect> Configuration<C>
|
||||
where C: Clone + std::marker::Send + Sync {
|
||||
pub fn new(client: hyper::client::Client<C>) -> Configuration<C> {
|
||||
Configuration {
|
||||
base_path: "http://localhost:8000".to_owned(),
|
||||
user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()),
|
||||
client,
|
||||
basic_auth: None,
|
||||
oauth_access_token: None,
|
||||
api_key: None,
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* oneOf test
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::borrow::Borrow;
|
||||
use std::pin::Pin;
|
||||
#[allow(unused_imports)]
|
||||
use std::option::Option;
|
||||
|
||||
use hyper;
|
||||
use futures::Future;
|
||||
|
||||
use super::{Error, configuration};
|
||||
use super::request as __internal_request;
|
||||
|
||||
pub struct DefaultApiClient<C: hyper::client::connect::Connect>
|
||||
where C: Clone + std::marker::Send + Sync + 'static {
|
||||
configuration: Rc<configuration::Configuration<C>>,
|
||||
}
|
||||
|
||||
impl<C: hyper::client::connect::Connect> DefaultApiClient<C>
|
||||
where C: Clone + std::marker::Send + Sync {
|
||||
pub fn new(configuration: Rc<configuration::Configuration<C>>) -> DefaultApiClient<C> {
|
||||
DefaultApiClient {
|
||||
configuration,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait DefaultApi {
|
||||
fn create_state(&self, create_state_request: crate::models::CreateStateRequest) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>;
|
||||
fn get_state(&self, ) -> Pin<Box<dyn Future<Output = Result<crate::models::GetState200Response, Error>>>>;
|
||||
}
|
||||
|
||||
impl<C: hyper::client::connect::Connect>DefaultApi for DefaultApiClient<C>
|
||||
where C: Clone + std::marker::Send + Sync {
|
||||
#[allow(unused_mut)]
|
||||
fn create_state(&self, create_state_request: crate::models::CreateStateRequest) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
|
||||
let mut req = __internal_request::Request::new(hyper::Method::POST, "/state".to_string())
|
||||
;
|
||||
req = req.with_body_param(create_state_request);
|
||||
req = req.returns_nothing();
|
||||
|
||||
req.execute(self.configuration.borrow())
|
||||
}
|
||||
|
||||
#[allow(unused_mut)]
|
||||
fn get_state(&self, ) -> Pin<Box<dyn Future<Output = Result<crate::models::GetState200Response, Error>>>> {
|
||||
let mut req = __internal_request::Request::new(hyper::Method::GET, "/state".to_string())
|
||||
;
|
||||
|
||||
req.execute(self.configuration.borrow())
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
use http;
|
||||
use hyper;
|
||||
use serde_json;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
Api(ApiError),
|
||||
Header(hyper::http::header::InvalidHeaderValue),
|
||||
Http(http::Error),
|
||||
Hyper(hyper::Error),
|
||||
Serde(serde_json::Error),
|
||||
UriError(http::uri::InvalidUri),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ApiError {
|
||||
pub code: hyper::StatusCode,
|
||||
pub body: hyper::body::Body,
|
||||
}
|
||||
|
||||
impl From<(hyper::StatusCode, hyper::body::Body)> for Error {
|
||||
fn from(e: (hyper::StatusCode, hyper::body::Body)) -> Self {
|
||||
Error::Api(ApiError {
|
||||
code: e.0,
|
||||
body: e.1,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl From<http::Error> for Error {
|
||||
fn from(e: http::Error) -> Self {
|
||||
return Error::Http(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<hyper::Error> for Error {
|
||||
fn from(e: hyper::Error) -> Self {
|
||||
return Error::Hyper(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<serde_json::Error> for Error {
|
||||
fn from(e: serde_json::Error) -> Self {
|
||||
return Error::Serde(e)
|
||||
}
|
||||
}
|
||||
|
||||
mod request;
|
||||
|
||||
mod default_api;
|
||||
pub use self::default_api::{ DefaultApi, DefaultApiClient };
|
||||
|
||||
pub mod configuration;
|
||||
pub mod client;
|
@ -0,0 +1,242 @@
|
||||
use std::collections::HashMap;
|
||||
use std::pin::Pin;
|
||||
|
||||
use futures;
|
||||
use futures::Future;
|
||||
use futures::future::*;
|
||||
use hyper;
|
||||
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, HeaderValue, USER_AGENT};
|
||||
use serde;
|
||||
use serde_json;
|
||||
|
||||
use super::{configuration, Error};
|
||||
|
||||
pub(crate) struct ApiKey {
|
||||
pub in_header: bool,
|
||||
pub in_query: bool,
|
||||
pub param_name: String,
|
||||
}
|
||||
|
||||
impl ApiKey {
|
||||
fn key(&self, prefix: &Option<String>, key: &str) -> String {
|
||||
match prefix {
|
||||
None => key.to_owned(),
|
||||
Some(ref prefix) => format!("{} {}", prefix, key),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) enum Auth {
|
||||
None,
|
||||
ApiKey(ApiKey),
|
||||
Basic,
|
||||
Oauth,
|
||||
}
|
||||
|
||||
/// If the authorization type is unspecified then it will be automatically detected based
|
||||
/// on the configuration. This functionality is useful when the OpenAPI definition does not
|
||||
/// include an authorization scheme.
|
||||
pub(crate) struct Request {
|
||||
auth: Option<Auth>,
|
||||
method: hyper::Method,
|
||||
path: String,
|
||||
query_params: HashMap<String, String>,
|
||||
no_return_type: bool,
|
||||
path_params: HashMap<String, String>,
|
||||
form_params: HashMap<String, String>,
|
||||
header_params: HashMap<String, String>,
|
||||
// TODO: multiple body params are possible technically, but not supported here.
|
||||
serialized_body: Option<String>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl Request {
|
||||
pub fn new(method: hyper::Method, path: String) -> Self {
|
||||
Request {
|
||||
auth: None,
|
||||
method,
|
||||
path,
|
||||
query_params: HashMap::new(),
|
||||
path_params: HashMap::new(),
|
||||
form_params: HashMap::new(),
|
||||
header_params: HashMap::new(),
|
||||
serialized_body: None,
|
||||
no_return_type: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_body_param<T: serde::Serialize>(mut self, param: T) -> Self {
|
||||
self.serialized_body = Some(serde_json::to_string(¶m).unwrap());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_header_param(mut self, basename: String, param: String) -> Self {
|
||||
self.header_params.insert(basename, param);
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn with_query_param(mut self, basename: String, param: String) -> Self {
|
||||
self.query_params.insert(basename, param);
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn with_path_param(mut self, basename: String, param: String) -> Self {
|
||||
self.path_params.insert(basename, param);
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn with_form_param(mut self, basename: String, param: String) -> Self {
|
||||
self.form_params.insert(basename, param);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn returns_nothing(mut self) -> Self {
|
||||
self.no_return_type = true;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_auth(mut self, auth: Auth) -> Self {
|
||||
self.auth = Some(auth);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn execute<'a, C, U>(
|
||||
self,
|
||||
conf: &configuration::Configuration<C>,
|
||||
) -> Pin<Box<dyn Future<Output=Result<U, Error>> + 'a>>
|
||||
where
|
||||
C: hyper::client::connect::Connect + Clone + std::marker::Send + Sync,
|
||||
U: Sized + std::marker::Send + 'a,
|
||||
for<'de> U: serde::Deserialize<'de>,
|
||||
{
|
||||
let mut query_string = ::url::form_urlencoded::Serializer::new("".to_owned());
|
||||
|
||||
let mut path = self.path;
|
||||
for (k, v) in self.path_params {
|
||||
// replace {id} with the value of the id path param
|
||||
path = path.replace(&format!("{{{}}}", k), &v);
|
||||
}
|
||||
|
||||
for (key, val) in self.query_params {
|
||||
query_string.append_pair(&key, &val);
|
||||
}
|
||||
|
||||
let mut uri_str = format!("{}{}", conf.base_path, path);
|
||||
|
||||
let query_string_str = query_string.finish();
|
||||
if !query_string_str.is_empty() {
|
||||
uri_str += "?";
|
||||
uri_str += &query_string_str;
|
||||
}
|
||||
let uri: hyper::Uri = match uri_str.parse() {
|
||||
Err(e) => return Box::pin(futures::future::err(Error::UriError(e))),
|
||||
Ok(u) => u,
|
||||
};
|
||||
|
||||
let mut req_builder = hyper::Request::builder()
|
||||
.uri(uri)
|
||||
.method(self.method);
|
||||
|
||||
// Detect the authorization type if it hasn't been set.
|
||||
let auth = self.auth.unwrap_or_else(||
|
||||
if conf.api_key.is_some() {
|
||||
panic!("Cannot automatically set the API key from the configuration, it must be specified in the OpenAPI definition")
|
||||
} else if conf.oauth_access_token.is_some() {
|
||||
Auth::Oauth
|
||||
} else if conf.basic_auth.is_some() {
|
||||
Auth::Basic
|
||||
} else {
|
||||
Auth::None
|
||||
}
|
||||
);
|
||||
match auth {
|
||||
Auth::ApiKey(apikey) => {
|
||||
if let Some(ref key) = conf.api_key {
|
||||
let val = apikey.key(&key.prefix, &key.key);
|
||||
if apikey.in_query {
|
||||
query_string.append_pair(&apikey.param_name, &val);
|
||||
}
|
||||
if apikey.in_header {
|
||||
req_builder = req_builder.header(&apikey.param_name, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
Auth::Basic => {
|
||||
if let Some(ref auth_conf) = conf.basic_auth {
|
||||
let mut text = auth_conf.0.clone();
|
||||
text.push(':');
|
||||
if let Some(ref pass) = auth_conf.1 {
|
||||
text.push_str(&pass[..]);
|
||||
}
|
||||
let encoded = base64::encode(&text);
|
||||
req_builder = req_builder.header(AUTHORIZATION, encoded);
|
||||
}
|
||||
}
|
||||
Auth::Oauth => {
|
||||
if let Some(ref token) = conf.oauth_access_token {
|
||||
let text = "Bearer ".to_owned() + token;
|
||||
req_builder = req_builder.header(AUTHORIZATION, text);
|
||||
}
|
||||
}
|
||||
Auth::None => {}
|
||||
}
|
||||
|
||||
if let Some(ref user_agent) = conf.user_agent {
|
||||
req_builder = req_builder.header(USER_AGENT, match HeaderValue::from_str(user_agent) {
|
||||
Ok(header_value) => header_value,
|
||||
Err(e) => return Box::pin(futures::future::err(super::Error::Header(e)))
|
||||
});
|
||||
}
|
||||
|
||||
for (k, v) in self.header_params {
|
||||
req_builder = req_builder.header(&k, v);
|
||||
}
|
||||
|
||||
let req_headers = req_builder.headers_mut().unwrap();
|
||||
let request_result = if self.form_params.len() > 0 {
|
||||
req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/x-www-form-urlencoded"));
|
||||
let mut enc = ::url::form_urlencoded::Serializer::new("".to_owned());
|
||||
for (k, v) in self.form_params {
|
||||
enc.append_pair(&k, &v);
|
||||
}
|
||||
req_builder.body(hyper::Body::from(enc.finish()))
|
||||
} else if let Some(body) = self.serialized_body {
|
||||
req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
|
||||
req_headers.insert(CONTENT_LENGTH, body.len().into());
|
||||
req_builder.body(hyper::Body::from(body))
|
||||
} else {
|
||||
req_builder.body(hyper::Body::default())
|
||||
};
|
||||
let request = match request_result {
|
||||
Ok(request) => request,
|
||||
Err(e) => return Box::pin(futures::future::err(Error::from(e)))
|
||||
};
|
||||
|
||||
let no_return_type = self.no_return_type;
|
||||
Box::pin(conf.client
|
||||
.request(request)
|
||||
.map_err(|e| Error::from(e))
|
||||
.and_then(move |response| {
|
||||
let status = response.status();
|
||||
if !status.is_success() {
|
||||
futures::future::err::<U, Error>(Error::from((status, response.into_body()))).boxed()
|
||||
} else if no_return_type {
|
||||
// This is a hack; if there's no_ret_type, U is (), but serde_json gives an
|
||||
// error when deserializing "" into (), so deserialize 'null' into it
|
||||
// instead.
|
||||
// An alternate option would be to require U: Default, and then return
|
||||
// U::default() here instead since () implements that, but then we'd
|
||||
// need to impl default for all models.
|
||||
futures::future::ok::<U, Error>(serde_json::from_str("null").expect("serde null value")).boxed()
|
||||
} else {
|
||||
hyper::body::to_bytes(response.into_body())
|
||||
.map(|bytes| serde_json::from_slice(&bytes.unwrap()))
|
||||
.map_err(|e| Error::from(e)).boxed()
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
11
samples/client/others/rust/hyper/composed-oneof/src/lib.rs
Normal file
11
samples/client/others/rust/hyper/composed-oneof/src/lib.rs
Normal file
@ -0,0 +1,11 @@
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
extern crate url;
|
||||
extern crate hyper;
|
||||
extern crate futures;
|
||||
|
||||
pub mod apis;
|
||||
pub mod models;
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* oneOf test
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use super::ObjA;
|
||||
use super::ObjB;
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "realtype")]
|
||||
pub enum CreateStateRequest {
|
||||
ObjA(Box<ObjA>),
|
||||
ObjB(Box<ObjB>),
|
||||
}
|
||||
|
||||
impl Default for CreateStateRequest {
|
||||
fn default() -> Self {
|
||||
Self::ObjA(Box::default())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* oneOf test
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use super::ObjA;
|
||||
use super::ObjB;
|
||||
use super::ObjC;
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "realtype")]
|
||||
pub enum CustomOneOfArraySchemaInner {
|
||||
ObjA(Box<ObjA>),
|
||||
ObjB(Box<ObjB>),
|
||||
ObjC(Box<ObjC>),
|
||||
}
|
||||
|
||||
impl Default for CustomOneOfArraySchemaInner {
|
||||
fn default() -> Self {
|
||||
Self::ObjA(Box::default())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* oneOf test
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use super::ObjA;
|
||||
use super::ObjB;
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "realtype")]
|
||||
pub enum CustomOneOfSchema {
|
||||
ObjA(Box<ObjA>),
|
||||
ObjB(Box<ObjB>),
|
||||
}
|
||||
|
||||
impl Default for CustomOneOfSchema {
|
||||
fn default() -> Self {
|
||||
Self::ObjA(Box::default())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* oneOf test
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use super::ObjA;
|
||||
use super::ObjB;
|
||||
use super::ObjD;
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "realtype")]
|
||||
pub enum GetState200Response {
|
||||
ObjA(Box<ObjA>),
|
||||
ObjB(Box<ObjB>),
|
||||
ObjD(Box<ObjD>),
|
||||
}
|
||||
|
||||
impl Default for GetState200Response {
|
||||
fn default() -> Self {
|
||||
Self::ObjA(Box::default())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
pub mod create_state_request;
|
||||
pub use self::create_state_request::CreateStateRequest;
|
||||
pub mod custom_one_of_array_schema_inner;
|
||||
pub use self::custom_one_of_array_schema_inner::CustomOneOfArraySchemaInner;
|
||||
pub mod custom_one_of_schema;
|
||||
pub use self::custom_one_of_schema::CustomOneOfSchema;
|
||||
pub mod get_state_200_response;
|
||||
pub use self::get_state_200_response::GetState200Response;
|
||||
pub mod obj_a;
|
||||
pub use self::obj_a::ObjA;
|
||||
pub mod obj_b;
|
||||
pub use self::obj_b::ObjB;
|
||||
pub mod obj_c;
|
||||
pub use self::obj_c::ObjC;
|
||||
pub mod obj_d;
|
||||
pub use self::obj_d::ObjD;
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* oneOf test
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ObjA {
|
||||
#[serde(rename = "realtype", skip_serializing_if = "Option::is_none")]
|
||||
pub realtype: Option<String>,
|
||||
#[serde(rename = "message", skip_serializing_if = "Option::is_none")]
|
||||
pub message: Option<String>,
|
||||
}
|
||||
|
||||
impl ObjA {
|
||||
pub fn new() -> ObjA {
|
||||
ObjA {
|
||||
realtype: None,
|
||||
message: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* oneOf test
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ObjB {
|
||||
#[serde(rename = "realtype", skip_serializing_if = "Option::is_none")]
|
||||
pub realtype: Option<String>,
|
||||
#[serde(rename = "description", skip_serializing_if = "Option::is_none")]
|
||||
pub description: Option<String>,
|
||||
#[serde(rename = "code", skip_serializing_if = "Option::is_none")]
|
||||
pub code: Option<i32>,
|
||||
}
|
||||
|
||||
impl ObjB {
|
||||
pub fn new() -> ObjB {
|
||||
ObjB {
|
||||
realtype: None,
|
||||
description: None,
|
||||
code: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* oneOf test
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ObjC {
|
||||
#[serde(rename = "realtype", skip_serializing_if = "Option::is_none")]
|
||||
pub realtype: Option<String>,
|
||||
#[serde(rename = "state", skip_serializing_if = "Option::is_none")]
|
||||
pub state: Option<String>,
|
||||
}
|
||||
|
||||
impl ObjC {
|
||||
pub fn new() -> ObjC {
|
||||
ObjC {
|
||||
realtype: None,
|
||||
state: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* oneOf test
|
||||
*
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ObjD {
|
||||
#[serde(rename = "realtype", skip_serializing_if = "Option::is_none")]
|
||||
pub realtype: Option<String>,
|
||||
#[serde(rename = "color", skip_serializing_if = "Option::is_none")]
|
||||
pub color: Option<String>,
|
||||
}
|
||||
|
||||
impl ObjD {
|
||||
pub fn new() -> ObjD {
|
||||
ObjD {
|
||||
realtype: None,
|
||||
color: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
3
samples/client/others/rust/hyper/oneOf/.gitignore
vendored
Normal file
3
samples/client/others/rust/hyper/oneOf/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/target/
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
@ -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
|
@ -0,0 +1,51 @@
|
||||
.gitignore
|
||||
.travis.yml
|
||||
Cargo.toml
|
||||
README.md
|
||||
docs/Addressable.md
|
||||
docs/Apple.md
|
||||
docs/Banana.md
|
||||
docs/Bar.md
|
||||
docs/BarApi.md
|
||||
docs/BarCreate.md
|
||||
docs/BarRef.md
|
||||
docs/BarRefOrValue.md
|
||||
docs/Entity.md
|
||||
docs/EntityRef.md
|
||||
docs/Extensible.md
|
||||
docs/Foo.md
|
||||
docs/FooApi.md
|
||||
docs/FooRef.md
|
||||
docs/FooRefOrValue.md
|
||||
docs/Fruit.md
|
||||
docs/FruitType.md
|
||||
docs/Pasta.md
|
||||
docs/Pizza.md
|
||||
docs/PizzaSpeziale.md
|
||||
git_push.sh
|
||||
src/apis/bar_api.rs
|
||||
src/apis/client.rs
|
||||
src/apis/configuration.rs
|
||||
src/apis/foo_api.rs
|
||||
src/apis/mod.rs
|
||||
src/apis/request.rs
|
||||
src/lib.rs
|
||||
src/models/addressable.rs
|
||||
src/models/apple.rs
|
||||
src/models/banana.rs
|
||||
src/models/bar.rs
|
||||
src/models/bar_create.rs
|
||||
src/models/bar_ref.rs
|
||||
src/models/bar_ref_or_value.rs
|
||||
src/models/entity.rs
|
||||
src/models/entity_ref.rs
|
||||
src/models/extensible.rs
|
||||
src/models/foo.rs
|
||||
src/models/foo_ref.rs
|
||||
src/models/foo_ref_or_value.rs
|
||||
src/models/fruit.rs
|
||||
src/models/fruit_type.rs
|
||||
src/models/mod.rs
|
||||
src/models/pasta.rs
|
||||
src/models/pizza.rs
|
||||
src/models/pizza_speziale.rs
|
@ -0,0 +1 @@
|
||||
7.3.0-SNAPSHOT
|
1
samples/client/others/rust/hyper/oneOf/.travis.yml
Normal file
1
samples/client/others/rust/hyper/oneOf/.travis.yml
Normal file
@ -0,0 +1 @@
|
||||
language: rust
|
20
samples/client/others/rust/hyper/oneOf/Cargo.toml
Normal file
20
samples/client/others/rust/hyper/oneOf/Cargo.toml
Normal file
@ -0,0 +1,20 @@
|
||||
[package]
|
||||
name = "oneof-hyper"
|
||||
version = "0.0.1"
|
||||
authors = ["OpenAPI Generator team and contributors"]
|
||||
description = "This tests for a oneOf interface representation "
|
||||
# Override this license by providing a License Object in the OpenAPI.
|
||||
license = "Unlicense"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = "^1.0"
|
||||
serde_derive = "^1.0"
|
||||
serde_json = "^1.0"
|
||||
url = "^2.2"
|
||||
uuid = { version = "^1.0", features = ["serde", "v4"] }
|
||||
hyper = { version = "~0.14", features = ["full"] }
|
||||
hyper-tls = "~0.5"
|
||||
http = "~0.2"
|
||||
base64 = "~0.7.0"
|
||||
futures = "^0.3"
|
65
samples/client/others/rust/hyper/oneOf/README.md
Normal file
65
samples/client/others/rust/hyper/oneOf/README.md
Normal file
@ -0,0 +1,65 @@
|
||||
# Rust API client for oneof-hyper
|
||||
|
||||
This tests for a oneOf interface representation
|
||||
|
||||
|
||||
|
||||
## 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: 0.0.1
|
||||
- Package version: 0.0.1
|
||||
- Build package: `org.openapitools.codegen.languages.RustClientCodegen`
|
||||
|
||||
## Installation
|
||||
|
||||
Put the package under your project folder in a directory named `oneof-hyper` and add the following to `Cargo.toml` under `[dependencies]`:
|
||||
|
||||
```
|
||||
oneof-hyper = { path = "./oneof-hyper" }
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *http://localhost:8080*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*BarApi* | [**create_bar**](docs/BarApi.md#create_bar) | **Post** /bar | Create a Bar
|
||||
*FooApi* | [**create_foo**](docs/FooApi.md#create_foo) | **Post** /foo | Create a Foo
|
||||
*FooApi* | [**get_all_foos**](docs/FooApi.md#get_all_foos) | **Get** /foo | GET all Foos
|
||||
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
- [Addressable](docs/Addressable.md)
|
||||
- [Apple](docs/Apple.md)
|
||||
- [Banana](docs/Banana.md)
|
||||
- [Bar](docs/Bar.md)
|
||||
- [BarCreate](docs/BarCreate.md)
|
||||
- [BarRef](docs/BarRef.md)
|
||||
- [BarRefOrValue](docs/BarRefOrValue.md)
|
||||
- [Entity](docs/Entity.md)
|
||||
- [EntityRef](docs/EntityRef.md)
|
||||
- [Extensible](docs/Extensible.md)
|
||||
- [Foo](docs/Foo.md)
|
||||
- [FooRef](docs/FooRef.md)
|
||||
- [FooRefOrValue](docs/FooRefOrValue.md)
|
||||
- [Fruit](docs/Fruit.md)
|
||||
- [FruitType](docs/FruitType.md)
|
||||
- [Pasta](docs/Pasta.md)
|
||||
- [Pizza](docs/Pizza.md)
|
||||
- [PizzaSpeziale](docs/PizzaSpeziale.md)
|
||||
|
||||
|
||||
To get access to the crate's generated documentation, use:
|
||||
|
||||
```
|
||||
cargo doc --open
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
|
||||
|
12
samples/client/others/rust/hyper/oneOf/docs/Addressable.md
Normal file
12
samples/client/others/rust/hyper/oneOf/docs/Addressable.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Addressable
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**href** | Option<**String**> | Hyperlink reference | [optional]
|
||||
**id** | Option<**String**> | unique identifier | [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)
|
||||
|
||||
|
11
samples/client/others/rust/hyper/oneOf/docs/Apple.md
Normal file
11
samples/client/others/rust/hyper/oneOf/docs/Apple.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Apple
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**seeds** | **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)
|
||||
|
||||
|
11
samples/client/others/rust/hyper/oneOf/docs/Banana.md
Normal file
11
samples/client/others/rust/hyper/oneOf/docs/Banana.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Banana
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**length** | **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)
|
||||
|
||||
|
18
samples/client/others/rust/hyper/oneOf/docs/Bar.md
Normal file
18
samples/client/others/rust/hyper/oneOf/docs/Bar.md
Normal file
@ -0,0 +1,18 @@
|
||||
# Bar
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **String** | |
|
||||
**bar_prop_a** | Option<**String**> | | [optional]
|
||||
**foo_prop_b** | Option<**String**> | | [optional]
|
||||
**foo** | Option<[**crate::models::FooRefOrValue**](FooRefOrValue.md)> | | [optional]
|
||||
**href** | Option<**String**> | Hyperlink reference | [optional]
|
||||
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
|
||||
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
|
||||
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
37
samples/client/others/rust/hyper/oneOf/docs/BarApi.md
Normal file
37
samples/client/others/rust/hyper/oneOf/docs/BarApi.md
Normal file
@ -0,0 +1,37 @@
|
||||
# \BarApi
|
||||
|
||||
All URIs are relative to *http://localhost:8080*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**create_bar**](BarApi.md#create_bar) | **Post** /bar | Create a Bar
|
||||
|
||||
|
||||
|
||||
## create_bar
|
||||
|
||||
> crate::models::Bar create_bar(bar_create)
|
||||
Create a Bar
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**bar_create** | [**BarCreate**](BarCreate.md) | | [required] |
|
||||
|
||||
### Return type
|
||||
|
||||
[**crate::models::Bar**](Bar.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **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)
|
||||
|
18
samples/client/others/rust/hyper/oneOf/docs/BarCreate.md
Normal file
18
samples/client/others/rust/hyper/oneOf/docs/BarCreate.md
Normal file
@ -0,0 +1,18 @@
|
||||
# BarCreate
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar_prop_a** | Option<**String**> | | [optional]
|
||||
**foo_prop_b** | Option<**String**> | | [optional]
|
||||
**foo** | Option<[**crate::models::FooRefOrValue**](FooRefOrValue.md)> | | [optional]
|
||||
**href** | Option<**String**> | Hyperlink reference | [optional]
|
||||
**id** | Option<**String**> | unique identifier | [optional]
|
||||
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
|
||||
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
|
||||
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
17
samples/client/others/rust/hyper/oneOf/docs/BarRef.md
Normal file
17
samples/client/others/rust/hyper/oneOf/docs/BarRef.md
Normal file
@ -0,0 +1,17 @@
|
||||
# BarRef
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | Option<**String**> | Name of the related entity. | [optional]
|
||||
**at_referred_type** | Option<**String**> | The actual type of the target instance when needed for disambiguation. | [optional]
|
||||
**href** | Option<**String**> | Hyperlink reference | [optional]
|
||||
**id** | Option<**String**> | unique identifier | [optional]
|
||||
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
|
||||
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
|
||||
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
|
||||
|
||||
[[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
samples/client/others/rust/hyper/oneOf/docs/BarRefOrValue.md
Normal file
12
samples/client/others/rust/hyper/oneOf/docs/BarRefOrValue.md
Normal file
@ -0,0 +1,12 @@
|
||||
# BarRefOrValue
|
||||
|
||||
## Enum Variants
|
||||
|
||||
| Name | Description |
|
||||
|---- | -----|
|
||||
| Bar | |
|
||||
| BarRef | |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
10
samples/client/others/rust/hyper/oneOf/docs/Entity.md
Normal file
10
samples/client/others/rust/hyper/oneOf/docs/Entity.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Entity
|
||||
|
||||
## Enum Variants
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
10
samples/client/others/rust/hyper/oneOf/docs/EntityRef.md
Normal file
10
samples/client/others/rust/hyper/oneOf/docs/EntityRef.md
Normal file
@ -0,0 +1,10 @@
|
||||
# EntityRef
|
||||
|
||||
## Enum Variants
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
|
||||
[[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
samples/client/others/rust/hyper/oneOf/docs/Extensible.md
Normal file
13
samples/client/others/rust/hyper/oneOf/docs/Extensible.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Extensible
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
|
||||
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
|
||||
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
17
samples/client/others/rust/hyper/oneOf/docs/Foo.md
Normal file
17
samples/client/others/rust/hyper/oneOf/docs/Foo.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Foo
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**foo_prop_a** | Option<**String**> | | [optional]
|
||||
**foo_prop_b** | Option<**String**> | | [optional]
|
||||
**href** | Option<**String**> | Hyperlink reference | [optional]
|
||||
**id** | Option<**String**> | unique identifier | [optional]
|
||||
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
|
||||
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
|
||||
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
63
samples/client/others/rust/hyper/oneOf/docs/FooApi.md
Normal file
63
samples/client/others/rust/hyper/oneOf/docs/FooApi.md
Normal file
@ -0,0 +1,63 @@
|
||||
# \FooApi
|
||||
|
||||
All URIs are relative to *http://localhost:8080*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**create_foo**](FooApi.md#create_foo) | **Post** /foo | Create a Foo
|
||||
[**get_all_foos**](FooApi.md#get_all_foos) | **Get** /foo | GET all Foos
|
||||
|
||||
|
||||
|
||||
## create_foo
|
||||
|
||||
> crate::models::FooRefOrValue create_foo(foo)
|
||||
Create a Foo
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Required | Notes
|
||||
------------- | ------------- | ------------- | ------------- | -------------
|
||||
**foo** | Option<[**Foo**](Foo.md)> | The Foo to be created | |
|
||||
|
||||
### Return type
|
||||
|
||||
[**crate::models::FooRefOrValue**](FooRefOrValue.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json;charset=utf-8
|
||||
- **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_all_foos
|
||||
|
||||
> Vec<crate::models::FooRefOrValue> get_all_foos()
|
||||
GET all Foos
|
||||
|
||||
### Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
[**Vec<crate::models::FooRefOrValue>**](FooRefOrValue.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json;charset=utf-8
|
||||
|
||||
[[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)
|
||||
|
18
samples/client/others/rust/hyper/oneOf/docs/FooRef.md
Normal file
18
samples/client/others/rust/hyper/oneOf/docs/FooRef.md
Normal file
@ -0,0 +1,18 @@
|
||||
# FooRef
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**fooref_prop_a** | Option<**String**> | | [optional]
|
||||
**name** | Option<**String**> | Name of the related entity. | [optional]
|
||||
**at_referred_type** | Option<**String**> | The actual type of the target instance when needed for disambiguation. | [optional]
|
||||
**href** | Option<**String**> | Hyperlink reference | [optional]
|
||||
**id** | Option<**String**> | unique identifier | [optional]
|
||||
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
|
||||
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
|
||||
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
10
samples/client/others/rust/hyper/oneOf/docs/FooRefOrValue.md
Normal file
10
samples/client/others/rust/hyper/oneOf/docs/FooRefOrValue.md
Normal file
@ -0,0 +1,10 @@
|
||||
# FooRefOrValue
|
||||
|
||||
## Enum Variants
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
10
samples/client/others/rust/hyper/oneOf/docs/Fruit.md
Normal file
10
samples/client/others/rust/hyper/oneOf/docs/Fruit.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Fruit
|
||||
|
||||
## Enum Variants
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
|
||||
[[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
samples/client/others/rust/hyper/oneOf/docs/FruitType.md
Normal file
13
samples/client/others/rust/hyper/oneOf/docs/FruitType.md
Normal file
@ -0,0 +1,13 @@
|
||||
# FruitType
|
||||
|
||||
## Enum Variants
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| Apple | APPLE |
|
||||
| Banana | BANANA |
|
||||
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
16
samples/client/others/rust/hyper/oneOf/docs/Pasta.md
Normal file
16
samples/client/others/rust/hyper/oneOf/docs/Pasta.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Pasta
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**vendor** | Option<**String**> | | [optional]
|
||||
**href** | Option<**String**> | Hyperlink reference | [optional]
|
||||
**id** | Option<**String**> | unique identifier | [optional]
|
||||
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
|
||||
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
|
||||
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
16
samples/client/others/rust/hyper/oneOf/docs/Pizza.md
Normal file
16
samples/client/others/rust/hyper/oneOf/docs/Pizza.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Pizza
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**pizza_size** | Option<**f32**> | | [optional]
|
||||
**href** | Option<**String**> | Hyperlink reference | [optional]
|
||||
**id** | Option<**String**> | unique identifier | [optional]
|
||||
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
|
||||
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
|
||||
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
17
samples/client/others/rust/hyper/oneOf/docs/PizzaSpeziale.md
Normal file
17
samples/client/others/rust/hyper/oneOf/docs/PizzaSpeziale.md
Normal file
@ -0,0 +1,17 @@
|
||||
# PizzaSpeziale
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**toppings** | Option<**String**> | | [optional]
|
||||
**pizza_size** | Option<**f32**> | | [optional]
|
||||
**href** | Option<**String**> | Hyperlink reference | [optional]
|
||||
**id** | Option<**String**> | unique identifier | [optional]
|
||||
**at_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]
|
||||
**at_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]
|
||||
**at_type** | **String** | When sub-classing, this defines the sub-class Extensible name |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
57
samples/client/others/rust/hyper/oneOf/git_push.sh
Normal file
57
samples/client/others/rust/hyper/oneOf/git_push.sh
Normal file
@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="github.com"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=$(git remote)
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
46
samples/client/others/rust/hyper/oneOf/pom.xml
Normal file
46
samples/client/others/rust/hyper/oneOf/pom.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>RustHyperOneOfClientTests</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>Rust Hyper oneOf Client</name>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>bundle-test</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>cargo</executable>
|
||||
<arguments>
|
||||
<argument>test</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
52
samples/client/others/rust/hyper/oneOf/src/apis/bar_api.rs
Normal file
52
samples/client/others/rust/hyper/oneOf/src/apis/bar_api.rs
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::borrow::Borrow;
|
||||
use std::pin::Pin;
|
||||
#[allow(unused_imports)]
|
||||
use std::option::Option;
|
||||
|
||||
use hyper;
|
||||
use futures::Future;
|
||||
|
||||
use super::{Error, configuration};
|
||||
use super::request as __internal_request;
|
||||
|
||||
pub struct BarApiClient<C: hyper::client::connect::Connect>
|
||||
where C: Clone + std::marker::Send + Sync + 'static {
|
||||
configuration: Rc<configuration::Configuration<C>>,
|
||||
}
|
||||
|
||||
impl<C: hyper::client::connect::Connect> BarApiClient<C>
|
||||
where C: Clone + std::marker::Send + Sync {
|
||||
pub fn new(configuration: Rc<configuration::Configuration<C>>) -> BarApiClient<C> {
|
||||
BarApiClient {
|
||||
configuration,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BarApi {
|
||||
fn create_bar(&self, bar_create: crate::models::BarCreate) -> Pin<Box<dyn Future<Output = Result<crate::models::Bar, Error>>>>;
|
||||
}
|
||||
|
||||
impl<C: hyper::client::connect::Connect>BarApi for BarApiClient<C>
|
||||
where C: Clone + std::marker::Send + Sync {
|
||||
#[allow(unused_mut)]
|
||||
fn create_bar(&self, bar_create: crate::models::BarCreate) -> Pin<Box<dyn Future<Output = Result<crate::models::Bar, Error>>>> {
|
||||
let mut req = __internal_request::Request::new(hyper::Method::POST, "/bar".to_string())
|
||||
;
|
||||
req = req.with_body_param(bar_create);
|
||||
|
||||
req.execute(self.configuration.borrow())
|
||||
}
|
||||
|
||||
}
|
30
samples/client/others/rust/hyper/oneOf/src/apis/client.rs
Normal file
30
samples/client/others/rust/hyper/oneOf/src/apis/client.rs
Normal file
@ -0,0 +1,30 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use hyper;
|
||||
use super::configuration::Configuration;
|
||||
|
||||
pub struct APIClient {
|
||||
bar_api: Box<dyn crate::apis::BarApi>,
|
||||
foo_api: Box<dyn crate::apis::FooApi>,
|
||||
}
|
||||
|
||||
impl APIClient {
|
||||
pub fn new<C: hyper::client::connect::Connect>(configuration: Configuration<C>) -> APIClient
|
||||
where C: Clone + std::marker::Send + Sync + 'static {
|
||||
let rc = Rc::new(configuration);
|
||||
|
||||
APIClient {
|
||||
bar_api: Box::new(crate::apis::BarApiClient::new(rc.clone())),
|
||||
foo_api: Box::new(crate::apis::FooApiClient::new(rc.clone())),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bar_api(&self) -> &dyn crate::apis::BarApi{
|
||||
self.bar_api.as_ref()
|
||||
}
|
||||
|
||||
pub fn foo_api(&self) -> &dyn crate::apis::FooApi{
|
||||
self.foo_api.as_ref()
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use hyper;
|
||||
|
||||
pub struct Configuration<C: hyper::client::connect::Connect>
|
||||
where C: Clone + std::marker::Send + Sync + 'static {
|
||||
pub base_path: String,
|
||||
pub user_agent: Option<String>,
|
||||
pub client: hyper::client::Client<C>,
|
||||
pub basic_auth: Option<BasicAuth>,
|
||||
pub oauth_access_token: Option<String>,
|
||||
pub api_key: Option<ApiKey>,
|
||||
// TODO: take an oauth2 token source, similar to the go one
|
||||
}
|
||||
|
||||
pub type BasicAuth = (String, Option<String>);
|
||||
|
||||
pub struct ApiKey {
|
||||
pub prefix: Option<String>,
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
impl<C: hyper::client::connect::Connect> Configuration<C>
|
||||
where C: Clone + std::marker::Send + Sync {
|
||||
pub fn new(client: hyper::client::Client<C>) -> Configuration<C> {
|
||||
Configuration {
|
||||
base_path: "http://localhost:8080".to_owned(),
|
||||
user_agent: Some("OpenAPI-Generator/0.0.1/rust".to_owned()),
|
||||
client,
|
||||
basic_auth: None,
|
||||
oauth_access_token: None,
|
||||
api_key: None,
|
||||
}
|
||||
}
|
||||
}
|
61
samples/client/others/rust/hyper/oneOf/src/apis/foo_api.rs
Normal file
61
samples/client/others/rust/hyper/oneOf/src/apis/foo_api.rs
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::borrow::Borrow;
|
||||
use std::pin::Pin;
|
||||
#[allow(unused_imports)]
|
||||
use std::option::Option;
|
||||
|
||||
use hyper;
|
||||
use futures::Future;
|
||||
|
||||
use super::{Error, configuration};
|
||||
use super::request as __internal_request;
|
||||
|
||||
pub struct FooApiClient<C: hyper::client::connect::Connect>
|
||||
where C: Clone + std::marker::Send + Sync + 'static {
|
||||
configuration: Rc<configuration::Configuration<C>>,
|
||||
}
|
||||
|
||||
impl<C: hyper::client::connect::Connect> FooApiClient<C>
|
||||
where C: Clone + std::marker::Send + Sync {
|
||||
pub fn new(configuration: Rc<configuration::Configuration<C>>) -> FooApiClient<C> {
|
||||
FooApiClient {
|
||||
configuration,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait FooApi {
|
||||
fn create_foo(&self, foo: Option<crate::models::Foo>) -> Pin<Box<dyn Future<Output = Result<crate::models::FooRefOrValue, Error>>>>;
|
||||
fn get_all_foos(&self, ) -> Pin<Box<dyn Future<Output = Result<Vec<crate::models::FooRefOrValue>, Error>>>>;
|
||||
}
|
||||
|
||||
impl<C: hyper::client::connect::Connect>FooApi for FooApiClient<C>
|
||||
where C: Clone + std::marker::Send + Sync {
|
||||
#[allow(unused_mut)]
|
||||
fn create_foo(&self, foo: Option<crate::models::Foo>) -> Pin<Box<dyn Future<Output = Result<crate::models::FooRefOrValue, Error>>>> {
|
||||
let mut req = __internal_request::Request::new(hyper::Method::POST, "/foo".to_string())
|
||||
;
|
||||
req = req.with_body_param(foo);
|
||||
|
||||
req.execute(self.configuration.borrow())
|
||||
}
|
||||
|
||||
#[allow(unused_mut)]
|
||||
fn get_all_foos(&self, ) -> Pin<Box<dyn Future<Output = Result<Vec<crate::models::FooRefOrValue>, Error>>>> {
|
||||
let mut req = __internal_request::Request::new(hyper::Method::GET, "/foo".to_string())
|
||||
;
|
||||
|
||||
req.execute(self.configuration.borrow())
|
||||
}
|
||||
|
||||
}
|
56
samples/client/others/rust/hyper/oneOf/src/apis/mod.rs
Normal file
56
samples/client/others/rust/hyper/oneOf/src/apis/mod.rs
Normal file
@ -0,0 +1,56 @@
|
||||
use http;
|
||||
use hyper;
|
||||
use serde_json;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
Api(ApiError),
|
||||
Header(hyper::http::header::InvalidHeaderValue),
|
||||
Http(http::Error),
|
||||
Hyper(hyper::Error),
|
||||
Serde(serde_json::Error),
|
||||
UriError(http::uri::InvalidUri),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ApiError {
|
||||
pub code: hyper::StatusCode,
|
||||
pub body: hyper::body::Body,
|
||||
}
|
||||
|
||||
impl From<(hyper::StatusCode, hyper::body::Body)> for Error {
|
||||
fn from(e: (hyper::StatusCode, hyper::body::Body)) -> Self {
|
||||
Error::Api(ApiError {
|
||||
code: e.0,
|
||||
body: e.1,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl From<http::Error> for Error {
|
||||
fn from(e: http::Error) -> Self {
|
||||
return Error::Http(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<hyper::Error> for Error {
|
||||
fn from(e: hyper::Error) -> Self {
|
||||
return Error::Hyper(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<serde_json::Error> for Error {
|
||||
fn from(e: serde_json::Error) -> Self {
|
||||
return Error::Serde(e)
|
||||
}
|
||||
}
|
||||
|
||||
mod request;
|
||||
|
||||
mod bar_api;
|
||||
pub use self::bar_api::{ BarApi, BarApiClient };
|
||||
mod foo_api;
|
||||
pub use self::foo_api::{ FooApi, FooApiClient };
|
||||
|
||||
pub mod configuration;
|
||||
pub mod client;
|
242
samples/client/others/rust/hyper/oneOf/src/apis/request.rs
Normal file
242
samples/client/others/rust/hyper/oneOf/src/apis/request.rs
Normal file
@ -0,0 +1,242 @@
|
||||
use std::collections::HashMap;
|
||||
use std::pin::Pin;
|
||||
|
||||
use futures;
|
||||
use futures::Future;
|
||||
use futures::future::*;
|
||||
use hyper;
|
||||
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, HeaderValue, USER_AGENT};
|
||||
use serde;
|
||||
use serde_json;
|
||||
|
||||
use super::{configuration, Error};
|
||||
|
||||
pub(crate) struct ApiKey {
|
||||
pub in_header: bool,
|
||||
pub in_query: bool,
|
||||
pub param_name: String,
|
||||
}
|
||||
|
||||
impl ApiKey {
|
||||
fn key(&self, prefix: &Option<String>, key: &str) -> String {
|
||||
match prefix {
|
||||
None => key.to_owned(),
|
||||
Some(ref prefix) => format!("{} {}", prefix, key),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) enum Auth {
|
||||
None,
|
||||
ApiKey(ApiKey),
|
||||
Basic,
|
||||
Oauth,
|
||||
}
|
||||
|
||||
/// If the authorization type is unspecified then it will be automatically detected based
|
||||
/// on the configuration. This functionality is useful when the OpenAPI definition does not
|
||||
/// include an authorization scheme.
|
||||
pub(crate) struct Request {
|
||||
auth: Option<Auth>,
|
||||
method: hyper::Method,
|
||||
path: String,
|
||||
query_params: HashMap<String, String>,
|
||||
no_return_type: bool,
|
||||
path_params: HashMap<String, String>,
|
||||
form_params: HashMap<String, String>,
|
||||
header_params: HashMap<String, String>,
|
||||
// TODO: multiple body params are possible technically, but not supported here.
|
||||
serialized_body: Option<String>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl Request {
|
||||
pub fn new(method: hyper::Method, path: String) -> Self {
|
||||
Request {
|
||||
auth: None,
|
||||
method,
|
||||
path,
|
||||
query_params: HashMap::new(),
|
||||
path_params: HashMap::new(),
|
||||
form_params: HashMap::new(),
|
||||
header_params: HashMap::new(),
|
||||
serialized_body: None,
|
||||
no_return_type: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_body_param<T: serde::Serialize>(mut self, param: T) -> Self {
|
||||
self.serialized_body = Some(serde_json::to_string(¶m).unwrap());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_header_param(mut self, basename: String, param: String) -> Self {
|
||||
self.header_params.insert(basename, param);
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn with_query_param(mut self, basename: String, param: String) -> Self {
|
||||
self.query_params.insert(basename, param);
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn with_path_param(mut self, basename: String, param: String) -> Self {
|
||||
self.path_params.insert(basename, param);
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn with_form_param(mut self, basename: String, param: String) -> Self {
|
||||
self.form_params.insert(basename, param);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn returns_nothing(mut self) -> Self {
|
||||
self.no_return_type = true;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_auth(mut self, auth: Auth) -> Self {
|
||||
self.auth = Some(auth);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn execute<'a, C, U>(
|
||||
self,
|
||||
conf: &configuration::Configuration<C>,
|
||||
) -> Pin<Box<dyn Future<Output=Result<U, Error>> + 'a>>
|
||||
where
|
||||
C: hyper::client::connect::Connect + Clone + std::marker::Send + Sync,
|
||||
U: Sized + std::marker::Send + 'a,
|
||||
for<'de> U: serde::Deserialize<'de>,
|
||||
{
|
||||
let mut query_string = ::url::form_urlencoded::Serializer::new("".to_owned());
|
||||
|
||||
let mut path = self.path;
|
||||
for (k, v) in self.path_params {
|
||||
// replace {id} with the value of the id path param
|
||||
path = path.replace(&format!("{{{}}}", k), &v);
|
||||
}
|
||||
|
||||
for (key, val) in self.query_params {
|
||||
query_string.append_pair(&key, &val);
|
||||
}
|
||||
|
||||
let mut uri_str = format!("{}{}", conf.base_path, path);
|
||||
|
||||
let query_string_str = query_string.finish();
|
||||
if !query_string_str.is_empty() {
|
||||
uri_str += "?";
|
||||
uri_str += &query_string_str;
|
||||
}
|
||||
let uri: hyper::Uri = match uri_str.parse() {
|
||||
Err(e) => return Box::pin(futures::future::err(Error::UriError(e))),
|
||||
Ok(u) => u,
|
||||
};
|
||||
|
||||
let mut req_builder = hyper::Request::builder()
|
||||
.uri(uri)
|
||||
.method(self.method);
|
||||
|
||||
// Detect the authorization type if it hasn't been set.
|
||||
let auth = self.auth.unwrap_or_else(||
|
||||
if conf.api_key.is_some() {
|
||||
panic!("Cannot automatically set the API key from the configuration, it must be specified in the OpenAPI definition")
|
||||
} else if conf.oauth_access_token.is_some() {
|
||||
Auth::Oauth
|
||||
} else if conf.basic_auth.is_some() {
|
||||
Auth::Basic
|
||||
} else {
|
||||
Auth::None
|
||||
}
|
||||
);
|
||||
match auth {
|
||||
Auth::ApiKey(apikey) => {
|
||||
if let Some(ref key) = conf.api_key {
|
||||
let val = apikey.key(&key.prefix, &key.key);
|
||||
if apikey.in_query {
|
||||
query_string.append_pair(&apikey.param_name, &val);
|
||||
}
|
||||
if apikey.in_header {
|
||||
req_builder = req_builder.header(&apikey.param_name, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
Auth::Basic => {
|
||||
if let Some(ref auth_conf) = conf.basic_auth {
|
||||
let mut text = auth_conf.0.clone();
|
||||
text.push(':');
|
||||
if let Some(ref pass) = auth_conf.1 {
|
||||
text.push_str(&pass[..]);
|
||||
}
|
||||
let encoded = base64::encode(&text);
|
||||
req_builder = req_builder.header(AUTHORIZATION, encoded);
|
||||
}
|
||||
}
|
||||
Auth::Oauth => {
|
||||
if let Some(ref token) = conf.oauth_access_token {
|
||||
let text = "Bearer ".to_owned() + token;
|
||||
req_builder = req_builder.header(AUTHORIZATION, text);
|
||||
}
|
||||
}
|
||||
Auth::None => {}
|
||||
}
|
||||
|
||||
if let Some(ref user_agent) = conf.user_agent {
|
||||
req_builder = req_builder.header(USER_AGENT, match HeaderValue::from_str(user_agent) {
|
||||
Ok(header_value) => header_value,
|
||||
Err(e) => return Box::pin(futures::future::err(super::Error::Header(e)))
|
||||
});
|
||||
}
|
||||
|
||||
for (k, v) in self.header_params {
|
||||
req_builder = req_builder.header(&k, v);
|
||||
}
|
||||
|
||||
let req_headers = req_builder.headers_mut().unwrap();
|
||||
let request_result = if self.form_params.len() > 0 {
|
||||
req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/x-www-form-urlencoded"));
|
||||
let mut enc = ::url::form_urlencoded::Serializer::new("".to_owned());
|
||||
for (k, v) in self.form_params {
|
||||
enc.append_pair(&k, &v);
|
||||
}
|
||||
req_builder.body(hyper::Body::from(enc.finish()))
|
||||
} else if let Some(body) = self.serialized_body {
|
||||
req_headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
|
||||
req_headers.insert(CONTENT_LENGTH, body.len().into());
|
||||
req_builder.body(hyper::Body::from(body))
|
||||
} else {
|
||||
req_builder.body(hyper::Body::default())
|
||||
};
|
||||
let request = match request_result {
|
||||
Ok(request) => request,
|
||||
Err(e) => return Box::pin(futures::future::err(Error::from(e)))
|
||||
};
|
||||
|
||||
let no_return_type = self.no_return_type;
|
||||
Box::pin(conf.client
|
||||
.request(request)
|
||||
.map_err(|e| Error::from(e))
|
||||
.and_then(move |response| {
|
||||
let status = response.status();
|
||||
if !status.is_success() {
|
||||
futures::future::err::<U, Error>(Error::from((status, response.into_body()))).boxed()
|
||||
} else if no_return_type {
|
||||
// This is a hack; if there's no_ret_type, U is (), but serde_json gives an
|
||||
// error when deserializing "" into (), so deserialize 'null' into it
|
||||
// instead.
|
||||
// An alternate option would be to require U: Default, and then return
|
||||
// U::default() here instead since () implements that, but then we'd
|
||||
// need to impl default for all models.
|
||||
futures::future::ok::<U, Error>(serde_json::from_str("null").expect("serde null value")).boxed()
|
||||
} else {
|
||||
hyper::body::to_bytes(response.into_body())
|
||||
.map(|bytes| serde_json::from_slice(&bytes.unwrap()))
|
||||
.map_err(|e| Error::from(e)).boxed()
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
11
samples/client/others/rust/hyper/oneOf/src/lib.rs
Normal file
11
samples/client/others/rust/hyper/oneOf/src/lib.rs
Normal file
@ -0,0 +1,11 @@
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
extern crate url;
|
||||
extern crate hyper;
|
||||
extern crate futures;
|
||||
|
||||
pub mod apis;
|
||||
pub mod models;
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
/// Addressable : Base schema for addressable entities
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Addressable {
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
pub href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<String>,
|
||||
}
|
||||
|
||||
impl Addressable {
|
||||
/// Base schema for addressable entities
|
||||
pub fn new() -> Addressable {
|
||||
Addressable {
|
||||
href: None,
|
||||
id: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
28
samples/client/others/rust/hyper/oneOf/src/models/apple.rs
Normal file
28
samples/client/others/rust/hyper/oneOf/src/models/apple.rs
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Apple {
|
||||
#[serde(rename = "seeds")]
|
||||
pub seeds: i32,
|
||||
}
|
||||
|
||||
impl Apple {
|
||||
pub fn new(seeds: i32) -> Apple {
|
||||
Apple {
|
||||
seeds,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
28
samples/client/others/rust/hyper/oneOf/src/models/banana.rs
Normal file
28
samples/client/others/rust/hyper/oneOf/src/models/banana.rs
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Banana {
|
||||
#[serde(rename = "length")]
|
||||
pub length: i32,
|
||||
}
|
||||
|
||||
impl Banana {
|
||||
pub fn new(length: i32) -> Banana {
|
||||
Banana {
|
||||
length,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
53
samples/client/others/rust/hyper/oneOf/src/models/bar.rs
Normal file
53
samples/client/others/rust/hyper/oneOf/src/models/bar.rs
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Bar {
|
||||
#[serde(rename = "id")]
|
||||
pub id: String,
|
||||
#[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")]
|
||||
pub bar_prop_a: Option<String>,
|
||||
#[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")]
|
||||
pub foo_prop_b: Option<String>,
|
||||
#[serde(rename = "foo", skip_serializing_if = "Option::is_none")]
|
||||
pub foo: Option<Box<crate::models::FooRefOrValue>>,
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
pub href: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
pub at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
pub at_base_type: Option<String>,
|
||||
/// When sub-classing, this defines the sub-class Extensible name
|
||||
#[serde(rename = "@type")]
|
||||
pub at_type: String,
|
||||
}
|
||||
|
||||
impl Bar {
|
||||
pub fn new(id: String, at_type: String) -> Bar {
|
||||
Bar {
|
||||
id,
|
||||
bar_prop_a: None,
|
||||
foo_prop_b: None,
|
||||
foo: None,
|
||||
href: None,
|
||||
at_schema_location: None,
|
||||
at_base_type: None,
|
||||
at_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct BarCreate {
|
||||
#[serde(rename = "barPropA", skip_serializing_if = "Option::is_none")]
|
||||
pub bar_prop_a: Option<String>,
|
||||
#[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")]
|
||||
pub foo_prop_b: Option<String>,
|
||||
#[serde(rename = "foo", skip_serializing_if = "Option::is_none")]
|
||||
pub foo: Option<Box<crate::models::FooRefOrValue>>,
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
pub href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
pub at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
pub at_base_type: Option<String>,
|
||||
/// When sub-classing, this defines the sub-class Extensible name
|
||||
#[serde(rename = "@type")]
|
||||
pub at_type: String,
|
||||
}
|
||||
|
||||
impl BarCreate {
|
||||
pub fn new(at_type: String) -> BarCreate {
|
||||
BarCreate {
|
||||
bar_prop_a: None,
|
||||
foo_prop_b: None,
|
||||
foo: None,
|
||||
href: None,
|
||||
id: None,
|
||||
at_schema_location: None,
|
||||
at_base_type: None,
|
||||
at_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
53
samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs
Normal file
53
samples/client/others/rust/hyper/oneOf/src/models/bar_ref.rs
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct BarRef {
|
||||
/// Name of the related entity.
|
||||
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
|
||||
pub name: Option<String>,
|
||||
/// The actual type of the target instance when needed for disambiguation.
|
||||
#[serde(rename = "@referredType", skip_serializing_if = "Option::is_none")]
|
||||
pub at_referred_type: Option<String>,
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
pub href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
pub at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
pub at_base_type: Option<String>,
|
||||
/// When sub-classing, this defines the sub-class Extensible name
|
||||
#[serde(rename = "@type")]
|
||||
pub at_type: String,
|
||||
}
|
||||
|
||||
impl BarRef {
|
||||
pub fn new(at_type: String) -> BarRef {
|
||||
BarRef {
|
||||
name: None,
|
||||
at_referred_type: None,
|
||||
href: None,
|
||||
id: None,
|
||||
at_schema_location: None,
|
||||
at_base_type: None,
|
||||
at_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use super::Bar;
|
||||
use super::BarRef;
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum BarRefOrValue {
|
||||
Bar(Box<Bar>),
|
||||
BarRef(Box<BarRef>),
|
||||
}
|
||||
|
||||
impl Default for BarRefOrValue {
|
||||
fn default() -> Self {
|
||||
Self::Bar(Box::default())
|
||||
}
|
||||
}
|
||||
|
||||
|
121
samples/client/others/rust/hyper/oneOf/src/models/entity.rs
Normal file
121
samples/client/others/rust/hyper/oneOf/src/models/entity.rs
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "@type")]
|
||||
pub enum Entity {
|
||||
#[serde(rename="Bar")]
|
||||
Bar {
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
id: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
at_base_type: Option<String>,
|
||||
},
|
||||
#[serde(rename="Bar_Create")]
|
||||
BarCreate {
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
id: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
at_base_type: Option<String>,
|
||||
},
|
||||
#[serde(rename="Foo")]
|
||||
Foo {
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
id: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
at_base_type: Option<String>,
|
||||
},
|
||||
#[serde(rename="Pasta")]
|
||||
Pasta {
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
id: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
at_base_type: Option<String>,
|
||||
},
|
||||
#[serde(rename="Pizza")]
|
||||
Pizza {
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
id: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
at_base_type: Option<String>,
|
||||
},
|
||||
#[serde(rename="PizzaSpeziale")]
|
||||
PizzaSpeziale {
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
id: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
at_base_type: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
impl Default for Entity {
|
||||
fn default() -> Self {
|
||||
Self::Bar {
|
||||
href: Default::default(),
|
||||
id: Default::default(),
|
||||
at_schema_location: Default::default(),
|
||||
at_base_type: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
/// EntityRef : Entity reference schema to be use for all entityRef class.
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "@type")]
|
||||
pub enum EntityRef {
|
||||
#[serde(rename="BarRef")]
|
||||
BarRef {
|
||||
/// Name of the related entity.
|
||||
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
|
||||
name: Option<String>,
|
||||
/// The actual type of the target instance when needed for disambiguation.
|
||||
#[serde(rename = "@referredType", skip_serializing_if = "Option::is_none")]
|
||||
at_referred_type: Option<String>,
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
id: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
at_base_type: Option<String>,
|
||||
},
|
||||
#[serde(rename="FooRef")]
|
||||
FooRef {
|
||||
/// Name of the related entity.
|
||||
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
|
||||
name: Option<String>,
|
||||
/// The actual type of the target instance when needed for disambiguation.
|
||||
#[serde(rename = "@referredType", skip_serializing_if = "Option::is_none")]
|
||||
at_referred_type: Option<String>,
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
id: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
at_base_type: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
impl Default for EntityRef {
|
||||
fn default() -> Self {
|
||||
Self::BarRef {
|
||||
name: Default::default(),
|
||||
at_referred_type: Default::default(),
|
||||
href: Default::default(),
|
||||
id: Default::default(),
|
||||
at_schema_location: Default::default(),
|
||||
at_base_type: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Extensible {
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
pub at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
pub at_base_type: Option<String>,
|
||||
/// When sub-classing, this defines the sub-class Extensible name
|
||||
#[serde(rename = "@type")]
|
||||
pub at_type: String,
|
||||
}
|
||||
|
||||
impl Extensible {
|
||||
pub fn new(at_type: String) -> Extensible {
|
||||
Extensible {
|
||||
at_schema_location: None,
|
||||
at_base_type: None,
|
||||
at_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
51
samples/client/others/rust/hyper/oneOf/src/models/foo.rs
Normal file
51
samples/client/others/rust/hyper/oneOf/src/models/foo.rs
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Foo {
|
||||
#[serde(rename = "fooPropA", skip_serializing_if = "Option::is_none")]
|
||||
pub foo_prop_a: Option<String>,
|
||||
#[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")]
|
||||
pub foo_prop_b: Option<String>,
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
pub href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
pub at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
pub at_base_type: Option<String>,
|
||||
/// When sub-classing, this defines the sub-class Extensible name
|
||||
#[serde(rename = "@type")]
|
||||
pub at_type: String,
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
pub fn new(at_type: String) -> Foo {
|
||||
Foo {
|
||||
foo_prop_a: None,
|
||||
foo_prop_b: None,
|
||||
href: None,
|
||||
id: None,
|
||||
at_schema_location: None,
|
||||
at_base_type: None,
|
||||
at_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
56
samples/client/others/rust/hyper/oneOf/src/models/foo_ref.rs
Normal file
56
samples/client/others/rust/hyper/oneOf/src/models/foo_ref.rs
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct FooRef {
|
||||
#[serde(rename = "foorefPropA", skip_serializing_if = "Option::is_none")]
|
||||
pub fooref_prop_a: Option<String>,
|
||||
/// Name of the related entity.
|
||||
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
|
||||
pub name: Option<String>,
|
||||
/// The actual type of the target instance when needed for disambiguation.
|
||||
#[serde(rename = "@referredType", skip_serializing_if = "Option::is_none")]
|
||||
pub at_referred_type: Option<String>,
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
pub href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
pub at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
pub at_base_type: Option<String>,
|
||||
/// When sub-classing, this defines the sub-class Extensible name
|
||||
#[serde(rename = "@type")]
|
||||
pub at_type: String,
|
||||
}
|
||||
|
||||
impl FooRef {
|
||||
pub fn new(at_type: String) -> FooRef {
|
||||
FooRef {
|
||||
fooref_prop_a: None,
|
||||
name: None,
|
||||
at_referred_type: None,
|
||||
href: None,
|
||||
id: None,
|
||||
at_schema_location: None,
|
||||
at_base_type: None,
|
||||
at_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use super::Foo;
|
||||
use super::FooRef;
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "@type")]
|
||||
pub enum FooRefOrValue {
|
||||
Foo(Box<Foo>),
|
||||
FooRef(Box<FooRef>),
|
||||
}
|
||||
|
||||
impl Default for FooRefOrValue {
|
||||
fn default() -> Self {
|
||||
Self::Foo(Box::default())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
30
samples/client/others/rust/hyper/oneOf/src/models/fruit.rs
Normal file
30
samples/client/others/rust/hyper/oneOf/src/models/fruit.rs
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use super::Apple;
|
||||
use super::Banana;
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "fruitType")]
|
||||
pub enum Fruit {
|
||||
Apple(Box<Apple>),
|
||||
Banana(Box<Banana>),
|
||||
}
|
||||
|
||||
impl Default for Fruit {
|
||||
fn default() -> Self {
|
||||
Self::Apple(Box::default())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
///
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
|
||||
pub enum FruitType {
|
||||
#[serde(rename = "APPLE")]
|
||||
Apple,
|
||||
#[serde(rename = "BANANA")]
|
||||
Banana,
|
||||
|
||||
}
|
||||
|
||||
impl ToString for FruitType {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
Self::Apple => String::from("APPLE"),
|
||||
Self::Banana => String::from("BANANA"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for FruitType {
|
||||
fn default() -> FruitType {
|
||||
Self::Apple
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
36
samples/client/others/rust/hyper/oneOf/src/models/mod.rs
Normal file
36
samples/client/others/rust/hyper/oneOf/src/models/mod.rs
Normal file
@ -0,0 +1,36 @@
|
||||
pub mod addressable;
|
||||
pub use self::addressable::Addressable;
|
||||
pub mod apple;
|
||||
pub use self::apple::Apple;
|
||||
pub mod banana;
|
||||
pub use self::banana::Banana;
|
||||
pub mod bar;
|
||||
pub use self::bar::Bar;
|
||||
pub mod bar_create;
|
||||
pub use self::bar_create::BarCreate;
|
||||
pub mod bar_ref;
|
||||
pub use self::bar_ref::BarRef;
|
||||
pub mod bar_ref_or_value;
|
||||
pub use self::bar_ref_or_value::BarRefOrValue;
|
||||
pub mod entity;
|
||||
pub use self::entity::Entity;
|
||||
pub mod entity_ref;
|
||||
pub use self::entity_ref::EntityRef;
|
||||
pub mod extensible;
|
||||
pub use self::extensible::Extensible;
|
||||
pub mod foo;
|
||||
pub use self::foo::Foo;
|
||||
pub mod foo_ref;
|
||||
pub use self::foo_ref::FooRef;
|
||||
pub mod foo_ref_or_value;
|
||||
pub use self::foo_ref_or_value::FooRefOrValue;
|
||||
pub mod fruit;
|
||||
pub use self::fruit::Fruit;
|
||||
pub mod fruit_type;
|
||||
pub use self::fruit_type::FruitType;
|
||||
pub mod pasta;
|
||||
pub use self::pasta::Pasta;
|
||||
pub mod pizza;
|
||||
pub use self::pizza::Pizza;
|
||||
pub mod pizza_speziale;
|
||||
pub use self::pizza_speziale::PizzaSpeziale;
|
48
samples/client/others/rust/hyper/oneOf/src/models/pasta.rs
Normal file
48
samples/client/others/rust/hyper/oneOf/src/models/pasta.rs
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Pasta {
|
||||
#[serde(rename = "vendor", skip_serializing_if = "Option::is_none")]
|
||||
pub vendor: Option<String>,
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
pub href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
pub at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
pub at_base_type: Option<String>,
|
||||
/// When sub-classing, this defines the sub-class Extensible name
|
||||
#[serde(rename = "@type")]
|
||||
pub at_type: String,
|
||||
}
|
||||
|
||||
impl Pasta {
|
||||
pub fn new(at_type: String) -> Pasta {
|
||||
Pasta {
|
||||
vendor: None,
|
||||
href: None,
|
||||
id: None,
|
||||
at_schema_location: None,
|
||||
at_base_type: None,
|
||||
at_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
48
samples/client/others/rust/hyper/oneOf/src/models/pizza.rs
Normal file
48
samples/client/others/rust/hyper/oneOf/src/models/pizza.rs
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* ByRefOrValue
|
||||
*
|
||||
* This tests for a oneOf interface representation
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Pizza {
|
||||
#[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")]
|
||||
pub pizza_size: Option<f32>,
|
||||
/// Hyperlink reference
|
||||
#[serde(rename = "href", skip_serializing_if = "Option::is_none")]
|
||||
pub href: Option<String>,
|
||||
/// unique identifier
|
||||
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<String>,
|
||||
/// A URI to a JSON-Schema file that defines additional attributes and relationships
|
||||
#[serde(rename = "@schemaLocation", skip_serializing_if = "Option::is_none")]
|
||||
pub at_schema_location: Option<String>,
|
||||
/// When sub-classing, this defines the super-class
|
||||
#[serde(rename = "@baseType", skip_serializing_if = "Option::is_none")]
|
||||
pub at_base_type: Option<String>,
|
||||
/// When sub-classing, this defines the sub-class Extensible name
|
||||
#[serde(rename = "@type")]
|
||||
pub at_type: String,
|
||||
}
|
||||
|
||||
impl Pizza {
|
||||
pub fn new(at_type: String) -> Pizza {
|
||||
Pizza {
|
||||
pizza_size: None,
|
||||
href: None,
|
||||
id: None,
|
||||
at_schema_location: None,
|
||||
at_base_type: None,
|
||||
at_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user