fix(rust): oneOf generation for client (#17915)

* fix(rust): discriminator mapping to serde rename

Discriminator mapping has been ignored in some cases.
Even existing samples had wrong definition in some cases

This PR addresses this

* fix(rust): `oneOf` generation for client

Solves #17869 and #17896 and also includes unmerged $17898

Unfortunately it affects quite a lot of code, but we can see that only client-side models were affected by re-generation.
I tried to split this PR to several, but they're really coupled and hard to create a chain of PRs.

* fix: indentation in `impl Default`

* missing fixes

* fix: correct typeDeclaration with unaliased schema

* style: improve indentation for models

* fix: user toModelName for aliases of oneOf

* refactor: unify `getTypeDeclaration` for rust

* cover the case when `mapping` has the same `ref` for different mapping names

* test: add test for previous change

* style: remove extra qualified path to models

* add some comments

* fix(build): use method of `List` instead of specific for `LinkedList`
This commit is contained in:
Artem Medvedev 2024-02-24 16:41:30 +01:00 committed by GitHub
parent 15af1ce1de
commit 518b29d089
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
335 changed files with 3663 additions and 1099 deletions

View File

@ -0,0 +1,8 @@
generatorName: rust
outputDir: samples/client/others/rust/hyper/oneOf-array-map
library: hyper
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOfArrayMapImport.yaml
templateDir: modules/openapi-generator/src/main/resources/rust
additionalProperties:
supportAsync: false
packageName: oneof-array-map-hyper

View File

@ -0,0 +1,8 @@
generatorName: rust
outputDir: samples/client/others/rust/hyper/oneOf-reuseRef
library: hyper
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_reuseRef.yaml
templateDir: modules/openapi-generator/src/main/resources/rust
additionalProperties:
supportAsync: false
packageName: oneof-reuse-ref-hyper

View File

@ -0,0 +1,8 @@
generatorName: rust
outputDir: samples/client/others/rust/reqwest/oneOf-array-map
library: reqwest
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOfArrayMapImport.yaml
templateDir: modules/openapi-generator/src/main/resources/rust
additionalProperties:
supportAsync: false
packageName: oneof-array-map-reqwest

View File

@ -0,0 +1,8 @@
generatorName: rust
outputDir: samples/client/others/rust/reqwest/oneOf-reuseRef
library: reqwest
inputSpec: modules/openapi-generator/src/test/resources/3_0/oneOf_reuseRef.yaml
templateDir: modules/openapi-generator/src/main/resources/rust
additionalProperties:
supportAsync: false
packageName: oneof-reuse-ref-reqwest

View File

@ -2,10 +2,11 @@ package org.openapitools.codegen.languages;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import org.openapitools.codegen.CodegenConfig; import io.swagger.v3.oas.models.media.ArraySchema;
import org.openapitools.codegen.CodegenProperty; import io.swagger.v3.oas.models.media.FileSchema;
import org.openapitools.codegen.DefaultCodegen; import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.GeneratorLanguage; import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.StringUtils; import org.openapitools.codegen.utils.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -232,6 +233,83 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
return name; return name;
} }
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
String innerType = getTypeDeclaration(inner);
return typeMapping.get("array") + "<" + innerType + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
String innerType = getTypeDeclaration(inner);
StringBuilder typeDeclaration = new StringBuilder(typeMapping.get("map")).append("<").append(typeMapping.get("string")).append(", ");
typeDeclaration.append(innerType).append(">");
return typeDeclaration.toString();
} else if (!org.apache.commons.lang3.StringUtils.isEmpty(p.get$ref())) {
String datatype;
try {
datatype = toModelName(ModelUtils.getSimpleRef(p.get$ref()));
datatype = "models::" + toModelName(datatype);
} catch (Exception e) {
LOGGER.warn("Error obtaining the datatype from schema (model):{}. Datatype default to Object", p);
datatype = "Object";
LOGGER.error(e.getMessage(), e);
}
return datatype;
} else if (p instanceof FileSchema) {
return typeMapping.get("file");
}
String oasType = getSchemaType(p);
if (typeMapping.containsKey(oasType)) {
return typeMapping.get(oasType);
}
if (typeMapping.containsValue(oasType)) {
return oasType;
}
if (languageSpecificPrimitives.contains(oasType)) {
return oasType;
}
return "models::" + toModelName(oasType);
}
@Override
public CodegenModel fromModel(String name, Schema model) {
LOGGER.trace("Creating model from schema: {}", model);
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
CodegenModel mdl = super.fromModel(name, model);
mdl.vendorExtensions.put("x-upper-case-name", name.toUpperCase(Locale.ROOT));
if (!org.apache.commons.lang3.StringUtils.isEmpty(model.get$ref())) {
Schema schema = allDefinitions.get(ModelUtils.getSimpleRef(model.get$ref()));
mdl.dataType = typeMapping.get(schema.getType());
}
if (ModelUtils.isArraySchema(model)) {
if (typeMapping.containsKey(mdl.arrayModelType)) {
mdl.arrayModelType = typeMapping.get(mdl.arrayModelType);
} else {
mdl.arrayModelType = toModelName(mdl.arrayModelType);
}
} else if ((!mdl.anyOf.isEmpty()) || (!mdl.oneOf.isEmpty())) {
mdl.dataType = getSchemaType(model);
}
Schema additionalProperties = ModelUtils.getAdditionalProperties(model);
if (additionalProperties != null) {
mdl.additionalPropertiesType = getTypeDeclaration(additionalProperties);
}
LOGGER.trace("Created model: {}", mdl);
return mdl;
}
@Override @Override
public String toVarName(String name) { public String toVarName(String name) {
// obtain the name from nameMapping directly if provided // obtain the name from nameMapping directly if provided

View File

@ -21,7 +21,6 @@ import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.FileSchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter; import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.parameters.RequestBody; import io.swagger.v3.oas.models.parameters.RequestBody;
@ -703,41 +702,6 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
return codegenParameter; return codegenParameter;
} }
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
String innerType = getTypeDeclaration(inner);
return typeMapping.get("array") + "<" + innerType + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
String innerType = getTypeDeclaration(inner);
StringBuilder typeDeclaration = new StringBuilder(typeMapping.get("map")).append("<").append(typeMapping.get("string")).append(", ");
typeDeclaration.append(innerType).append(">");
return typeDeclaration.toString();
} else if (!StringUtils.isEmpty(p.get$ref())) {
String datatype;
try {
datatype = p.get$ref();
if (datatype.indexOf("#/components/schemas/") == 0) {
datatype = toModelName(datatype.substring("#/components/schemas/".length()));
datatype = "models::" + datatype;
}
} catch (Exception e) {
LOGGER.warn("Error obtaining the datatype from schema (model):{}. Datatype default to Object", p);
datatype = "Object";
LOGGER.error(e.getMessage(), e);
}
return datatype;
} else if (p instanceof FileSchema) {
return typeMapping.get("File");
}
return super.getTypeDeclaration(p);
}
@Override @Override
public String toInstantiationType(Schema p) { public String toInstantiationType(Schema p) {
if (ModelUtils.isArraySchema(p)) { if (ModelUtils.isArraySchema(p)) {
@ -752,39 +716,6 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
} }
} }
@Override
public CodegenModel fromModel(String name, Schema model) {
LOGGER.trace("Creating model from schema: {}", model);
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
CodegenModel mdl = super.fromModel(name, model);
mdl.vendorExtensions.put("x-upper-case-name", name.toUpperCase(Locale.ROOT));
if (!StringUtils.isEmpty(model.get$ref())) {
Schema schema = allDefinitions.get(ModelUtils.getSimpleRef(model.get$ref()));
mdl.dataType = typeMapping.get(schema.getType());
}
if (ModelUtils.isArraySchema(model)) {
if (typeMapping.containsKey(mdl.arrayModelType)) {
mdl.arrayModelType = typeMapping.get(mdl.arrayModelType);
} else {
mdl.arrayModelType = toModelName(mdl.arrayModelType);
}
} else if ((!mdl.anyOf.isEmpty()) || (!mdl.oneOf.isEmpty())) {
mdl.dataType = getSchemaType(model);
}
Schema additionalProperties = ModelUtils.getAdditionalProperties(model);
if (additionalProperties != null) {
mdl.additionalPropertiesType = getTypeDeclaration(additionalProperties);
}
LOGGER.trace("Created model: {}", mdl);
return mdl;
}
@Override @Override
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> bundle) { public Map<String, Object> postProcessSupportingFileData(Map<String, Object> bundle) {
generateYAMLSpecFile(bundle); generateYAMLSpecFile(bundle);

View File

@ -19,9 +19,7 @@ package org.openapitools.codegen.languages;
import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template; import com.samskivert.mustache.Template;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.parser.util.SchemaTypeUtil; import io.swagger.v3.parser.util.SchemaTypeUtil;
import joptsimple.internal.Strings; import joptsimple.internal.Strings;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
@ -41,8 +39,7 @@ import java.io.Writer;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class RustClientCodegen extends AbstractRustCodegen implements CodegenConfig { public class RustClientCodegen extends AbstractRustCodegen implements CodegenConfig {
private final Logger LOGGER = LoggerFactory.getLogger(RustClientCodegen.class); private final Logger LOGGER = LoggerFactory.getLogger(RustClientCodegen.class);
@ -149,11 +146,13 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
typeMapping.clear(); typeMapping.clear();
typeMapping.put("integer", "i32"); typeMapping.put("integer", "i32");
typeMapping.put("long", "i64"); typeMapping.put("long", "i64");
typeMapping.put("number", "f32"); typeMapping.put("number", "f64");
typeMapping.put("float", "f32"); typeMapping.put("float", "f32");
typeMapping.put("double", "f64"); typeMapping.put("double", "f64");
typeMapping.put("boolean", "bool"); typeMapping.put("boolean", "bool");
typeMapping.put("string", "String"); typeMapping.put("string", "String");
typeMapping.put("array", "Vec");
typeMapping.put("map", "std::collections::HashMap");
typeMapping.put("UUID", "uuid::Uuid"); typeMapping.put("UUID", "uuid::Uuid");
typeMapping.put("URI", "String"); typeMapping.put("URI", "String");
typeMapping.put("date", "string"); typeMapping.put("date", "string");
@ -205,11 +204,72 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
setLibrary(REQWEST_LIBRARY); setLibrary(REQWEST_LIBRARY);
} }
@Override
public CodegenModel fromModel(String name, Schema model) {
CodegenModel mdl = super.fromModel(name, model);
// set correct names and baseNames to oneOf in composed-schema to use as enum variant names & mapping
if (mdl.getComposedSchemas() != null && mdl.getComposedSchemas().getOneOf() != null
&& !mdl.getComposedSchemas().getOneOf().isEmpty()) {
List<CodegenProperty> newOneOfs = mdl.getComposedSchemas().getOneOf().stream()
.map(CodegenProperty::clone)
.collect(Collectors.toList());
List<Schema> schemas = ModelUtils.getInterfaces(model);
if (newOneOfs.size() != schemas.size()) {
// For safety reasons, this should never happen unless there is an error in the code
throw new RuntimeException("oneOf size does not match the model");
}
Map<String, String> refsMapping = Optional.ofNullable(model.getDiscriminator())
.map(Discriminator::getMapping).orElse(Collections.emptyMap());
// Reverse mapped references to use as baseName for oneOF, but different keys may point to the same $ref.
// Thus, we group them by the value
Map<String, List<String>> mappedNamesByRef = refsMapping.entrySet().stream()
.collect(Collectors.groupingBy(Map.Entry::getValue,
Collectors.mapping(Map.Entry::getKey, Collectors.toList())
));
for (int i = 0; i < newOneOfs.size(); i++) {
CodegenProperty oneOf = newOneOfs.get(i);
Schema schema = schemas.get(i);
if (mappedNamesByRef.containsKey(schema.get$ref())) {
// prefer mapped names if present
// remove mapping not in order not to reuse for the next occurrence of the ref
List<String> names = mappedNamesByRef.get(schema.get$ref());
String mappedName = names.remove(0);
oneOf.setBaseName(mappedName);
oneOf.setName(toModelName(mappedName));
} else if (!org.apache.commons.lang3.StringUtils.isEmpty(schema.get$ref())) {
// use $ref if it's reference
String refName = ModelUtils.getSimpleRef(schema.get$ref());
if (refName != null) {
String modelName = toModelName(refName);
oneOf.setName(modelName);
oneOf.setBaseName(refName);
}
} else {
// In-placed type (primitive), because there is no mapping or ref for it.
// use camelized `title` if present, otherwise use `type`
String oneOfName = Optional.ofNullable(schema.getTitle()).orElseGet(schema::getType);
oneOf.setName(toModelName(oneOfName));
}
}
mdl.getComposedSchemas().setOneOf(newOneOfs);
}
return mdl;
}
@Override @Override
public ModelsMap postProcessModels(ModelsMap objs) { public ModelsMap postProcessModels(ModelsMap objs) {
// Remove the discriminator field from the model, serde will take care of this // Remove the discriminator field from the model, serde will take care of this
for (ModelMap model : objs.getModels()) { for (ModelMap model : objs.getModels()) {
CodegenModel cm = model.getModel(); CodegenModel cm = model.getModel();
if (cm.discriminator != null) { if (cm.discriminator != null) {
String reserved_var_name = cm.discriminator.getPropertyBaseName(); String reserved_var_name = cm.discriminator.getPropertyBaseName();
@ -399,43 +459,9 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
@Override @Override
public String getTypeDeclaration(Schema p) { public String getTypeDeclaration(Schema p) {
// use unaliased schema for client-side
Schema unaliasSchema = unaliasSchema(p); Schema unaliasSchema = unaliasSchema(p);
if (ModelUtils.isArraySchema(unaliasSchema)) { return super.getTypeDeclaration(unaliasSchema);
ArraySchema ap = (ArraySchema) unaliasSchema;
Schema inner = ap.getItems();
if (inner == null) {
LOGGER.warn("{}(array property) does not have a proper inner type defined.Default to string",
ap.getName());
inner = new StringSchema().description("TODO default missing array inner type to string");
}
return "Vec<" + getTypeDeclaration(inner) + ">";
} else if (ModelUtils.isMapSchema(unaliasSchema)) {
Schema inner = ModelUtils.getAdditionalProperties(unaliasSchema);
if (inner == null) {
LOGGER.warn("{}(map property) does not have a proper inner type defined. Default to string", unaliasSchema.getName());
inner = new StringSchema().description("TODO default missing map inner type to string");
}
return "::std::collections::HashMap<String, " + getTypeDeclaration(inner) + ">";
}
// Not using the supertype invocation, because we want to UpperCamelize
// the type.
String schemaType = getSchemaType(unaliasSchema);
if (typeMapping.containsKey(schemaType)) {
return typeMapping.get(schemaType);
}
if (typeMapping.containsValue(schemaType)) {
return schemaType;
}
if (languageSpecificPrimitives.contains(schemaType)) {
return schemaType;
}
// return fully-qualified model name
// crate::models::{{classnameFile}}::{{classname}}
return "crate::models::" + toModelName(schemaType);
} }
@Override @Override

View File

@ -22,8 +22,6 @@ import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.ComposedSchema;
import io.swagger.v3.oas.models.media.FileSchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.XML; import io.swagger.v3.oas.models.media.XML;
import io.swagger.v3.oas.models.parameters.Parameter; import io.swagger.v3.oas.models.parameters.Parameter;
@ -980,41 +978,6 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
return codegenParameter; return codegenParameter;
} }
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
String innerType = getTypeDeclaration(inner);
return typeMapping.get("array") + "<" + innerType + ">";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
String innerType = getTypeDeclaration(inner);
StringBuilder typeDeclaration = new StringBuilder(typeMapping.get("map")).append("<").append(typeMapping.get("string")).append(", ");
typeDeclaration.append(innerType).append(">");
return typeDeclaration.toString();
} else if (!StringUtils.isEmpty(p.get$ref())) {
String datatype;
try {
datatype = p.get$ref();
if (datatype.indexOf("#/components/schemas/") == 0) {
datatype = toModelName(datatype.substring("#/components/schemas/".length()));
datatype = "models::" + datatype;
}
} catch (Exception e) {
LOGGER.warn("Error obtaining the datatype from schema (model):{}. Datatype default to Object", p);
datatype = "Object";
LOGGER.error(e.getMessage(), e);
}
return datatype;
} else if (p instanceof FileSchema) {
return typeMapping.get("File");
}
return super.getTypeDeclaration(p);
}
@Override @Override
public String toInstantiationType(Schema p) { public String toInstantiationType(Schema p) {
if (ModelUtils.isArraySchema(p)) { if (ModelUtils.isArraySchema(p)) {
@ -1036,11 +999,6 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI); Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
CodegenModel mdl = super.fromModel(name, model); CodegenModel mdl = super.fromModel(name, model);
mdl.vendorExtensions.put("x-upper-case-name", name.toUpperCase(Locale.ROOT));
if (!StringUtils.isEmpty(model.get$ref())) {
Schema schema = allDefinitions.get(ModelUtils.getSimpleRef(model.get$ref()));
mdl.dataType = typeMapping.get(schema.getType());
}
if (ModelUtils.isArraySchema(model)) { if (ModelUtils.isArraySchema(model)) {
ArraySchema am = (ArraySchema) model; ArraySchema am = (ArraySchema) model;
String xmlName = null; String xmlName = null;
@ -1070,12 +1028,6 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
mdl.vendorExtensions.put("x-item-xml-name", xmlName); mdl.vendorExtensions.put("x-item-xml-name", xmlName);
modelXmlNames.put("models::" + mdl.classname, xmlName); modelXmlNames.put("models::" + mdl.classname, xmlName);
} }
if (typeMapping.containsKey(mdl.arrayModelType)) {
mdl.arrayModelType = typeMapping.get(mdl.arrayModelType);
} else {
mdl.arrayModelType = toModelName(mdl.arrayModelType);
}
} else if ((mdl.anyOf.size() > 0) || (mdl.oneOf.size() > 0)) { } else if ((mdl.anyOf.size() > 0) || (mdl.oneOf.size() > 0)) {
mdl.dataType = getSchemaType(model); mdl.dataType = getSchemaType(model);
} }
@ -1084,12 +1036,6 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon
additionalProperties.put("usesXmlNamespaces", true); additionalProperties.put("usesXmlNamespaces", true);
} }
Schema additionalProperties = ModelUtils.getAdditionalProperties(model);
if (additionalProperties != null) {
mdl.additionalPropertiesType = getTypeDeclaration(additionalProperties);
}
LOGGER.trace("Created model: {}", mdl); LOGGER.trace("Created model: {}", mdl);
return mdl; return mdl;

View File

@ -8,6 +8,7 @@ use std::option::Option;
use hyper; use hyper;
use futures::Future; use futures::Future;
use crate::models;
use super::{Error, configuration}; use super::{Error, configuration};
use super::request as __internal_request; use super::request as __internal_request;
@ -28,7 +29,7 @@ impl<C: hyper::client::connect::Connect> {{{classname}}}Client<C>
pub trait {{{classname}}} { pub trait {{{classname}}} {
{{#operations}} {{#operations}}
{{#operation}} {{#operation}}
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{^isUuid}}&str{{/isUuid}}{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Pin<Box<dyn Future<Output = Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>>>>; fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{^isUuid}}&str{{/isUuid}}{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Pin<Box<dyn Future<Output = Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}, Error>>>>;
{{/operation}} {{/operation}}
{{/operations}} {{/operations}}
} }
@ -38,7 +39,7 @@ impl<C: hyper::client::connect::Connect>{{{classname}}} for {{{classname}}}Clien
{{#operations}} {{#operations}}
{{#operation}} {{#operation}}
#[allow(unused_mut)] #[allow(unused_mut)]
fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{^isUuid}}&str{{/isUuid}}{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Pin<Box<dyn Future<Output = Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{.}}}{{/returnType}}, Error>>>> { fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{^isUuid}}&str{{/isUuid}}{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Pin<Box<dyn Future<Output = Result<{{^returnType}}(){{/returnType}}{{#returnType}}{{{.}}}{{/returnType}}, Error>>>> {
let mut req = __internal_request::Request::new(hyper::Method::{{{httpMethod.toUpperCase}}}, "{{{path}}}".to_string()) let mut req = __internal_request::Request::new(hyper::Method::{{{httpMethod.toUpperCase}}}, "{{{path}}}".to_string())
{{#hasAuthMethods}} {{#hasAuthMethods}}
{{#authMethods}} {{#authMethods}}

View File

@ -1,3 +1,5 @@
#![allow(unused_imports)]
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;

View File

@ -1,13 +1,11 @@
{{>partial_header}} {{>partial_header}}
use crate::models;
{{#models}} {{#models}}
{{#model}} {{#model}}
{{#description}} {{#description}}
/// {{{classname}}} : {{{description}}} /// {{{classname}}} : {{{description}}}
{{/description}} {{/description}}
{{#oneOf}}
use super::{{{.}}};
{{/oneOf}}
{{!-- for enum schemas --}} {{!-- for enum schemas --}}
{{#isEnum}} {{#isEnum}}
/// {{{description}}} /// {{{description}}}
@ -40,7 +38,6 @@ impl Default for {{{classname}}} {
} }
} }
{{/isEnum}} {{/isEnum}}
{{!-- for schemas that have a discriminator --}} {{!-- for schemas that have a discriminator --}}
{{#discriminator}} {{#discriminator}}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
@ -60,12 +57,17 @@ pub enum {{{classname}}} {
}, },
{{/mappedModels}} {{/mappedModels}}
{{/oneOf}} {{/oneOf}}
{{#oneOf}} {{^oneOf.isEmpty}}
{{#composedSchemas.oneOf}}
{{#description}} {{#description}}
/// {{{.}}} /// {{{.}}}
{{/description}} {{/description}}
{{{.}}}(Box<{{{.}}}>), {{#baseName}}
{{/oneOf}} #[serde(rename="{{{.}}}")]
{{/baseName}}
{{{name}}}(Box<{{{dataType}}}>),
{{/composedSchemas.oneOf}}
{{/oneOf.isEmpty}}
} }
impl Default for {{classname}} { impl Default for {{classname}} {
@ -74,12 +76,12 @@ impl Default for {{classname}} {
{{#vars}} {{#vars}}
{{{name}}}: Default::default(), {{{name}}}: Default::default(),
{{/vars}} {{/vars}}
}{{/-first}}{{/mappedModels}}{{/oneOf}}{{#oneOf}}{{#-first}}Self::{{{.}}}(Box::default()){{/-first}}{{/oneOf}} }{{/-first}}{{/mappedModels}}
{{/oneOf}}{{^oneOf.isEmpty}}{{#composedSchemas.oneOf}}{{#-first}}Self::{{{name}}}(Box::default()){{/-first}}{{/composedSchemas.oneOf}}{{/oneOf.isEmpty}}
} }
} }
{{/discriminator}} {{/discriminator}}
{{!-- for non-enum schemas --}} {{!-- for non-enum schemas --}}
{{^isEnum}} {{^isEnum}}
{{^discriminator}} {{^discriminator}}
@ -110,26 +112,28 @@ impl {{{classname}}} {
{{/oneOf.isEmpty}} {{/oneOf.isEmpty}}
{{^oneOf.isEmpty}} {{^oneOf.isEmpty}}
{{! TODO: add other vars that are not part of the oneOf}} {{! TODO: add other vars that are not part of the oneOf}}
{{#description}}
/// {{{.}}}
{{/description}}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum {{classname}} { pub enum {{classname}} {
{{#oneOf}} {{#composedSchemas.oneOf}}
{{#description}} {{#description}}
/// {{{.}}} /// {{{.}}}
{{/description}} {{/description}}
{{{.}}}(Box<{{{.}}}>), {{{name}}}(Box<{{{dataType}}}>),
{{/oneOf}} {{/composedSchemas.oneOf}}
} }
impl Default for {{classname}} { impl Default for {{classname}} {
fn default() -> Self { fn default() -> Self {
{{#oneOf}}{{#-first}}Self::{{{.}}}(Box::default()){{/-first}}{{/oneOf}} {{#composedSchemas.oneOf}}{{#-first}}Self::{{{name}}}(Box::default()){{/-first}}{{/composedSchemas.oneOf}}
} }
} }
{{/oneOf.isEmpty}} {{/oneOf.isEmpty}}
{{/discriminator}} {{/discriminator}}
{{/isEnum}} {{/isEnum}}
{{!-- for properties that are of enum type --}} {{!-- for properties that are of enum type --}}
{{#vars}} {{#vars}}
{{#isEnum}} {{#isEnum}}

View File

@ -2,7 +2,7 @@
use reqwest; use reqwest;
use crate::apis::ResponseContent; use crate::{apis::ResponseContent, models};
use super::{Error, configuration}; use super::{Error, configuration};
{{#operations}} {{#operations}}
@ -17,7 +17,7 @@ pub struct {{{operationIdCamelCase}}}Params {
{{#description}} {{#description}}
/// {{{.}}} /// {{{.}}}
{{/description}} {{/description}}
pub {{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^isUuid}}{{#isString}}{{#isArray}}Vec<{{/isArray}}String{{#isArray}}>{{/isArray}}{{/isString}}{{/isUuid}}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}String{{#isArray}}>{{/isArray}}{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}{{#isBodyParam}}crate::models::{{/isBodyParam}}{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}},{{/-last}} pub {{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^isUuid}}{{#isString}}{{#isArray}}Vec<{{/isArray}}String{{#isArray}}>{{/isArray}}{{/isString}}{{/isUuid}}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}String{{#isArray}}>{{/isArray}}{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}{{#isBodyParam}}models::{{/isBodyParam}}{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}},{{/-last}}
{{#-last}} {{#-last}}
} }
@ -90,7 +90,7 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration:
{{/vendorExtensions.x-group-parameters}} {{/vendorExtensions.x-group-parameters}}
{{^vendorExtensions.x-group-parameters}} {{^vendorExtensions.x-group-parameters}}
pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: &configuration::Configuration, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{#isArray}}Vec<{{/isArray}}{{^isUuid}}&str{{/isUuid}}{{#isArray}}>{{/isArray}}{{/isString}}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}&str{{#isArray}}>{{/isArray}}{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}{{#isBodyParam}}crate::models::{{/isBodyParam}}{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Result<{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{{returnType}}}{{/supportMultipleResponses}}, Error<{{{operationIdCamelCase}}}Error>> { pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: &configuration::Configuration, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{#isArray}}Vec<{{/isArray}}{{^isUuid}}&str{{/isUuid}}{{#isArray}}>{{/isArray}}{{/isString}}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}&str{{#isArray}}>{{/isArray}}{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}{{#isBodyParam}}models::{{/isBodyParam}}{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Result<{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{{returnType}}}{{/supportMultipleResponses}}, Error<{{{operationIdCamelCase}}}Error>> {
let local_var_configuration = configuration; let local_var_configuration = configuration;
{{/vendorExtensions.x-group-parameters}} {{/vendorExtensions.x-group-parameters}}

View File

@ -0,0 +1,47 @@
openapi: 3.0.1
info:
version: 1.0.0
title: Example
license:
name: MIT
servers:
- url: http://api.example.xyz/v1
paths:
/example:
get:
operationId: get_fruit
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/Fruit"
components:
schemas:
Apple:
type: object
properties:
cultivar:
type: string
pattern: ^[a-zA-Z\s]*$
origin:
type: string
pattern: /^[A-Z\s]*$/i
nullable: true
Banana:
type: object
properties:
lengthCm:
type: number
Fruit:
oneOf:
- $ref: '#/components/schemas/Apple'
- $ref: '#/components/schemas/Apple'
- $ref: '#/components/schemas/Banana'
discriminator:
propertyName: fruitType
mapping:
green_apple: '#/components/schemas/Apple'
banana: '#/components/schemas/Banana'
red_apple: '#/components/schemas/Apple'

View File

@ -615,6 +615,34 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "oneof-array-map-hyper"
version = "0.0.1"
dependencies = [
"base64 0.7.0",
"futures",
"http",
"hyper",
"hyper-tls",
"serde",
"serde_derive",
"serde_json",
"url",
"uuid",
]
[[package]]
name = "oneof-array-map-reqwest"
version = "0.0.1"
dependencies = [
"reqwest",
"serde",
"serde_derive",
"serde_json",
"url",
"uuid",
]
[[package]] [[package]]
name = "oneof-hyper" name = "oneof-hyper"
version = "0.0.1" version = "0.0.1"
@ -643,6 +671,34 @@ dependencies = [
"uuid", "uuid",
] ]
[[package]]
name = "oneof-reuse-ref-hyper"
version = "1.0.0"
dependencies = [
"base64 0.7.0",
"futures",
"http",
"hyper",
"hyper-tls",
"serde",
"serde_derive",
"serde_json",
"url",
"uuid",
]
[[package]]
name = "oneof-reuse-ref-reqwest"
version = "1.0.0"
dependencies = [
"reqwest",
"serde",
"serde_derive",
"serde_json",
"url",
"uuid",
]
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.55" version = "0.10.55"

View File

@ -39,7 +39,7 @@ No authorization required
## get_state ## get_state
> crate::models::GetState200Response get_state() > models::GetState200Response get_state()
### Parameters ### Parameters
@ -48,7 +48,7 @@ This endpoint does not need any parameter.
### Return type ### Return type
[**crate::models::GetState200Response**](getState_200_response.md) [**models::GetState200Response**](getState_200_response.md)
### Authorization ### Authorization

View File

@ -17,6 +17,7 @@ use std::option::Option;
use hyper; use hyper;
use futures::Future; use futures::Future;
use crate::models;
use super::{Error, configuration}; use super::{Error, configuration};
use super::request as __internal_request; use super::request as __internal_request;
@ -35,14 +36,14 @@ impl<C: hyper::client::connect::Connect> DefaultApiClient<C>
} }
pub trait DefaultApi { pub trait DefaultApi {
fn create_state(&self, create_state_request: crate::models::CreateStateRequest) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>; fn create_state(&self, create_state_request: models::CreateStateRequest) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>;
fn get_state(&self, ) -> Pin<Box<dyn Future<Output = Result<crate::models::GetState200Response, Error>>>>; fn get_state(&self, ) -> Pin<Box<dyn Future<Output = Result<models::GetState200Response, Error>>>>;
} }
impl<C: hyper::client::connect::Connect>DefaultApi for DefaultApiClient<C> impl<C: hyper::client::connect::Connect>DefaultApi for DefaultApiClient<C>
where C: Clone + std::marker::Send + Sync { where C: Clone + std::marker::Send + Sync {
#[allow(unused_mut)] #[allow(unused_mut)]
fn create_state(&self, create_state_request: crate::models::CreateStateRequest) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> { fn create_state(&self, create_state_request: models::CreateStateRequest) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
let mut req = __internal_request::Request::new(hyper::Method::POST, "/state".to_string()) let mut req = __internal_request::Request::new(hyper::Method::POST, "/state".to_string())
; ;
req = req.with_body_param(create_state_request); req = req.with_body_param(create_state_request);
@ -52,7 +53,7 @@ impl<C: hyper::client::connect::Connect>DefaultApi for DefaultApiClient<C>
} }
#[allow(unused_mut)] #[allow(unused_mut)]
fn get_state(&self, ) -> Pin<Box<dyn Future<Output = Result<crate::models::GetState200Response, Error>>>> { fn get_state(&self, ) -> Pin<Box<dyn Future<Output = Result<models::GetState200Response, Error>>>> {
let mut req = __internal_request::Request::new(hyper::Method::GET, "/state".to_string()) let mut req = __internal_request::Request::new(hyper::Method::GET, "/state".to_string())
; ;

View File

@ -1,3 +1,5 @@
#![allow(unused_imports)]
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;

View File

@ -8,23 +8,21 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use super::ObjA; use crate::models;
use super::ObjB;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "realtype")] #[serde(tag = "realtype")]
pub enum CreateStateRequest { pub enum CreateStateRequest {
ObjA(Box<ObjA>), #[serde(rename="a-type")]
ObjB(Box<ObjB>), AType(Box<models::ObjA>),
#[serde(rename="b-type")]
BType(Box<models::ObjB>),
} }
impl Default for CreateStateRequest { impl Default for CreateStateRequest {
fn default() -> Self { fn default() -> Self {
Self::ObjA(Box::default()) Self::AType(Box::default())
} }
} }

View File

@ -8,25 +8,23 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use super::ObjA; use crate::models;
use super::ObjB;
use super::ObjC;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "realtype")] #[serde(tag = "realtype")]
pub enum CustomOneOfArraySchemaInner { pub enum CustomOneOfArraySchemaInner {
ObjA(Box<ObjA>), #[serde(rename="a-type")]
ObjB(Box<ObjB>), AType(Box<models::ObjA>),
ObjC(Box<ObjC>), #[serde(rename="b-type")]
BType(Box<models::ObjB>),
#[serde(rename="c-type")]
CType(Box<models::ObjC>),
} }
impl Default for CustomOneOfArraySchemaInner { impl Default for CustomOneOfArraySchemaInner {
fn default() -> Self { fn default() -> Self {
Self::ObjA(Box::default()) Self::AType(Box::default())
} }
} }

View File

@ -8,23 +8,21 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use super::ObjA; use crate::models;
use super::ObjB;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "realtype")] #[serde(tag = "realtype")]
pub enum CustomOneOfSchema { pub enum CustomOneOfSchema {
ObjA(Box<ObjA>), #[serde(rename="a-type")]
ObjB(Box<ObjB>), AType(Box<models::ObjA>),
#[serde(rename="b-type")]
BType(Box<models::ObjB>),
} }
impl Default for CustomOneOfSchema { impl Default for CustomOneOfSchema {
fn default() -> Self { fn default() -> Self {
Self::ObjA(Box::default()) Self::AType(Box::default())
} }
} }

View File

@ -8,25 +8,23 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use super::ObjA; use crate::models;
use super::ObjB;
use super::ObjD;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "realtype")] #[serde(tag = "realtype")]
pub enum GetState200Response { pub enum GetState200Response {
ObjA(Box<ObjA>), #[serde(rename="a-type")]
ObjB(Box<ObjB>), AType(Box<models::ObjA>),
ObjD(Box<ObjD>), #[serde(rename="b-type")]
BType(Box<models::ObjB>),
#[serde(rename="d-type")]
DType(Box<models::ObjD>),
} }
impl Default for GetState200Response { impl Default for GetState200Response {
fn default() -> Self { fn default() -> Self {
Self::ObjA(Box::default()) Self::AType(Box::default())
} }
} }

View File

@ -8,8 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ObjA { pub struct ObjA {
@ -28,4 +27,3 @@ impl ObjA {
} }
} }

View File

@ -8,8 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ObjB { pub struct ObjB {
@ -31,4 +30,3 @@ impl ObjB {
} }
} }

View File

@ -8,8 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ObjC { pub struct ObjC {
@ -28,4 +27,3 @@ impl ObjC {
} }
} }

View File

@ -8,8 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ObjD { pub struct ObjD {
@ -28,4 +27,3 @@ impl ObjD {
} }
} }

View File

@ -10,7 +10,7 @@ Method | HTTP request | Description
## endpoint_get ## endpoint_get
> crate::models::EmptyObject endpoint_get() > models::EmptyObject endpoint_get()
Get endpoint Get endpoint
### Parameters ### Parameters
@ -19,7 +19,7 @@ This endpoint does not need any parameter.
### Return type ### Return type
[**crate::models::EmptyObject**](EmptyObject.md) [**models::EmptyObject**](EmptyObject.md)
### Authorization ### Authorization

View File

@ -17,6 +17,7 @@ use std::option::Option;
use hyper; use hyper;
use futures::Future; use futures::Future;
use crate::models;
use super::{Error, configuration}; use super::{Error, configuration};
use super::request as __internal_request; use super::request as __internal_request;
@ -35,13 +36,13 @@ impl<C: hyper::client::connect::Connect> DefaultApiClient<C>
} }
pub trait DefaultApi { pub trait DefaultApi {
fn endpoint_get(&self, ) -> Pin<Box<dyn Future<Output = Result<crate::models::EmptyObject, Error>>>>; fn endpoint_get(&self, ) -> Pin<Box<dyn Future<Output = Result<models::EmptyObject, Error>>>>;
} }
impl<C: hyper::client::connect::Connect>DefaultApi for DefaultApiClient<C> impl<C: hyper::client::connect::Connect>DefaultApi for DefaultApiClient<C>
where C: Clone + std::marker::Send + Sync { where C: Clone + std::marker::Send + Sync {
#[allow(unused_mut)] #[allow(unused_mut)]
fn endpoint_get(&self, ) -> Pin<Box<dyn Future<Output = Result<crate::models::EmptyObject, Error>>>> { fn endpoint_get(&self, ) -> Pin<Box<dyn Future<Output = Result<models::EmptyObject, Error>>>> {
let mut req = __internal_request::Request::new(hyper::Method::GET, "/endpoint".to_string()) let mut req = __internal_request::Request::new(hyper::Method::GET, "/endpoint".to_string())
; ;

View File

@ -1,3 +1,5 @@
#![allow(unused_imports)]
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;

View File

@ -8,8 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct EmptyObject { pub struct EmptyObject {
@ -25,4 +24,3 @@ impl EmptyObject {
} }
} }

View File

@ -0,0 +1,3 @@
/target/
**/*.rs.bk
Cargo.lock

View File

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

View File

@ -0,0 +1,19 @@
.gitignore
.travis.yml
Cargo.toml
README.md
docs/Apple.md
docs/DefaultApi.md
docs/Fruit.md
docs/Grape.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/apple.rs
src/models/fruit.rs
src/models/grape.rs
src/models/mod.rs

View File

@ -0,0 +1 @@
7.4.0-SNAPSHOT

View File

@ -0,0 +1 @@
language: rust

View File

@ -0,0 +1,20 @@
[package]
name = "oneof-array-map-hyper"
version = "0.0.1"
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"

View File

@ -0,0 +1,48 @@
# Rust API client for oneof-array-map-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: 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-array-map-hyper` and add the following to `Cargo.toml` under `[dependencies]`:
```
oneof-array-map-hyper = { path = "./oneof-array-map-hyper" }
```
## Documentation for API Endpoints
All URIs are relative to *http://localhost*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**root_get**](docs/DefaultApi.md#root_get) | **Get** / |
*DefaultApi* | [**test**](docs/DefaultApi.md#test) | **Put** / |
## Documentation For Models
- [Apple](docs/Apple.md)
- [Fruit](docs/Fruit.md)
- [Grape](docs/Grape.md)
To get access to the crate's generated documentation, use:
```
cargo doc --open
```
## Author

View File

@ -0,0 +1,11 @@
# Apple
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**kind** | 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)

View File

@ -0,0 +1,63 @@
# \DefaultApi
All URIs are relative to *http://localhost*
Method | HTTP request | Description
------------- | ------------- | -------------
[**root_get**](DefaultApi.md#root_get) | **Get** / |
[**test**](DefaultApi.md#test) | **Put** / |
## root_get
> models::Fruit root_get()
### Parameters
This endpoint does not need any parameter.
### Return type
[**models::Fruit**](fruit.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)
## test
> test(body)
### Parameters
Name | Type | Description | Required | Notes
------------- | ------------- | ------------- | ------------- | -------------
**body** | Option<**serde_json::Value**> | | |
### 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)

View File

@ -0,0 +1,12 @@
# Fruit
## Enum Variants
| Name | Description |
|---- | -----|
| Vec<models::Grape> | |
| std::collections::HashMap<String, models::Apple> | |
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,11 @@
# Grape
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**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)

View 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'

View File

@ -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()
}
}

View File

@ -0,0 +1,43 @@
/*
* fruity
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* 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".to_owned(),
user_agent: Some("OpenAPI-Generator/0.0.1/rust".to_owned()),
client,
basic_auth: None,
oauth_access_token: None,
api_key: None,
}
}
}

View File

@ -0,0 +1,63 @@
/*
* fruity
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* 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 crate::models;
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 root_get(&self, ) -> Pin<Box<dyn Future<Output = Result<models::Fruit, Error>>>>;
fn test(&self, body: Option<serde_json::Value>) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>;
}
impl<C: hyper::client::connect::Connect>DefaultApi for DefaultApiClient<C>
where C: Clone + std::marker::Send + Sync {
#[allow(unused_mut)]
fn root_get(&self, ) -> Pin<Box<dyn Future<Output = Result<models::Fruit, Error>>>> {
let mut req = __internal_request::Request::new(hyper::Method::GET, "/".to_string())
;
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn test(&self, body: Option<serde_json::Value>) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
let mut req = __internal_request::Request::new(hyper::Method::PUT, "/".to_string())
;
req = req.with_body_param(body);
req = req.returns_nothing();
req.execute(self.configuration.borrow())
}
}

View File

@ -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;

View 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(&param).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()
}
}))
}
}

View File

@ -0,0 +1,13 @@
#![allow(unused_imports)]
#[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;

View File

@ -0,0 +1,26 @@
/*
* fruity
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.0.1
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Apple {
#[serde(rename = "kind", skip_serializing_if = "Option::is_none")]
pub kind: Option<String>,
}
impl Apple {
pub fn new() -> Apple {
Apple {
kind: None,
}
}
}

View File

@ -0,0 +1,25 @@
/*
* fruity
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.0.1
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Fruit {
Apples(Box<std::collections::HashMap<String, models::Apple>>),
Grapes(Box<Vec<models::Grape>>),
}
impl Default for Fruit {
fn default() -> Self {
Self::Apples(Box::default())
}
}

View File

@ -0,0 +1,26 @@
/*
* fruity
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.0.1
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Grape {
#[serde(rename = "color", skip_serializing_if = "Option::is_none")]
pub color: Option<String>,
}
impl Grape {
pub fn new() -> Grape {
Grape {
color: None,
}
}
}

View File

@ -0,0 +1,6 @@
pub mod apple;
pub use self::apple::Apple;
pub mod fruit;
pub use self::fruit::Fruit;
pub mod grape;
pub use self::grape::Grape;

View File

@ -0,0 +1,3 @@
/target/
**/*.rs.bk
Cargo.lock

View File

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

View File

@ -0,0 +1,19 @@
.gitignore
.travis.yml
Cargo.toml
README.md
docs/Apple.md
docs/Banana.md
docs/DefaultApi.md
docs/Fruit.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/apple.rs
src/models/banana.rs
src/models/fruit.rs
src/models/mod.rs

View File

@ -0,0 +1 @@
7.4.0-SNAPSHOT

View File

@ -0,0 +1 @@
language: rust

View File

@ -0,0 +1,19 @@
[package]
name = "oneof-reuse-ref-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)"
license = "MIT"
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"

View File

@ -0,0 +1,47 @@
# Rust API client for oneof-reuse-ref-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 `oneof-reuse-ref-hyper` and add the following to `Cargo.toml` under `[dependencies]`:
```
oneof-reuse-ref-hyper = { path = "./oneof-reuse-ref-hyper" }
```
## Documentation for API Endpoints
All URIs are relative to *http://api.example.xyz/v1*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**get_fruit**](docs/DefaultApi.md#get_fruit) | **Get** /example |
## Documentation For Models
- [Apple](docs/Apple.md)
- [Banana](docs/Banana.md)
- [Fruit](docs/Fruit.md)
To get access to the crate's generated documentation, use:
```
cargo doc --open
```
## Author

View File

@ -0,0 +1,12 @@
# Apple
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**cultivar** | Option<**String**> | | [optional]
**origin** | 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)

View File

@ -0,0 +1,11 @@
# Banana
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**length_cm** | Option<**f64**> | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,34 @@
# \DefaultApi
All URIs are relative to *http://api.example.xyz/v1*
Method | HTTP request | Description
------------- | ------------- | -------------
[**get_fruit**](DefaultApi.md#get_fruit) | **Get** /example |
## get_fruit
> models::Fruit get_fruit()
### Parameters
This endpoint does not need any parameter.
### Return type
[**models::Fruit**](Fruit.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)

View 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)

View 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'

View File

@ -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()
}
}

View File

@ -0,0 +1,43 @@
/*
* Example
*
* 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://api.example.xyz/v1".to_owned(),
user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()),
client,
basic_auth: None,
oauth_access_token: None,
api_key: None,
}
}
}

View File

@ -0,0 +1,52 @@
/*
* Example
*
* 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 crate::models;
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 get_fruit(&self, ) -> Pin<Box<dyn Future<Output = Result<models::Fruit, Error>>>>;
}
impl<C: hyper::client::connect::Connect>DefaultApi for DefaultApiClient<C>
where C: Clone + std::marker::Send + Sync {
#[allow(unused_mut)]
fn get_fruit(&self, ) -> Pin<Box<dyn Future<Output = Result<models::Fruit, Error>>>> {
let mut req = __internal_request::Request::new(hyper::Method::GET, "/example".to_string())
;
req.execute(self.configuration.borrow())
}
}

View File

@ -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;

View 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(&param).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()
}
}))
}
}

View File

@ -0,0 +1,13 @@
#![allow(unused_imports)]
#[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;

View File

@ -0,0 +1,29 @@
/*
* Example
*
* 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 crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Apple {
#[serde(rename = "cultivar", skip_serializing_if = "Option::is_none")]
pub cultivar: Option<String>,
#[serde(rename = "origin", skip_serializing_if = "Option::is_none")]
pub origin: Option<String>,
}
impl Apple {
pub fn new() -> Apple {
Apple {
cultivar: None,
origin: None,
}
}
}

View File

@ -0,0 +1,26 @@
/*
* Example
*
* 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 crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Banana {
#[serde(rename = "lengthCm", skip_serializing_if = "Option::is_none")]
pub length_cm: Option<f64>,
}
impl Banana {
pub fn new() -> Banana {
Banana {
length_cm: None,
}
}
}

View File

@ -0,0 +1,30 @@
/*
* Example
*
* 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 crate::models;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "fruitType")]
pub enum Fruit {
#[serde(rename="green_apple")]
GreenApple(Box<models::Apple>),
#[serde(rename="red_apple")]
RedApple(Box<models::Apple>),
#[serde(rename="banana")]
Banana(Box<models::Banana>),
}
impl Default for Fruit {
fn default() -> Self {
Self::GreenApple(Box::default())
}
}

View File

@ -0,0 +1,6 @@
pub mod apple;
pub use self::apple::Apple;
pub mod banana;
pub use self::banana::Banana;
pub mod fruit;
pub use self::fruit::Fruit;

View File

@ -7,7 +7,7 @@ Name | Type | Description | Notes
**id** | **String** | | **id** | **String** | |
**bar_prop_a** | Option<**String**> | | [optional] **bar_prop_a** | Option<**String**> | | [optional]
**foo_prop_b** | Option<**String**> | | [optional] **foo_prop_b** | Option<**String**> | | [optional]
**foo** | Option<[**crate::models::FooRefOrValue**](FooRefOrValue.md)> | | [optional] **foo** | Option<[**models::FooRefOrValue**](FooRefOrValue.md)> | | [optional]
**href** | Option<**String**> | Hyperlink reference | [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_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_base_type** | Option<**String**> | When sub-classing, this defines the super-class | [optional]

View File

@ -10,7 +10,7 @@ Method | HTTP request | Description
## create_bar ## create_bar
> crate::models::Bar create_bar(bar_create) > models::Bar create_bar(bar_create)
Create a Bar Create a Bar
### Parameters ### Parameters
@ -22,7 +22,7 @@ Name | Type | Description | Required | Notes
### Return type ### Return type
[**crate::models::Bar**](Bar.md) [**models::Bar**](Bar.md)
### Authorization ### Authorization

View File

@ -6,7 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**bar_prop_a** | Option<**String**> | | [optional] **bar_prop_a** | Option<**String**> | | [optional]
**foo_prop_b** | Option<**String**> | | [optional] **foo_prop_b** | Option<**String**> | | [optional]
**foo** | Option<[**crate::models::FooRefOrValue**](FooRefOrValue.md)> | | [optional] **foo** | Option<[**models::FooRefOrValue**](FooRefOrValue.md)> | | [optional]
**href** | Option<**String**> | Hyperlink reference | [optional] **href** | Option<**String**> | Hyperlink reference | [optional]
**id** | Option<**String**> | unique identifier | [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_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]

View File

@ -11,7 +11,7 @@ Method | HTTP request | Description
## create_foo ## create_foo
> crate::models::FooRefOrValue create_foo(foo) > models::FooRefOrValue create_foo(foo)
Create a Foo Create a Foo
### Parameters ### Parameters
@ -23,7 +23,7 @@ Name | Type | Description | Required | Notes
### Return type ### Return type
[**crate::models::FooRefOrValue**](FooRefOrValue.md) [**models::FooRefOrValue**](FooRefOrValue.md)
### Authorization ### Authorization
@ -39,7 +39,7 @@ No authorization required
## get_all_foos ## get_all_foos
> Vec<crate::models::FooRefOrValue> get_all_foos() > Vec<models::FooRefOrValue> get_all_foos()
GET all Foos GET all Foos
### Parameters ### Parameters
@ -48,7 +48,7 @@ This endpoint does not need any parameter.
### Return type ### Return type
[**Vec<crate::models::FooRefOrValue>**](FooRefOrValue.md) [**Vec<models::FooRefOrValue>**](FooRefOrValue.md)
### Authorization ### Authorization

View File

@ -4,7 +4,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**pizza_size** | Option<**f32**> | | [optional] **pizza_size** | Option<**f64**> | | [optional]
**href** | Option<**String**> | Hyperlink reference | [optional] **href** | Option<**String**> | Hyperlink reference | [optional]
**id** | Option<**String**> | unique identifier | [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_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]

View File

@ -5,7 +5,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**toppings** | Option<**String**> | | [optional] **toppings** | Option<**String**> | | [optional]
**pizza_size** | Option<**f32**> | | [optional] **pizza_size** | Option<**f64**> | | [optional]
**href** | Option<**String**> | Hyperlink reference | [optional] **href** | Option<**String**> | Hyperlink reference | [optional]
**id** | Option<**String**> | unique identifier | [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_schema_location** | Option<**String**> | A URI to a JSON-Schema file that defines additional attributes and relationships | [optional]

View File

@ -17,6 +17,7 @@ use std::option::Option;
use hyper; use hyper;
use futures::Future; use futures::Future;
use crate::models;
use super::{Error, configuration}; use super::{Error, configuration};
use super::request as __internal_request; use super::request as __internal_request;
@ -35,13 +36,13 @@ impl<C: hyper::client::connect::Connect> BarApiClient<C>
} }
pub trait BarApi { pub trait BarApi {
fn create_bar(&self, bar_create: crate::models::BarCreate) -> Pin<Box<dyn Future<Output = Result<crate::models::Bar, Error>>>>; fn create_bar(&self, bar_create: models::BarCreate) -> Pin<Box<dyn Future<Output = Result<models::Bar, Error>>>>;
} }
impl<C: hyper::client::connect::Connect>BarApi for BarApiClient<C> impl<C: hyper::client::connect::Connect>BarApi for BarApiClient<C>
where C: Clone + std::marker::Send + Sync { where C: Clone + std::marker::Send + Sync {
#[allow(unused_mut)] #[allow(unused_mut)]
fn create_bar(&self, bar_create: crate::models::BarCreate) -> Pin<Box<dyn Future<Output = Result<crate::models::Bar, Error>>>> { fn create_bar(&self, bar_create: models::BarCreate) -> Pin<Box<dyn Future<Output = Result<models::Bar, Error>>>> {
let mut req = __internal_request::Request::new(hyper::Method::POST, "/bar".to_string()) let mut req = __internal_request::Request::new(hyper::Method::POST, "/bar".to_string())
; ;
req = req.with_body_param(bar_create); req = req.with_body_param(bar_create);

View File

@ -17,6 +17,7 @@ use std::option::Option;
use hyper; use hyper;
use futures::Future; use futures::Future;
use crate::models;
use super::{Error, configuration}; use super::{Error, configuration};
use super::request as __internal_request; use super::request as __internal_request;
@ -35,14 +36,14 @@ impl<C: hyper::client::connect::Connect> FooApiClient<C>
} }
pub trait FooApi { pub trait FooApi {
fn create_foo(&self, foo: Option<crate::models::Foo>) -> Pin<Box<dyn Future<Output = Result<crate::models::FooRefOrValue, Error>>>>; fn create_foo(&self, foo: Option<models::Foo>) -> Pin<Box<dyn Future<Output = Result<models::FooRefOrValue, Error>>>>;
fn get_all_foos(&self, ) -> Pin<Box<dyn Future<Output = Result<Vec<crate::models::FooRefOrValue>, Error>>>>; fn get_all_foos(&self, ) -> Pin<Box<dyn Future<Output = Result<Vec<models::FooRefOrValue>, Error>>>>;
} }
impl<C: hyper::client::connect::Connect>FooApi for FooApiClient<C> impl<C: hyper::client::connect::Connect>FooApi for FooApiClient<C>
where C: Clone + std::marker::Send + Sync { where C: Clone + std::marker::Send + Sync {
#[allow(unused_mut)] #[allow(unused_mut)]
fn create_foo(&self, foo: Option<crate::models::Foo>) -> Pin<Box<dyn Future<Output = Result<crate::models::FooRefOrValue, Error>>>> { fn create_foo(&self, foo: Option<models::Foo>) -> Pin<Box<dyn Future<Output = Result<models::FooRefOrValue, Error>>>> {
let mut req = __internal_request::Request::new(hyper::Method::POST, "/foo".to_string()) let mut req = __internal_request::Request::new(hyper::Method::POST, "/foo".to_string())
; ;
req = req.with_body_param(foo); req = req.with_body_param(foo);
@ -51,7 +52,7 @@ impl<C: hyper::client::connect::Connect>FooApi for FooApiClient<C>
} }
#[allow(unused_mut)] #[allow(unused_mut)]
fn get_all_foos(&self, ) -> Pin<Box<dyn Future<Output = Result<Vec<crate::models::FooRefOrValue>, Error>>>> { fn get_all_foos(&self, ) -> Pin<Box<dyn Future<Output = Result<Vec<models::FooRefOrValue>, Error>>>> {
let mut req = __internal_request::Request::new(hyper::Method::GET, "/foo".to_string()) let mut req = __internal_request::Request::new(hyper::Method::GET, "/foo".to_string())
; ;

View File

@ -1,3 +1,5 @@
#![allow(unused_imports)]
#[macro_use] #[macro_use]
extern crate serde_derive; extern crate serde_derive;

View File

@ -8,10 +8,9 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
/// Addressable : Base schema for addressable entities /// Addressable : Base schema for addressable entities
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Addressable { pub struct Addressable {
/// Hyperlink reference /// Hyperlink reference
@ -32,4 +31,3 @@ impl Addressable {
} }
} }

View File

@ -8,8 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Apple { pub struct Apple {
@ -25,4 +24,3 @@ impl Apple {
} }
} }

View File

@ -8,8 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Banana { pub struct Banana {
@ -25,4 +24,3 @@ impl Banana {
} }
} }

View File

@ -8,8 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Bar { pub struct Bar {
@ -20,7 +19,7 @@ pub struct Bar {
#[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")] #[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")]
pub foo_prop_b: Option<String>, pub foo_prop_b: Option<String>,
#[serde(rename = "foo", skip_serializing_if = "Option::is_none")] #[serde(rename = "foo", skip_serializing_if = "Option::is_none")]
pub foo: Option<Box<crate::models::FooRefOrValue>>, pub foo: Option<Box<models::FooRefOrValue>>,
/// Hyperlink reference /// Hyperlink reference
#[serde(rename = "href", skip_serializing_if = "Option::is_none")] #[serde(rename = "href", skip_serializing_if = "Option::is_none")]
pub href: Option<String>, pub href: Option<String>,
@ -50,4 +49,3 @@ impl Bar {
} }
} }

View File

@ -8,8 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct BarCreate { pub struct BarCreate {
@ -18,7 +17,7 @@ pub struct BarCreate {
#[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")] #[serde(rename = "fooPropB", skip_serializing_if = "Option::is_none")]
pub foo_prop_b: Option<String>, pub foo_prop_b: Option<String>,
#[serde(rename = "foo", skip_serializing_if = "Option::is_none")] #[serde(rename = "foo", skip_serializing_if = "Option::is_none")]
pub foo: Option<Box<crate::models::FooRefOrValue>>, pub foo: Option<Box<models::FooRefOrValue>>,
/// Hyperlink reference /// Hyperlink reference
#[serde(rename = "href", skip_serializing_if = "Option::is_none")] #[serde(rename = "href", skip_serializing_if = "Option::is_none")]
pub href: Option<String>, pub href: Option<String>,
@ -51,4 +50,3 @@ impl BarCreate {
} }
} }

View File

@ -8,8 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct BarRef { pub struct BarRef {
@ -50,4 +49,3 @@ impl BarRef {
} }
} }

View File

@ -8,16 +8,13 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use super::Bar; use crate::models;
use super::BarRef;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum BarRefOrValue { pub enum BarRefOrValue {
Bar(Box<Bar>), Bar(Box<models::Bar>),
BarRef(Box<BarRef>), BarRef(Box<models::BarRef>),
} }
impl Default for BarRefOrValue { impl Default for BarRefOrValue {
@ -26,4 +23,3 @@ impl Default for BarRefOrValue {
} }
} }

View File

@ -8,7 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "@type")] #[serde(tag = "@type")]
@ -113,9 +113,8 @@ impl Default for Entity {
at_schema_location: Default::default(), at_schema_location: Default::default(),
at_base_type: Default::default(), at_base_type: Default::default(),
} }
} }
} }

View File

@ -8,9 +8,9 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
/// EntityRef : Entity reference schema to be use for all entityRef class. /// EntityRef : Entity reference schema to be use for all entityRef class.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "@type")] #[serde(tag = "@type")]
pub enum EntityRef { pub enum EntityRef {
@ -68,9 +68,8 @@ impl Default for EntityRef {
at_schema_location: Default::default(), at_schema_location: Default::default(),
at_base_type: Default::default(), at_base_type: Default::default(),
} }
} }
} }

View File

@ -8,8 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Extensible { pub struct Extensible {
@ -34,4 +33,3 @@ impl Extensible {
} }
} }

View File

@ -8,8 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Foo { pub struct Foo {
@ -48,4 +47,3 @@ impl Foo {
} }
} }

View File

@ -8,8 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct FooRef { pub struct FooRef {
@ -53,4 +52,3 @@ impl FooRef {
} }
} }

View File

@ -8,15 +8,15 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use super::Foo; use crate::models;
use super::FooRef;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "@type")] #[serde(tag = "@type")]
pub enum FooRefOrValue { pub enum FooRefOrValue {
Foo(Box<Foo>), #[serde(rename="Foo")]
FooRef(Box<FooRef>), Foo(Box<models::Foo>),
#[serde(rename="FooRef")]
FooRef(Box<models::FooRef>),
} }
impl Default for FooRefOrValue { impl Default for FooRefOrValue {
@ -26,5 +26,3 @@ impl Default for FooRefOrValue {
} }

View File

@ -8,15 +8,15 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use super::Apple; use crate::models;
use super::Banana;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "fruitType")] #[serde(tag = "fruitType")]
pub enum Fruit { pub enum Fruit {
Apple(Box<Apple>), #[serde(rename="APPLE")]
Banana(Box<Banana>), Apple(Box<models::Apple>),
#[serde(rename="BANANA")]
Banana(Box<models::Banana>),
} }
impl Default for Fruit { impl Default for Fruit {
@ -26,5 +26,3 @@ impl Default for Fruit {
} }

View File

@ -8,6 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
/// ///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
@ -34,6 +35,3 @@ impl Default for FruitType {
} }
} }

View File

@ -8,8 +8,7 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Pasta { pub struct Pasta {
@ -45,4 +44,3 @@ impl Pasta {
} }
} }

View File

@ -8,13 +8,12 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Pizza { pub struct Pizza {
#[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")] #[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")]
pub pizza_size: Option<f32>, pub pizza_size: Option<f64>,
/// Hyperlink reference /// Hyperlink reference
#[serde(rename = "href", skip_serializing_if = "Option::is_none")] #[serde(rename = "href", skip_serializing_if = "Option::is_none")]
pub href: Option<String>, pub href: Option<String>,
@ -45,4 +44,3 @@ impl Pizza {
} }
} }

View File

@ -8,15 +8,14 @@
* Generated by: https://openapi-generator.tech * Generated by: https://openapi-generator.tech
*/ */
use crate::models;
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct PizzaSpeziale { pub struct PizzaSpeziale {
#[serde(rename = "toppings", skip_serializing_if = "Option::is_none")] #[serde(rename = "toppings", skip_serializing_if = "Option::is_none")]
pub toppings: Option<String>, pub toppings: Option<String>,
#[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")] #[serde(rename = "pizzaSize", skip_serializing_if = "Option::is_none")]
pub pizza_size: Option<f32>, pub pizza_size: Option<f64>,
/// Hyperlink reference /// Hyperlink reference
#[serde(rename = "href", skip_serializing_if = "Option::is_none")] #[serde(rename = "href", skip_serializing_if = "Option::is_none")]
pub href: Option<String>, pub href: Option<String>,
@ -48,4 +47,3 @@ impl PizzaSpeziale {
} }
} }

Some files were not shown because too many files have changed in this diff Show More