mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-06-29 20:20:53 +00:00
[Rust] [Axum] Deduplicate code from rust-axum generator (#17588)
* [Rust] [Axum] Deduplicate code from rust-axum generator * Fix build
This commit is contained in:
parent
61c40474af
commit
be19c35c45
@ -11,7 +11,6 @@ import io.swagger.v3.oas.models.parameters.Parameter;
|
|||||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||||
import io.swagger.v3.oas.models.servers.Server;
|
import io.swagger.v3.oas.models.servers.Server;
|
||||||
import joptsimple.internal.Strings;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openapitools.codegen.*;
|
import org.openapitools.codegen.*;
|
||||||
@ -26,14 +25,13 @@ import org.openapitools.codegen.model.ModelsMap;
|
|||||||
import org.openapitools.codegen.model.OperationMap;
|
import org.openapitools.codegen.model.OperationMap;
|
||||||
import org.openapitools.codegen.model.OperationsMap;
|
import org.openapitools.codegen.model.OperationsMap;
|
||||||
import org.openapitools.codegen.utils.ModelUtils;
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
import org.openapitools.codegen.utils.URLPathUtils;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.net.URL;
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -42,17 +40,31 @@ import static org.openapitools.codegen.utils.StringUtils.underscore;
|
|||||||
|
|
||||||
public class RustAxumServerCodegen extends AbstractRustCodegen implements CodegenConfig {
|
public class RustAxumServerCodegen extends AbstractRustCodegen implements CodegenConfig {
|
||||||
public static final String PROJECT_NAME = "openapi-server";
|
public static final String PROJECT_NAME = "openapi-server";
|
||||||
|
private static final String apiPath = "rust-axum";
|
||||||
|
|
||||||
|
private String packageName;
|
||||||
|
private String packageVersion;
|
||||||
|
private Boolean disableValidator = false;
|
||||||
|
private Boolean allowBlockingValidator = false;
|
||||||
|
private Boolean allowBlockingResponseSerialize = false;
|
||||||
|
private String externCrateName;
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
private static final String uuidType = "uuid::Uuid";
|
private static final String uuidType = "uuid::Uuid";
|
||||||
private static final String bytesType = "ByteArray";
|
private static final String bytesType = "ByteArray";
|
||||||
|
private static final String dateType = "chrono::naive::NaiveDate";
|
||||||
|
private static final String dateTimeType = "chrono::DateTime::<chrono::Utc>";
|
||||||
|
private static final String stringType = "String";
|
||||||
|
private static final String objectType = "crate::types::Object";
|
||||||
|
private static final String mapType = "std::collections::HashMap";
|
||||||
|
private static final String vecType = "Vec";
|
||||||
|
|
||||||
|
// Mime
|
||||||
private static final String octetMimeType = "application/octet-stream";
|
private static final String octetMimeType = "application/octet-stream";
|
||||||
private static final String plainTextMimeType = "text/plain";
|
private static final String plainTextMimeType = "text/plain";
|
||||||
|
|
||||||
private static final String xmlMimeType = "application/xml";
|
private static final String xmlMimeType = "application/xml";
|
||||||
private static final String textXmlMimeType = "text/xml";
|
private static final String textXmlMimeType = "text/xml";
|
||||||
|
|
||||||
private static final String formUrlEncodedMimeType = "application/x-www-form-urlencoded";
|
private static final String formUrlEncodedMimeType = "application/x-www-form-urlencoded";
|
||||||
|
|
||||||
private static final String jsonMimeType = "application/json";
|
private static final String jsonMimeType = "application/json";
|
||||||
// RFC 7386 support
|
// RFC 7386 support
|
||||||
private static final String mergePatchJsonMimeType = "application/merge-patch+json";
|
private static final String mergePatchJsonMimeType = "application/merge-patch+json";
|
||||||
@ -60,19 +72,11 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
private static final String problemJsonMimeType = "application/problem+json";
|
private static final String problemJsonMimeType = "application/problem+json";
|
||||||
private static final String problemXmlMimeType = "application/problem+xml";
|
private static final String problemXmlMimeType = "application/problem+xml";
|
||||||
|
|
||||||
private final Logger LOGGER = LoggerFactory.getLogger(RustAxumServerCodegen.class);
|
|
||||||
// Grouping (Method, Operation) by Path.
|
// Grouping (Method, Operation) by Path.
|
||||||
private final Map<String, ArrayList<MethodOperation>> pathMethodOpMap = new HashMap<>();
|
private final Map<String, ArrayList<MethodOperation>> pathMethodOpMap = new HashMap<>();
|
||||||
|
|
||||||
protected String apiVersion = "1.0.0";
|
// Logger
|
||||||
protected String apiPath = "rust-axum";
|
private final Logger LOGGER = LoggerFactory.getLogger(RustAxumServerCodegen.class);
|
||||||
protected String packageName;
|
|
||||||
protected String packageVersion;
|
|
||||||
protected Boolean disableValidator = false;
|
|
||||||
protected Boolean allowBlockingValidator = false;
|
|
||||||
protected Boolean allowBlockingResponseSerialize = false;
|
|
||||||
protected String externCrateName;
|
|
||||||
protected int serverPort = 8080;
|
|
||||||
|
|
||||||
public RustAxumServerCodegen() {
|
public RustAxumServerCodegen() {
|
||||||
super();
|
super();
|
||||||
@ -109,7 +113,7 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
hideGenerationTimestamp = Boolean.FALSE;
|
hideGenerationTimestamp = Boolean.FALSE;
|
||||||
|
|
||||||
// set the output folder here
|
// set the output folder here
|
||||||
outputFolder = "generated-code" + File.separator + "rust-axum";
|
outputFolder = Path.of("generated-code", "rust-axum").toString();
|
||||||
embeddedTemplateDir = templateDir = "rust-axum";
|
embeddedTemplateDir = templateDir = "rust-axum";
|
||||||
|
|
||||||
importMapping = new HashMap<>();
|
importMapping = new HashMap<>();
|
||||||
@ -118,13 +122,11 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
|
|
||||||
// types
|
// types
|
||||||
defaultIncludes = new HashSet<>(
|
defaultIncludes = new HashSet<>(
|
||||||
Arrays.asList(
|
Set.of("map", "array")
|
||||||
"map",
|
|
||||||
"array")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
languageSpecificPrimitives = new HashSet<>(
|
languageSpecificPrimitives = new HashSet<>(
|
||||||
Arrays.asList(
|
Set.of(
|
||||||
"bool",
|
"bool",
|
||||||
"char",
|
"char",
|
||||||
"i8",
|
"i8",
|
||||||
@ -140,49 +142,48 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
"f32",
|
"f32",
|
||||||
"f64",
|
"f64",
|
||||||
"str",
|
"str",
|
||||||
"String")
|
stringType)
|
||||||
);
|
);
|
||||||
|
assert languageSpecificPrimitives.size() == 16;
|
||||||
|
|
||||||
instantiationTypes.clear();
|
instantiationTypes = new HashMap<>(
|
||||||
instantiationTypes.put("array", "Vec");
|
Map.of(
|
||||||
instantiationTypes.put("map", "std::collections::HashMap");
|
"array", vecType,
|
||||||
|
"map", mapType
|
||||||
|
)
|
||||||
|
);
|
||||||
|
assert instantiationTypes.size() == 2;
|
||||||
|
|
||||||
typeMapping.clear();
|
typeMapping = new HashMap<>(Map.ofEntries(
|
||||||
typeMapping.put("number", "f64");
|
new AbstractMap.SimpleEntry<>("number", "f64"),
|
||||||
typeMapping.put("integer", "i32");
|
new AbstractMap.SimpleEntry<>("integer", "i32"),
|
||||||
typeMapping.put("long", "i64");
|
new AbstractMap.SimpleEntry<>("long", "i64"),
|
||||||
typeMapping.put("float", "f32");
|
new AbstractMap.SimpleEntry<>("float", "f32"),
|
||||||
typeMapping.put("double", "f64");
|
new AbstractMap.SimpleEntry<>("double", "f64"),
|
||||||
typeMapping.put("string", "String");
|
new AbstractMap.SimpleEntry<>("string", stringType),
|
||||||
typeMapping.put("UUID", uuidType);
|
new AbstractMap.SimpleEntry<>("UUID", uuidType),
|
||||||
typeMapping.put("URI", "String");
|
new AbstractMap.SimpleEntry<>("URI", stringType),
|
||||||
typeMapping.put("byte", "u8");
|
new AbstractMap.SimpleEntry<>("byte", "u8"),
|
||||||
typeMapping.put("ByteArray", bytesType);
|
new AbstractMap.SimpleEntry<>("ByteArray", bytesType),
|
||||||
typeMapping.put("binary", bytesType);
|
new AbstractMap.SimpleEntry<>("binary", bytesType),
|
||||||
typeMapping.put("boolean", "bool");
|
new AbstractMap.SimpleEntry<>("boolean", "bool"),
|
||||||
typeMapping.put("date", "chrono::naive::NaiveDate");
|
new AbstractMap.SimpleEntry<>("date", dateType),
|
||||||
typeMapping.put("DateTime", "chrono::DateTime::<chrono::Utc>");
|
new AbstractMap.SimpleEntry<>("DateTime", dateTimeType),
|
||||||
typeMapping.put("password", "String");
|
new AbstractMap.SimpleEntry<>("password", stringType),
|
||||||
typeMapping.put("File", "ByteArray");
|
new AbstractMap.SimpleEntry<>("File", bytesType),
|
||||||
typeMapping.put("file", "ByteArray");
|
new AbstractMap.SimpleEntry<>("file", bytesType),
|
||||||
typeMapping.put("array", "Vec");
|
new AbstractMap.SimpleEntry<>("array", vecType),
|
||||||
typeMapping.put("map", "std::collections::HashMap");
|
new AbstractMap.SimpleEntry<>("map", mapType),
|
||||||
typeMapping.put("object", "crate::types::Object");
|
new AbstractMap.SimpleEntry<>("object", objectType),
|
||||||
typeMapping.put("AnyType", "crate::types::Object");
|
new AbstractMap.SimpleEntry<>("AnyType", objectType)
|
||||||
|
));
|
||||||
|
assert typeMapping.size() == 21;
|
||||||
|
|
||||||
// cli options
|
// cli options
|
||||||
cliOptions.clear();
|
|
||||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME,
|
|
||||||
"Rust crate name (convention: snake_case).")
|
|
||||||
.defaultValue("openapi"));
|
|
||||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION,
|
|
||||||
"Rust crate version."));
|
|
||||||
|
|
||||||
CliOption optDisableValidator = new CliOption("disableValidator", "Disable validating request-data (header, path, query, body) " +
|
CliOption optDisableValidator = new CliOption("disableValidator", "Disable validating request-data (header, path, query, body) " +
|
||||||
"against OpenAPI Schema Specification.");
|
"against OpenAPI Schema Specification.");
|
||||||
optDisableValidator.setType("bool");
|
optDisableValidator.setType("bool");
|
||||||
optDisableValidator.defaultValue(disableValidator.toString());
|
optDisableValidator.defaultValue(disableValidator.toString());
|
||||||
cliOptions.add(optDisableValidator);
|
|
||||||
|
|
||||||
CliOption optAllowBlockingValidator = new CliOption("allowBlockingValidator",
|
CliOption optAllowBlockingValidator = new CliOption("allowBlockingValidator",
|
||||||
String.join("",
|
String.join("",
|
||||||
@ -193,7 +194,6 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
"is low cost."));
|
"is low cost."));
|
||||||
optAllowBlockingValidator.setType("bool");
|
optAllowBlockingValidator.setType("bool");
|
||||||
optAllowBlockingValidator.defaultValue(allowBlockingValidator.toString());
|
optAllowBlockingValidator.defaultValue(allowBlockingValidator.toString());
|
||||||
cliOptions.add(optAllowBlockingValidator);
|
|
||||||
|
|
||||||
CliOption optAllowBlockingResponseSerialize = new CliOption("allowBlockingResponseSerialize",
|
CliOption optAllowBlockingResponseSerialize = new CliOption("allowBlockingResponseSerialize",
|
||||||
String.join("", "By default, json/form-urlencoded response serialization, which might ",
|
String.join("", "By default, json/form-urlencoded response serialization, which might ",
|
||||||
@ -203,10 +203,19 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
"serialization (e.g. returns tiny data) is low cost."));
|
"serialization (e.g. returns tiny data) is low cost."));
|
||||||
optAllowBlockingResponseSerialize.setType("bool");
|
optAllowBlockingResponseSerialize.setType("bool");
|
||||||
optAllowBlockingResponseSerialize.defaultValue(allowBlockingResponseSerialize.toString());
|
optAllowBlockingResponseSerialize.defaultValue(allowBlockingResponseSerialize.toString());
|
||||||
cliOptions.add(optAllowBlockingResponseSerialize);
|
|
||||||
|
|
||||||
additionalProperties.put("apiVersion", apiVersion);
|
cliOptions = new ArrayList<>(
|
||||||
additionalProperties.put("apiPath", apiPath);
|
List.of(
|
||||||
|
new CliOption(CodegenConstants.PACKAGE_NAME,
|
||||||
|
"Rust crate name (convention: snake_case).")
|
||||||
|
.defaultValue("openapi"),
|
||||||
|
new CliOption(CodegenConstants.PACKAGE_VERSION,
|
||||||
|
"Rust crate version."),
|
||||||
|
optDisableValidator,
|
||||||
|
optAllowBlockingValidator,
|
||||||
|
optAllowBlockingResponseSerialize
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("Cargo.mustache", "", "Cargo.toml"));
|
supportingFiles.add(new SupportingFile("Cargo.mustache", "", "Cargo.toml"));
|
||||||
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
|
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
|
||||||
@ -276,7 +285,7 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey("allowBlockingResponseSerialize")) {
|
if (additionalProperties.containsKey("allowBlockingResponseSerialize")) {
|
||||||
allowBlockingValidator = convertPropertyToBooleanAndWriteBack("allowBlockingResponseSerialize");
|
allowBlockingResponseSerialize = convertPropertyToBooleanAndWriteBack("allowBlockingResponseSerialize");
|
||||||
} else {
|
} else {
|
||||||
additionalProperties.put("allowBlockingResponseSerialize", allowBlockingResponseSerialize);
|
additionalProperties.put("allowBlockingResponseSerialize", allowBlockingResponseSerialize);
|
||||||
}
|
}
|
||||||
@ -302,10 +311,6 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||||
Info info = openAPI.getInfo();
|
Info info = openAPI.getInfo();
|
||||||
|
|
||||||
URL url = URLPathUtils.getServerURL(openAPI, serverVariableOverrides());
|
|
||||||
additionalProperties.put("serverHost", url.getHost());
|
|
||||||
additionalProperties.put("serverPort", URLPathUtils.getPort(url, serverPort));
|
|
||||||
|
|
||||||
if (packageVersion == null || packageVersion.isEmpty()) {
|
if (packageVersion == null || packageVersion.isEmpty()) {
|
||||||
List<String> versionComponents = new ArrayList<>(Arrays.asList(info.getVersion().split("[.]")));
|
List<String> versionComponents = new ArrayList<>(Arrays.asList(info.getVersion().split("[.]")));
|
||||||
if (versionComponents.isEmpty()) {
|
if (versionComponents.isEmpty()) {
|
||||||
@ -323,10 +328,9 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toApiName(String name) {
|
public String toApiName(String name) {
|
||||||
if (name.isEmpty()) {
|
return name.isEmpty() ?
|
||||||
return "default";
|
"default" :
|
||||||
}
|
sanitizeIdentifier(name, CasingType.SNAKE_CASE, "api", "API", true);
|
||||||
return sanitizeIdentifier(name, CasingType.SNAKE_CASE, "api", "API", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -335,7 +339,7 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String apiFileFolder() {
|
public String apiFileFolder() {
|
||||||
return outputFolder + File.separator + apiPackage().replace('.', File.separatorChar);
|
return Path.of(outputFolder, apiPackage().replace('.', File.separatorChar)).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -348,6 +352,10 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
return "\"" + super.toEnumValue(value, datatype) + "\"";
|
return "\"" + super.toEnumValue(value, datatype) + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isObjectType(String type) {
|
||||||
|
return "object".equals(type);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isMimetypeXml(String mimetype) {
|
private boolean isMimetypeXml(String mimetype) {
|
||||||
return mimetype.toLowerCase(Locale.ROOT).startsWith(xmlMimeType) ||
|
return mimetype.toLowerCase(Locale.ROOT).startsWith(xmlMimeType) ||
|
||||||
mimetype.toLowerCase(Locale.ROOT).startsWith(problemXmlMimeType) ||
|
mimetype.toLowerCase(Locale.ROOT).startsWith(problemXmlMimeType) ||
|
||||||
@ -483,11 +491,6 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
outputMime = jsonMimeType;
|
outputMime = jsonMimeType;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If we know exactly what mimetype this response is
|
|
||||||
// going to produce, then use that. If we have not found
|
|
||||||
// anything, then we'll fall back to the 'producesXXX'
|
|
||||||
// definitions we worked out above for the operation as a
|
|
||||||
// whole.
|
|
||||||
if (isMimetypeWwwFormUrlEncoded(firstProduces)) {
|
if (isMimetypeWwwFormUrlEncoded(firstProduces)) {
|
||||||
producesFormUrlEncoded = true;
|
producesFormUrlEncoded = true;
|
||||||
producesPlainText = false;
|
producesPlainText = false;
|
||||||
@ -509,8 +512,6 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
|
|
||||||
rsp.vendorExtensions.put("x-mime-type", outputMime);
|
rsp.vendorExtensions.put("x-mime-type", outputMime);
|
||||||
|
|
||||||
// Write out the type of data we actually expect this response
|
|
||||||
// to make.
|
|
||||||
if (producesFormUrlEncoded) {
|
if (producesFormUrlEncoded) {
|
||||||
rsp.vendorExtensions.put("x-produces-form-urlencoded", true);
|
rsp.vendorExtensions.put("x-produces-form-urlencoded", true);
|
||||||
} else if (producesPlainText) {
|
} else if (producesPlainText) {
|
||||||
@ -529,11 +530,8 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rsp.vendorExtensions.put("x-produces-json", true);
|
rsp.vendorExtensions.put("x-produces-json", true);
|
||||||
// If the data type is just "object", then ensure that the
|
if (isObjectType(rsp.dataType)) {
|
||||||
// Rust data type is "crate::types::Object". This allows us
|
rsp.dataType = objectType;
|
||||||
// to define APIs that can return arbitrary JSON bodies.
|
|
||||||
if ("object".equals(rsp.dataType)) {
|
|
||||||
rsp.dataType = "crate::types::Object";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -557,15 +555,15 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
public OperationsMap postProcessOperationsWithModels(OperationsMap operationsMap, List<ModelMap> allModels) {
|
||||||
OperationMap operations = objs.getOperations();
|
OperationMap operations = operationsMap.getOperations();
|
||||||
List<CodegenOperation> operationList = operations.getOperation();
|
List<CodegenOperation> operationList = operations.getOperation();
|
||||||
|
|
||||||
for (CodegenOperation op : operationList) {
|
for (CodegenOperation op : operationList) {
|
||||||
postProcessOperationWithModels(op);
|
postProcessOperationWithModels(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
return objs;
|
return operationsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void postProcessOperationWithModels(CodegenOperation op) {
|
private void postProcessOperationWithModels(CodegenOperation op) {
|
||||||
@ -793,7 +791,8 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
String defaultValue = null;
|
String defaultValue = null;
|
||||||
if ((ModelUtils.isNullable(p)) && (p.getDefault() != null) && ("null".equalsIgnoreCase(p.getDefault().toString())))
|
if ((ModelUtils.isNullable(p)) && (p.getDefault() != null) && ("null".equalsIgnoreCase(p.getDefault().toString())))
|
||||||
return "Nullable::Null";
|
return "Nullable::Null";
|
||||||
else if (ModelUtils.isBooleanSchema(p)) {
|
|
||||||
|
if (ModelUtils.isBooleanSchema(p)) {
|
||||||
if (p.getDefault() != null) {
|
if (p.getDefault() != null) {
|
||||||
if ("false".equalsIgnoreCase(p.getDefault().toString()))
|
if ("false".equalsIgnoreCase(p.getDefault().toString()))
|
||||||
defaultValue = "false";
|
defaultValue = "false";
|
||||||
@ -813,18 +812,20 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
defaultValue = "\"" + p.getDefault() + "\".to_string()";
|
defaultValue = "\"" + p.getDefault() + "\".to_string()";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((defaultValue != null) && (ModelUtils.isNullable(p)))
|
if ((defaultValue != null) && (ModelUtils.isNullable(p)))
|
||||||
defaultValue = "Nullable::Present(" + defaultValue + ")";
|
defaultValue = "Nullable::Present(" + defaultValue + ")";
|
||||||
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||||
super.postProcessModelProperty(model, property);
|
super.postProcessModelProperty(model, property);
|
||||||
|
|
||||||
if (!languageSpecificPrimitives.contains(property.dataType)) {
|
if (!languageSpecificPrimitives.contains(property.dataType)) {
|
||||||
// If we use a more qualified model name, then only camelize the actual type, not the qualifier.
|
final int position = property.dataType.lastIndexOf(":");
|
||||||
if (property.dataType.contains(":")) {
|
if (position != -1) {
|
||||||
int position = property.dataType.lastIndexOf(":");
|
|
||||||
property.dataType = property.dataType.substring(0, position) + camelize(property.dataType.substring(position));
|
property.dataType = property.dataType.substring(0, position) + camelize(property.dataType.substring(position));
|
||||||
} else {
|
} else {
|
||||||
property.dataType = camelize(property.dataType);
|
property.dataType = camelize(property.dataType);
|
||||||
@ -836,42 +837,12 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
|
|
||||||
// Integer type fitting
|
// Integer type fitting
|
||||||
if (Objects.equals(property.baseType, "integer")) {
|
if (Objects.equals(property.baseType, "integer")) {
|
||||||
|
|
||||||
BigInteger minimum = Optional.ofNullable(property.getMinimum()).map(BigInteger::new).orElse(null);
|
BigInteger minimum = Optional.ofNullable(property.getMinimum()).map(BigInteger::new).orElse(null);
|
||||||
BigInteger maximum = Optional.ofNullable(property.getMaximum()).map(BigInteger::new).orElse(null);
|
BigInteger maximum = Optional.ofNullable(property.getMaximum()).map(BigInteger::new).orElse(null);
|
||||||
|
property.dataType = bestFittingIntegerType(
|
||||||
boolean unsigned = canFitIntoUnsigned(minimum, property.getExclusiveMinimum());
|
minimum, property.getExclusiveMinimum(),
|
||||||
|
maximum, property.getExclusiveMaximum(),
|
||||||
if (Strings.isNullOrEmpty(property.dataFormat)) {
|
|
||||||
property.dataType = bestFittingIntegerType(minimum,
|
|
||||||
property.getExclusiveMinimum(),
|
|
||||||
maximum,
|
|
||||||
property.getExclusiveMaximum(),
|
|
||||||
true);
|
true);
|
||||||
} else {
|
|
||||||
switch (property.dataFormat) {
|
|
||||||
// custom integer formats (legacy)
|
|
||||||
case "uint32":
|
|
||||||
property.dataType = "u32";
|
|
||||||
break;
|
|
||||||
case "uint64":
|
|
||||||
property.dataType = "u64";
|
|
||||||
break;
|
|
||||||
case "int32":
|
|
||||||
property.dataType = unsigned ? "u32" : "i32";
|
|
||||||
break;
|
|
||||||
case "int64":
|
|
||||||
property.dataType = unsigned ? "u64" : "i64";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
LOGGER.warn("The integer format '{}' is not recognized and will be ignored.", property.dataFormat);
|
|
||||||
property.dataType = bestFittingIntegerType(minimum,
|
|
||||||
property.getExclusiveMinimum(),
|
|
||||||
maximum,
|
|
||||||
property.getExclusiveMaximum(),
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
property.name = underscore(property.name);
|
property.name = underscore(property.name);
|
||||||
@ -880,57 +851,41 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
property.defaultValue = (property.defaultValue != null) ? "Some(" + property.defaultValue + ")" : "None";
|
property.defaultValue = (property.defaultValue != null) ? "Some(" + property.defaultValue + ")" : "None";
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a property has no type defined in the schema, it can take values of any type.
|
if (isObjectType(property.baseType)) {
|
||||||
// This clashes with Rust being statically typed. Hence, assume it's sent as a json
|
property.dataType = objectType;
|
||||||
// blob and return the json value to the user of the API and let the user determine
|
|
||||||
// the type from the value. If the property has no type, at this point it will have
|
|
||||||
// baseType "object" allowing us to identify such properties. Moreover, set to not
|
|
||||||
// nullable, we can use the crate::types::Object::Null enum variant.
|
|
||||||
if ("object".equals(property.baseType)) {
|
|
||||||
property.dataType = "crate::types::Object";
|
|
||||||
property.isNullable = false;
|
property.isNullable = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ModelsMap postProcessModels(ModelsMap objs) {
|
public ModelsMap postProcessModels(ModelsMap modelsMap) {
|
||||||
for (ModelMap mo : objs.getModels()) {
|
for (ModelMap mo : modelsMap.getModels()) {
|
||||||
CodegenModel cm = mo.getModel();
|
CodegenModel cm = mo.getModel();
|
||||||
|
|
||||||
LOGGER.trace("Post processing model: {}", cm);
|
LOGGER.trace("Post processing model: {}", cm);
|
||||||
|
|
||||||
if ("object".equals(cm.dataType)) {
|
if (isObjectType(cm.dataType)) {
|
||||||
// Object isn't a sensible default. Instead, we set it to
|
// Object isn't a sensible default. Instead, we set it to
|
||||||
// 'null'. This ensures that we treat this model as a struct
|
// 'null'. This ensures that we treat this model as a struct
|
||||||
// with multiple parameters.
|
// with multiple parameters.
|
||||||
cm.dataType = null;
|
cm.dataType = null;
|
||||||
} else if ("map".equals(cm.dataType)) {
|
} else if ("map".equals(cm.dataType)) {
|
||||||
if (!cm.allVars.isEmpty() || cm.additionalPropertiesType == null) {
|
if (!cm.allVars.isEmpty() || cm.additionalPropertiesType == null) {
|
||||||
// We don't yet support `additionalProperties` that also have
|
|
||||||
// properties. If we see variables, we ignore the
|
|
||||||
// `additionalProperties` type ('map') and warn the user. This
|
|
||||||
// will produce code that compiles, but won't feature the
|
|
||||||
// `additionalProperties` - but that's likely more useful to
|
|
||||||
// the user than the alternative.
|
|
||||||
LOGGER.warn("Ignoring additionalProperties (see https://github.com/OpenAPITools/openapi-generator/issues/318) alongside defined properties");
|
LOGGER.warn("Ignoring additionalProperties (see https://github.com/OpenAPITools/openapi-generator/issues/318) alongside defined properties");
|
||||||
cm.dataType = null;
|
cm.dataType = null;
|
||||||
} else {
|
} else {
|
||||||
cm.dataType = "std::collections::HashMap<String, " + cm.additionalPropertiesType + ">";
|
cm.dataType = mapType + "<String, " + cm.additionalPropertiesType + ">";
|
||||||
}
|
}
|
||||||
} else if (cm.dataType != null) {
|
} else if (cm.dataType != null) {
|
||||||
// We need to hack about with single-parameter models to
|
// We need to hack about with single-parameter models to
|
||||||
// get them recognised correctly.
|
// get them recognised correctly.
|
||||||
cm.isAlias = false;
|
cm.isAlias = false;
|
||||||
cm.dataType = typeMapping.get(cm.dataType);
|
cm.dataType = typeMapping.get(cm.dataType);
|
||||||
|
|
||||||
if (uuidType.equals(cm.dataType)) {
|
|
||||||
additionalProperties.put("apiUsesUuid", true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cm.vendorExtensions.put("x-is-string", "String".equals(cm.dataType));
|
cm.vendorExtensions.put("x-is-string", stringType.equals(cm.dataType));
|
||||||
}
|
}
|
||||||
return super.postProcessModelsEnum(objs);
|
return super.postProcessModelsEnum(modelsMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -939,24 +894,30 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String commandPrefix = System.getenv("RUST_POST_PROCESS_FILE");
|
final String fileName = file.toString();
|
||||||
if (StringUtils.isEmpty(commandPrefix)) {
|
|
||||||
commandPrefix = "rustfmt";
|
String[] command;
|
||||||
|
|
||||||
|
String cmd = System.getenv("RUST_POST_PROCESS_FILE");
|
||||||
|
if (StringUtils.isEmpty(cmd)) {
|
||||||
|
cmd = "rustfmt";
|
||||||
|
command = new String[]{cmd, "--edition", "2021", fileName};
|
||||||
|
} else {
|
||||||
|
command = new String[]{cmd, fileName};
|
||||||
}
|
}
|
||||||
|
|
||||||
// only process files with .rs extension
|
// only process files with .rs extension
|
||||||
if ("rs".equals(FilenameUtils.getExtension(file.toString()))) {
|
if ("rs".equals(FilenameUtils.getExtension(fileName))) {
|
||||||
try {
|
try {
|
||||||
Process p = Runtime.getRuntime().exec(new String[]{commandPrefix, "--edition", "2021", file.toString()});
|
Process p = Runtime.getRuntime().exec(command);
|
||||||
int exitValue = p.waitFor();
|
int exitValue = p.waitFor();
|
||||||
if (exitValue != 0) {
|
if (exitValue != 0) {
|
||||||
LOGGER.error("Error running the command ({} {}). Exit code: {}", commandPrefix, file, exitValue);
|
LOGGER.error("Error running the command ({} {}). Exit code: {}", cmd, file, exitValue);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.info("Successfully executed: {} {}", commandPrefix, file);
|
LOGGER.info("Successfully executed: {} {}", cmd, file);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException | IOException e) {
|
} catch (InterruptedException | IOException e) {
|
||||||
LOGGER.error("Error running the command ({} {}). Exception: {}", commandPrefix, file, e.getMessage());
|
LOGGER.error("Error running the command ({} {}). Exception: {}", cmd, file, e.getMessage());
|
||||||
// Restore interrupted state
|
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -964,9 +925,6 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateParameterForString(CodegenParameter codegenParameter, Schema parameterSchema) {
|
protected void updateParameterForString(CodegenParameter codegenParameter, Schema parameterSchema) {
|
||||||
/*
|
|
||||||
we have a custom version of this function to set isString to false for uuid
|
|
||||||
*/
|
|
||||||
if (ModelUtils.isEmailSchema(parameterSchema)) {
|
if (ModelUtils.isEmailSchema(parameterSchema)) {
|
||||||
codegenParameter.isEmail = true;
|
codegenParameter.isEmail = true;
|
||||||
} else if (ModelUtils.isUUIDSchema(parameterSchema)) {
|
} else if (ModelUtils.isUUIDSchema(parameterSchema)) {
|
||||||
@ -1000,9 +958,6 @@ public class RustAxumServerCodegen extends AbstractRustCodegen implements Codege
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updatePropertyForAnyType(CodegenProperty property, Schema p) {
|
protected void updatePropertyForAnyType(CodegenProperty property, Schema p) {
|
||||||
/*
|
|
||||||
* we have a custom version of this function to not set isNullable to true
|
|
||||||
*/
|
|
||||||
// The 'null' value is allowed when the OAS schema is 'any type'.
|
// The 'null' value is allowed when the OAS schema is 'any type'.
|
||||||
// See https://github.com/OAI/OpenAPI-Specification/issues/1389
|
// See https://github.com/OAI/OpenAPI-Specification/issues/1389
|
||||||
if (Boolean.FALSE.equals(p.getNullable())) {
|
if (Boolean.FALSE.equals(p.getNullable())) {
|
||||||
|
@ -30,11 +30,16 @@ macro_rules! ihv_generate {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||||
Err(e) => Err(format!("Unable to parse {} as a string: {}",
|
Err(e) => Err(format!(
|
||||||
stringify!($t), e)),
|
"Unable to parse {} as a string: {}",
|
||||||
|
stringify!($t),
|
||||||
|
e
|
||||||
|
)),
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to parse header {:?} as a string - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,9 +79,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
|
|||||||
"" => None,
|
"" => None,
|
||||||
y => Some(y.to_string()),
|
y => Some(y.to_string()),
|
||||||
})
|
})
|
||||||
.collect())),
|
.collect(),
|
||||||
Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
|
)),
|
||||||
hdr_value, e)),
|
Err(e) => Err(format!(
|
||||||
|
"Unable to parse header: {:?} as a string - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,8 +95,10 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert {:?} into a header - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,8 +111,7 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
|
|||||||
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
||||||
Err(e) => Err(format!("Unable to convert header {:?} to {}",
|
Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,8 +122,10 @@ impl TryFrom<IntoHeaderValue<String>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0) {
|
match HeaderValue::from_str(&hdr_value.0) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert {:?} from a header {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,11 +139,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match hdr_value.parse() {
|
Ok(hdr_value) => match hdr_value.parse() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||||
Err(e) => Err(format!("Unable to parse bool from {} - {}",
|
Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert {:?} from a header {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,8 +155,10 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert: {:?} into a header: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,11 +172,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
||||||
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
||||||
Err(e) => Err(format!("Unable to parse: {} as date - {}",
|
Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to convert header {:?} to string {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert header {:?} to string {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,8 +188,10 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert {:?} to a header: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
#![allow(
|
||||||
|
missing_docs,
|
||||||
|
trivial_casts,
|
||||||
|
unused_variables,
|
||||||
|
unused_mut,
|
||||||
|
unused_imports,
|
||||||
|
unused_extern_crates,
|
||||||
|
non_camel_case_types
|
||||||
|
)]
|
||||||
#![allow(unused_imports, unused_attributes)]
|
#![allow(unused_imports, unused_attributes)]
|
||||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
||||||
|
|
||||||
@ -19,7 +27,7 @@ pub const API_VERSION: &str = "1.0.7";
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum MultipartRelatedRequestPostResponse {
|
pub enum MultipartRelatedRequestPostResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status201_OK
|
Status201_OK,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -27,7 +35,7 @@ pub enum MultipartRelatedRequestPostResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum MultipartRequestPostResponse {
|
pub enum MultipartRequestPostResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status201_OK
|
Status201_OK,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -35,15 +43,13 @@ pub enum MultipartRequestPostResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum MultipleIdenticalMimeTypesPostResponse {
|
pub enum MultipleIdenticalMimeTypesPostResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status200_OK
|
Status200_OK,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// API
|
/// API
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
#[allow(clippy::ptr_arg)]
|
#[allow(clippy::ptr_arg)]
|
||||||
pub trait Api {
|
pub trait Api {
|
||||||
|
|
||||||
/// MultipartRelatedRequestPost - POST /multipart_related_request
|
/// MultipartRelatedRequestPost - POST /multipart_related_request
|
||||||
async fn multipart_related_request_post(
|
async fn multipart_related_request_post(
|
||||||
&self,
|
&self,
|
||||||
@ -53,7 +59,6 @@ pub trait Api {
|
|||||||
body: axum::body::Body,
|
body: axum::body::Body,
|
||||||
) -> Result<MultipartRelatedRequestPostResponse, String>;
|
) -> Result<MultipartRelatedRequestPostResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// MultipartRequestPost - POST /multipart_request
|
/// MultipartRequestPost - POST /multipart_request
|
||||||
async fn multipart_request_post(
|
async fn multipart_request_post(
|
||||||
&self,
|
&self,
|
||||||
@ -63,7 +68,6 @@ pub trait Api {
|
|||||||
body: Multipart,
|
body: Multipart,
|
||||||
) -> Result<MultipartRequestPostResponse, String>;
|
) -> Result<MultipartRequestPostResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types
|
/// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types
|
||||||
async fn multiple_identical_mime_types_post(
|
async fn multiple_identical_mime_types_post(
|
||||||
&self,
|
&self,
|
||||||
@ -72,7 +76,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
body: axum::body::Body,
|
body: axum::body::Body,
|
||||||
) -> Result<MultipleIdenticalMimeTypesPostResponse, String>;
|
) -> Result<MultipleIdenticalMimeTypesPostResponse, String>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
|
@ -7,14 +7,6 @@ use validator::Validate;
|
|||||||
use crate::header;
|
use crate::header;
|
||||||
use crate::{models, types::*};
|
use crate::{models, types::*};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct MultipartRelatedRequest {
|
pub struct MultipartRelatedRequest {
|
||||||
@ -28,13 +20,11 @@ pub struct MultipartRelatedRequest {
|
|||||||
|
|
||||||
#[serde(rename = "required_binary_field")]
|
#[serde(rename = "required_binary_field")]
|
||||||
pub required_binary_field: ByteArray,
|
pub required_binary_field: ByteArray,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl MultipartRelatedRequest {
|
impl MultipartRelatedRequest {
|
||||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||||
pub fn new(required_binary_field: ByteArray, ) -> MultipartRelatedRequest {
|
pub fn new(required_binary_field: ByteArray) -> MultipartRelatedRequest {
|
||||||
MultipartRelatedRequest {
|
MultipartRelatedRequest {
|
||||||
object_field: None,
|
object_field: None,
|
||||||
optional_binary_field: None,
|
optional_binary_field: None,
|
||||||
@ -88,7 +78,11 @@ impl std::str::FromStr for MultipartRelatedRequest {
|
|||||||
while key_result.is_some() {
|
while key_result.is_some() {
|
||||||
let val = match string_iter.next() {
|
let val = match string_iter.next() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => return std::result::Result::Err("Missing value while parsing MultipartRelatedRequest".to_string())
|
None => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Missing value while parsing MultipartRelatedRequest".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(key) = key_result {
|
if let Some(key) = key_result {
|
||||||
@ -110,7 +104,13 @@ impl std::str::FromStr for MultipartRelatedRequest {
|
|||||||
std::result::Result::Ok(MultipartRelatedRequest {
|
std::result::Result::Ok(MultipartRelatedRequest {
|
||||||
object_field: intermediate_rep.object_field.into_iter().next(),
|
object_field: intermediate_rep.object_field.into_iter().next(),
|
||||||
optional_binary_field: intermediate_rep.optional_binary_field.into_iter().next(),
|
optional_binary_field: intermediate_rep.optional_binary_field.into_iter().next(),
|
||||||
required_binary_field: intermediate_rep.required_binary_field.into_iter().next().ok_or_else(|| "required_binary_field missing in MultipartRelatedRequest".to_string())?,
|
required_binary_field: intermediate_rep
|
||||||
|
.required_binary_field
|
||||||
|
.into_iter()
|
||||||
|
.next()
|
||||||
|
.ok_or_else(|| {
|
||||||
|
"required_binary_field missing in MultipartRelatedRequest".to_string()
|
||||||
|
})?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,13 +121,16 @@ impl std::str::FromStr for MultipartRelatedRequest {
|
|||||||
impl std::convert::TryFrom<header::IntoHeaderValue<MultipartRelatedRequest>> for HeaderValue {
|
impl std::convert::TryFrom<header::IntoHeaderValue<MultipartRelatedRequest>> for HeaderValue {
|
||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
fn try_from(hdr_value: header::IntoHeaderValue<MultipartRelatedRequest>) -> std::result::Result<Self, Self::Error> {
|
fn try_from(
|
||||||
|
hdr_value: header::IntoHeaderValue<MultipartRelatedRequest>,
|
||||||
|
) -> std::result::Result<Self, Self::Error> {
|
||||||
let hdr_value = hdr_value.to_string();
|
let hdr_value = hdr_value.to_string();
|
||||||
match HeaderValue::from_str(&hdr_value) {
|
match HeaderValue::from_str(&hdr_value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
format!("Invalid header value for MultipartRelatedRequest - value: {} is invalid {}",
|
"Invalid header value for MultipartRelatedRequest - value: {} is invalid {}",
|
||||||
hdr_value, e))
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,25 +143,23 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<MultipartRel
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
std::result::Result::Ok(value) => {
|
std::result::Result::Ok(value) => {
|
||||||
match <MultipartRelatedRequest as std::str::FromStr>::from_str(value) {
|
match <MultipartRelatedRequest as std::str::FromStr>::from_str(value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
std::result::Result::Ok(value) => {
|
||||||
std::result::Result::Err(err) => std::result::Result::Err(
|
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||||
format!("Unable to convert header value '{}' into MultipartRelatedRequest - {}",
|
|
||||||
value, err))
|
|
||||||
}
|
}
|
||||||
},
|
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
"Unable to convert header value '{}' into MultipartRelatedRequest - {}",
|
||||||
format!("Unable to convert header: {:?} to string: {}",
|
value, err
|
||||||
hdr_value, e))
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
|
"Unable to convert header: {:?} to string: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct MultipartRequestObjectField {
|
pub struct MultipartRequestObjectField {
|
||||||
@ -168,13 +169,11 @@ pub struct MultipartRequestObjectField {
|
|||||||
#[serde(rename = "field_b")]
|
#[serde(rename = "field_b")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub field_b: Option<Vec<String>>,
|
pub field_b: Option<Vec<String>>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl MultipartRequestObjectField {
|
impl MultipartRequestObjectField {
|
||||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||||
pub fn new(field_a: String, ) -> MultipartRequestObjectField {
|
pub fn new(field_a: String) -> MultipartRequestObjectField {
|
||||||
MultipartRequestObjectField {
|
MultipartRequestObjectField {
|
||||||
field_a,
|
field_a,
|
||||||
field_b: None,
|
field_b: None,
|
||||||
@ -188,18 +187,19 @@ impl MultipartRequestObjectField {
|
|||||||
impl std::string::ToString for MultipartRequestObjectField {
|
impl std::string::ToString for MultipartRequestObjectField {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
let params: Vec<Option<String>> = vec![
|
let params: Vec<Option<String>> = vec![
|
||||||
|
|
||||||
Some("field_a".to_string()),
|
Some("field_a".to_string()),
|
||||||
Some(self.field_a.to_string()),
|
Some(self.field_a.to_string()),
|
||||||
|
|
||||||
|
|
||||||
self.field_b.as_ref().map(|field_b| {
|
self.field_b.as_ref().map(|field_b| {
|
||||||
[
|
[
|
||||||
"field_b".to_string(),
|
"field_b".to_string(),
|
||||||
field_b.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","),
|
field_b
|
||||||
].join(",")
|
.iter()
|
||||||
|
.map(|x| x.to_string())
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join(","),
|
||||||
|
]
|
||||||
|
.join(",")
|
||||||
}),
|
}),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||||
@ -230,7 +230,11 @@ impl std::str::FromStr for MultipartRequestObjectField {
|
|||||||
while key_result.is_some() {
|
while key_result.is_some() {
|
||||||
let val = match string_iter.next() {
|
let val = match string_iter.next() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => return std::result::Result::Err("Missing value while parsing MultipartRequestObjectField".to_string())
|
None => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Missing value while parsing MultipartRequestObjectField".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(key) = key_result {
|
if let Some(key) = key_result {
|
||||||
@ -249,7 +253,11 @@ impl std::str::FromStr for MultipartRequestObjectField {
|
|||||||
|
|
||||||
// Use the intermediate representation to return the struct
|
// Use the intermediate representation to return the struct
|
||||||
std::result::Result::Ok(MultipartRequestObjectField {
|
std::result::Result::Ok(MultipartRequestObjectField {
|
||||||
field_a: intermediate_rep.field_a.into_iter().next().ok_or_else(|| "field_a missing in MultipartRequestObjectField".to_string())?,
|
field_a: intermediate_rep
|
||||||
|
.field_a
|
||||||
|
.into_iter()
|
||||||
|
.next()
|
||||||
|
.ok_or_else(|| "field_a missing in MultipartRequestObjectField".to_string())?,
|
||||||
field_b: intermediate_rep.field_b.into_iter().next(),
|
field_b: intermediate_rep.field_b.into_iter().next(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -261,13 +269,16 @@ impl std::str::FromStr for MultipartRequestObjectField {
|
|||||||
impl std::convert::TryFrom<header::IntoHeaderValue<MultipartRequestObjectField>> for HeaderValue {
|
impl std::convert::TryFrom<header::IntoHeaderValue<MultipartRequestObjectField>> for HeaderValue {
|
||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
fn try_from(hdr_value: header::IntoHeaderValue<MultipartRequestObjectField>) -> std::result::Result<Self, Self::Error> {
|
fn try_from(
|
||||||
|
hdr_value: header::IntoHeaderValue<MultipartRequestObjectField>,
|
||||||
|
) -> std::result::Result<Self, Self::Error> {
|
||||||
let hdr_value = hdr_value.to_string();
|
let hdr_value = hdr_value.to_string();
|
||||||
match HeaderValue::from_str(&hdr_value) {
|
match HeaderValue::from_str(&hdr_value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
format!("Invalid header value for MultipartRequestObjectField - value: {} is invalid {}",
|
"Invalid header value for MultipartRequestObjectField - value: {} is invalid {}",
|
||||||
hdr_value, e))
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,25 +291,23 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<MultipartReq
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
std::result::Result::Ok(value) => {
|
std::result::Result::Ok(value) => {
|
||||||
match <MultipartRequestObjectField as std::str::FromStr>::from_str(value) {
|
match <MultipartRequestObjectField as std::str::FromStr>::from_str(value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
std::result::Result::Ok(value) => {
|
||||||
std::result::Result::Err(err) => std::result::Result::Err(
|
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||||
format!("Unable to convert header value '{}' into MultipartRequestObjectField - {}",
|
|
||||||
value, err))
|
|
||||||
}
|
}
|
||||||
},
|
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
"Unable to convert header value '{}' into MultipartRequestObjectField - {}",
|
||||||
format!("Unable to convert header: {:?} to string: {}",
|
value, err
|
||||||
hdr_value, e))
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
|
"Unable to convert header: {:?} to string: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct MultipleIdenticalMimeTypesPostRequest {
|
pub struct MultipleIdenticalMimeTypesPostRequest {
|
||||||
@ -309,10 +318,8 @@ pub struct MultipleIdenticalMimeTypesPostRequest {
|
|||||||
#[serde(rename = "binary2")]
|
#[serde(rename = "binary2")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub binary2: Option<ByteArray>,
|
pub binary2: Option<ByteArray>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl MultipleIdenticalMimeTypesPostRequest {
|
impl MultipleIdenticalMimeTypesPostRequest {
|
||||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||||
pub fn new() -> MultipleIdenticalMimeTypesPostRequest {
|
pub fn new() -> MultipleIdenticalMimeTypesPostRequest {
|
||||||
@ -365,7 +372,12 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest {
|
|||||||
while key_result.is_some() {
|
while key_result.is_some() {
|
||||||
let val = match string_iter.next() {
|
let val = match string_iter.next() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => return std::result::Result::Err("Missing value while parsing MultipleIdenticalMimeTypesPostRequest".to_string())
|
None => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Missing value while parsing MultipleIdenticalMimeTypesPostRequest"
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(key) = key_result {
|
if let Some(key) = key_result {
|
||||||
@ -392,10 +404,14 @@ impl std::str::FromStr for MultipleIdenticalMimeTypesPostRequest {
|
|||||||
// Methods for converting between header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest> and HeaderValue
|
// Methods for converting between header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest> and HeaderValue
|
||||||
|
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
impl std::convert::TryFrom<header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>> for HeaderValue {
|
impl std::convert::TryFrom<header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>>
|
||||||
|
for HeaderValue
|
||||||
|
{
|
||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
fn try_from(hdr_value: header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>) -> std::result::Result<Self, Self::Error> {
|
fn try_from(
|
||||||
|
hdr_value: header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>,
|
||||||
|
) -> std::result::Result<Self, Self::Error> {
|
||||||
let hdr_value = hdr_value.to_string();
|
let hdr_value = hdr_value.to_string();
|
||||||
match HeaderValue::from_str(&hdr_value) {
|
match HeaderValue::from_str(&hdr_value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||||
@ -407,7 +423,9 @@ impl std::convert::TryFrom<header::IntoHeaderValue<MultipleIdenticalMimeTypesPos
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest> {
|
impl std::convert::TryFrom<HeaderValue>
|
||||||
|
for header::IntoHeaderValue<MultipleIdenticalMimeTypesPostRequest>
|
||||||
|
{
|
||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
|
fn try_from(hdr_value: HeaderValue) -> std::result::Result<Self, Self::Error> {
|
||||||
@ -426,6 +444,3 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<MultipleIden
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,10 +12,9 @@ use crate::{header, types::*};
|
|||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::models;
|
use crate::models;
|
||||||
|
|
||||||
use crate::{Api,
|
use crate::{
|
||||||
MultipartRelatedRequestPostResponse,
|
Api, MultipartRelatedRequestPostResponse, MultipartRequestPostResponse,
|
||||||
MultipartRequestPostResponse,
|
MultipleIdenticalMimeTypesPostResponse,
|
||||||
MultipleIdenticalMimeTypesPostResponse
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Setup API Server.
|
/// Setup API Server.
|
||||||
@ -26,27 +25,21 @@ where
|
|||||||
{
|
{
|
||||||
// build our application with a route
|
// build our application with a route
|
||||||
Router::new()
|
Router::new()
|
||||||
.route("/multipart_related_request",
|
.route(
|
||||||
post(multipart_related_request_post::<I, A>)
|
"/multipart_related_request",
|
||||||
|
post(multipart_related_request_post::<I, A>),
|
||||||
)
|
)
|
||||||
.route("/multipart_request",
|
.route("/multipart_request", post(multipart_request_post::<I, A>))
|
||||||
post(multipart_request_post::<I, A>)
|
.route(
|
||||||
)
|
"/multiple-identical-mime-types",
|
||||||
.route("/multiple-identical-mime-types",
|
post(multiple_identical_mime_types_post::<I, A>),
|
||||||
post(multiple_identical_mime_types_post::<I, A>)
|
|
||||||
)
|
)
|
||||||
.with_state(api_impl)
|
.with_state(api_impl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn multipart_related_request_post_validation(
|
fn multipart_related_request_post_validation() -> std::result::Result<(), ValidationErrors> {
|
||||||
) -> std::result::Result<(
|
Ok(())
|
||||||
), ValidationErrors>
|
|
||||||
{
|
|
||||||
|
|
||||||
Ok((
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// MultipartRelatedRequestPost - POST /multipart_related_request
|
/// MultipartRelatedRequestPost - POST /multipart_related_request
|
||||||
@ -62,58 +55,49 @@ where
|
|||||||
I: AsRef<A> + Send + Sync,
|
I: AsRef<A> + Send + Sync,
|
||||||
A: Api,
|
A: Api,
|
||||||
{
|
{
|
||||||
|
|
||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
let validation = tokio::task::spawn_blocking(move ||
|
let validation =
|
||||||
multipart_related_request_post_validation(
|
tokio::task::spawn_blocking(move || multipart_related_request_post_validation())
|
||||||
)
|
.await
|
||||||
).await.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let Ok((
|
let Ok(()) = validation else {
|
||||||
)) = validation else {
|
|
||||||
return Response::builder()
|
return Response::builder()
|
||||||
.status(StatusCode::BAD_REQUEST)
|
.status(StatusCode::BAD_REQUEST)
|
||||||
.body(Body::from(validation.unwrap_err().to_string()))
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = api_impl.as_ref().multipart_related_request_post(
|
let result = api_impl
|
||||||
method,
|
.as_ref()
|
||||||
host,
|
.multipart_related_request_post(method, host, cookies, body)
|
||||||
cookies,
|
.await;
|
||||||
body,
|
|
||||||
).await;
|
|
||||||
|
|
||||||
let mut response = Response::builder();
|
let mut response = Response::builder();
|
||||||
|
|
||||||
let resp = match result {
|
let resp = match result {
|
||||||
Ok(rsp) => match rsp {
|
Ok(rsp) => match rsp {
|
||||||
MultipartRelatedRequestPostResponse::Status201_OK
|
MultipartRelatedRequestPostResponse::Status201_OK => {
|
||||||
=> {
|
|
||||||
|
|
||||||
let mut response = response.status(201);
|
let mut response = response.status(201);
|
||||||
response.body(Body::empty())
|
response.body(Body::empty())
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Application code returned an error. This should not happen, as the implementation should
|
// Application code returned an error. This should not happen, as the implementation should
|
||||||
// return a valid response.
|
// return a valid response.
|
||||||
response.status(500).body(Body::empty())
|
response.status(500).body(Body::empty())
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
resp.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn multipart_request_post_validation(
|
fn multipart_request_post_validation() -> std::result::Result<(), ValidationErrors> {
|
||||||
) -> std::result::Result<(
|
Ok(())
|
||||||
), ValidationErrors>
|
|
||||||
{
|
|
||||||
|
|
||||||
Ok((
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// MultipartRequestPost - POST /multipart_request
|
/// MultipartRequestPost - POST /multipart_request
|
||||||
@ -129,58 +113,48 @@ where
|
|||||||
I: AsRef<A> + Send + Sync,
|
I: AsRef<A> + Send + Sync,
|
||||||
A: Api,
|
A: Api,
|
||||||
{
|
{
|
||||||
|
|
||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
let validation = tokio::task::spawn_blocking(move ||
|
let validation = tokio::task::spawn_blocking(move || multipart_request_post_validation())
|
||||||
multipart_request_post_validation(
|
.await
|
||||||
)
|
.unwrap();
|
||||||
).await.unwrap();
|
|
||||||
|
|
||||||
let Ok((
|
let Ok(()) = validation else {
|
||||||
)) = validation else {
|
|
||||||
return Response::builder()
|
return Response::builder()
|
||||||
.status(StatusCode::BAD_REQUEST)
|
.status(StatusCode::BAD_REQUEST)
|
||||||
.body(Body::from(validation.unwrap_err().to_string()))
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = api_impl.as_ref().multipart_request_post(
|
let result = api_impl
|
||||||
method,
|
.as_ref()
|
||||||
host,
|
.multipart_request_post(method, host, cookies, body)
|
||||||
cookies,
|
.await;
|
||||||
body,
|
|
||||||
).await;
|
|
||||||
|
|
||||||
let mut response = Response::builder();
|
let mut response = Response::builder();
|
||||||
|
|
||||||
let resp = match result {
|
let resp = match result {
|
||||||
Ok(rsp) => match rsp {
|
Ok(rsp) => match rsp {
|
||||||
MultipartRequestPostResponse::Status201_OK
|
MultipartRequestPostResponse::Status201_OK => {
|
||||||
=> {
|
|
||||||
|
|
||||||
let mut response = response.status(201);
|
let mut response = response.status(201);
|
||||||
response.body(Body::empty())
|
response.body(Body::empty())
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Application code returned an error. This should not happen, as the implementation should
|
// Application code returned an error. This should not happen, as the implementation should
|
||||||
// return a valid response.
|
// return a valid response.
|
||||||
response.status(500).body(Body::empty())
|
response.status(500).body(Body::empty())
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
resp.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn multiple_identical_mime_types_post_validation(
|
fn multiple_identical_mime_types_post_validation() -> std::result::Result<(), ValidationErrors> {
|
||||||
) -> std::result::Result<(
|
Ok(())
|
||||||
), ValidationErrors>
|
|
||||||
{
|
|
||||||
|
|
||||||
Ok((
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types
|
/// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types
|
||||||
@ -196,46 +170,42 @@ where
|
|||||||
I: AsRef<A> + Send + Sync,
|
I: AsRef<A> + Send + Sync,
|
||||||
A: Api,
|
A: Api,
|
||||||
{
|
{
|
||||||
|
|
||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
let validation = tokio::task::spawn_blocking(move ||
|
let validation =
|
||||||
multiple_identical_mime_types_post_validation(
|
tokio::task::spawn_blocking(move || multiple_identical_mime_types_post_validation())
|
||||||
)
|
.await
|
||||||
).await.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let Ok((
|
let Ok(()) = validation else {
|
||||||
)) = validation else {
|
|
||||||
return Response::builder()
|
return Response::builder()
|
||||||
.status(StatusCode::BAD_REQUEST)
|
.status(StatusCode::BAD_REQUEST)
|
||||||
.body(Body::from(validation.unwrap_err().to_string()))
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = api_impl.as_ref().multiple_identical_mime_types_post(
|
let result = api_impl
|
||||||
method,
|
.as_ref()
|
||||||
host,
|
.multiple_identical_mime_types_post(method, host, cookies, body)
|
||||||
cookies,
|
.await;
|
||||||
body,
|
|
||||||
).await;
|
|
||||||
|
|
||||||
let mut response = Response::builder();
|
let mut response = Response::builder();
|
||||||
|
|
||||||
let resp = match result {
|
let resp = match result {
|
||||||
Ok(rsp) => match rsp {
|
Ok(rsp) => match rsp {
|
||||||
MultipleIdenticalMimeTypesPostResponse::Status200_OK
|
MultipleIdenticalMimeTypesPostResponse::Status200_OK => {
|
||||||
=> {
|
|
||||||
|
|
||||||
let mut response = response.status(200);
|
let mut response = response.status(200);
|
||||||
response.body(Body::empty())
|
response.body(Body::empty())
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Application code returned an error. This should not happen, as the implementation should
|
// Application code returned an error. This should not happen, as the implementation should
|
||||||
// return a valid response.
|
// return a valid response.
|
||||||
response.status(500).body(Body::empty())
|
response.status(500).body(Body::empty())
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
resp.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,11 +30,16 @@ macro_rules! ihv_generate {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||||
Err(e) => Err(format!("Unable to parse {} as a string: {}",
|
Err(e) => Err(format!(
|
||||||
stringify!($t), e)),
|
"Unable to parse {} as a string: {}",
|
||||||
|
stringify!($t),
|
||||||
|
e
|
||||||
|
)),
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to parse header {:?} as a string - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,9 +79,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
|
|||||||
"" => None,
|
"" => None,
|
||||||
y => Some(y.to_string()),
|
y => Some(y.to_string()),
|
||||||
})
|
})
|
||||||
.collect())),
|
.collect(),
|
||||||
Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
|
)),
|
||||||
hdr_value, e)),
|
Err(e) => Err(format!(
|
||||||
|
"Unable to parse header: {:?} as a string - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,8 +95,10 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert {:?} into a header - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,8 +111,7 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
|
|||||||
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
||||||
Err(e) => Err(format!("Unable to convert header {:?} to {}",
|
Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,8 +122,10 @@ impl TryFrom<IntoHeaderValue<String>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0) {
|
match HeaderValue::from_str(&hdr_value.0) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert {:?} from a header {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,11 +139,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match hdr_value.parse() {
|
Ok(hdr_value) => match hdr_value.parse() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||||
Err(e) => Err(format!("Unable to parse bool from {} - {}",
|
Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert {:?} from a header {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,8 +155,10 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert: {:?} into a header: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,11 +172,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
||||||
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
||||||
Err(e) => Err(format!("Unable to parse: {} as date - {}",
|
Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to convert header {:?} to string {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert header {:?} to string {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,8 +188,10 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert {:?} to a header: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
#![allow(
|
||||||
|
missing_docs,
|
||||||
|
trivial_casts,
|
||||||
|
unused_variables,
|
||||||
|
unused_mut,
|
||||||
|
unused_imports,
|
||||||
|
unused_extern_crates,
|
||||||
|
non_camel_case_types
|
||||||
|
)]
|
||||||
#![allow(unused_imports, unused_attributes)]
|
#![allow(unused_imports, unused_attributes)]
|
||||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
||||||
|
|
||||||
@ -19,16 +27,11 @@ pub const API_VERSION: &str = "1.0.7";
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum AnyOfGetResponse {
|
pub enum AnyOfGetResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success(models::AnyOfObject),
|
||||||
(models::AnyOfObject)
|
|
||||||
,
|
|
||||||
/// AlternateSuccess
|
/// AlternateSuccess
|
||||||
Status201_AlternateSuccess
|
Status201_AlternateSuccess(models::Model12345AnyOfObject),
|
||||||
(models::Model12345AnyOfObject)
|
|
||||||
,
|
|
||||||
/// AnyOfSuccess
|
/// AnyOfSuccess
|
||||||
Status202_AnyOfSuccess
|
Status202_AnyOfSuccess(models::AnyOfGet202Response),
|
||||||
(models::AnyOfGet202Response)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -36,7 +39,7 @@ pub enum AnyOfGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum CallbackWithHeaderPostResponse {
|
pub enum CallbackWithHeaderPostResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status204_OK
|
Status204_OK,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -44,7 +47,7 @@ pub enum CallbackWithHeaderPostResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum ComplexQueryParamGetResponse {
|
pub enum ComplexQueryParamGetResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -52,7 +55,7 @@ pub enum ComplexQueryParamGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum EnumInPathPathParamGetResponse {
|
pub enum EnumInPathPathParamGetResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -60,7 +63,7 @@ pub enum EnumInPathPathParamGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum JsonComplexQueryParamGetResponse {
|
pub enum JsonComplexQueryParamGetResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -68,7 +71,7 @@ pub enum JsonComplexQueryParamGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum MandatoryRequestHeaderGetResponse {
|
pub enum MandatoryRequestHeaderGetResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -76,8 +79,7 @@ pub enum MandatoryRequestHeaderGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum MergePatchJsonGetResponse {
|
pub enum MergePatchJsonGetResponse {
|
||||||
/// merge-patch+json-encoded response
|
/// merge-patch+json-encoded response
|
||||||
Status200_Merge
|
Status200_Merge(models::AnotherXmlObject),
|
||||||
(models::AnotherXmlObject)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -85,32 +87,19 @@ pub enum MergePatchJsonGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum MultigetGetResponse {
|
pub enum MultigetGetResponse {
|
||||||
/// JSON rsp
|
/// JSON rsp
|
||||||
Status200_JSONRsp
|
Status200_JSONRsp(models::AnotherXmlObject),
|
||||||
(models::AnotherXmlObject)
|
|
||||||
,
|
|
||||||
/// XML rsp
|
/// XML rsp
|
||||||
Status201_XMLRsp
|
Status201_XMLRsp(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// octet rsp
|
/// octet rsp
|
||||||
Status202_OctetRsp
|
Status202_OctetRsp(ByteArray),
|
||||||
(ByteArray)
|
|
||||||
,
|
|
||||||
/// string rsp
|
/// string rsp
|
||||||
Status203_StringRsp
|
Status203_StringRsp(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Duplicate Response long text. One.
|
/// Duplicate Response long text. One.
|
||||||
Status204_DuplicateResponseLongText
|
Status204_DuplicateResponseLongText(models::AnotherXmlObject),
|
||||||
(models::AnotherXmlObject)
|
|
||||||
,
|
|
||||||
/// Duplicate Response long text. Two.
|
/// Duplicate Response long text. Two.
|
||||||
Status205_DuplicateResponseLongText
|
Status205_DuplicateResponseLongText(models::AnotherXmlObject),
|
||||||
(models::AnotherXmlObject)
|
|
||||||
,
|
|
||||||
/// Duplicate Response long text. Three.
|
/// Duplicate Response long text. Three.
|
||||||
Status206_DuplicateResponseLongText
|
Status206_DuplicateResponseLongText(models::AnotherXmlObject),
|
||||||
(models::AnotherXmlObject)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -118,7 +107,7 @@ pub enum MultigetGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum MultipleAuthSchemeGetResponse {
|
pub enum MultipleAuthSchemeGetResponse {
|
||||||
/// Check that limiting to multiple required auth schemes works
|
/// Check that limiting to multiple required auth schemes works
|
||||||
Status200_CheckThatLimitingToMultipleRequiredAuthSchemesWorks
|
Status200_CheckThatLimitingToMultipleRequiredAuthSchemesWorks,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -126,8 +115,7 @@ pub enum MultipleAuthSchemeGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum OneOfGetResponse {
|
pub enum OneOfGetResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success(models::OneOfGet200Response),
|
||||||
(models::OneOfGet200Response)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -135,7 +123,7 @@ pub enum OneOfGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum OverrideServerGetResponse {
|
pub enum OverrideServerGetResponse {
|
||||||
/// Success.
|
/// Success.
|
||||||
Status204_Success
|
Status204_Success,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -143,8 +131,7 @@ pub enum OverrideServerGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum ParamgetGetResponse {
|
pub enum ParamgetGetResponse {
|
||||||
/// JSON rsp
|
/// JSON rsp
|
||||||
Status200_JSONRsp
|
Status200_JSONRsp(models::AnotherXmlObject),
|
||||||
(models::AnotherXmlObject)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -152,7 +139,7 @@ pub enum ParamgetGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum ReadonlyAuthSchemeGetResponse {
|
pub enum ReadonlyAuthSchemeGetResponse {
|
||||||
/// Check that limiting to a single required auth scheme works
|
/// Check that limiting to a single required auth scheme works
|
||||||
Status200_CheckThatLimitingToASingleRequiredAuthSchemeWorks
|
Status200_CheckThatLimitingToASingleRequiredAuthSchemeWorks,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -160,7 +147,7 @@ pub enum ReadonlyAuthSchemeGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum RegisterCallbackPostResponse {
|
pub enum RegisterCallbackPostResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status204_OK
|
Status204_OK,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -168,7 +155,7 @@ pub enum RegisterCallbackPostResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum RequiredOctetStreamPutResponse {
|
pub enum RequiredOctetStreamPutResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status200_OK
|
Status200_OK,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -176,36 +163,17 @@ pub enum RequiredOctetStreamPutResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum ResponsesWithHeadersGetResponse {
|
pub enum ResponsesWithHeadersGetResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success {
|
||||||
{
|
|
||||||
body: String,
|
body: String,
|
||||||
success_info:
|
success_info: String,
|
||||||
String
|
bool_header: Option<bool>,
|
||||||
,
|
object_header: Option<models::ObjectHeader>,
|
||||||
bool_header:
|
},
|
||||||
Option<
|
|
||||||
bool
|
|
||||||
>
|
|
||||||
,
|
|
||||||
object_header:
|
|
||||||
Option<
|
|
||||||
models::ObjectHeader
|
|
||||||
>
|
|
||||||
}
|
|
||||||
,
|
|
||||||
/// Precondition Failed
|
/// Precondition Failed
|
||||||
Status412_PreconditionFailed
|
Status412_PreconditionFailed {
|
||||||
{
|
further_info: Option<String>,
|
||||||
further_info:
|
failure_info: Option<String>,
|
||||||
Option<
|
},
|
||||||
String
|
|
||||||
>
|
|
||||||
,
|
|
||||||
failure_info:
|
|
||||||
Option<
|
|
||||||
String
|
|
||||||
>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -213,16 +181,11 @@ pub enum ResponsesWithHeadersGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum Rfc7807GetResponse {
|
pub enum Rfc7807GetResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status204_OK
|
Status204_OK(models::ObjectWithArrayOfObjects),
|
||||||
(models::ObjectWithArrayOfObjects)
|
|
||||||
,
|
|
||||||
/// NotFound
|
/// NotFound
|
||||||
Status404_NotFound
|
Status404_NotFound(models::ObjectWithArrayOfObjects),
|
||||||
(models::ObjectWithArrayOfObjects)
|
|
||||||
,
|
|
||||||
/// NotAcceptable
|
/// NotAcceptable
|
||||||
Status406_NotAcceptable
|
Status406_NotAcceptable(String),
|
||||||
(String)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -230,7 +193,7 @@ pub enum Rfc7807GetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum UntypedPropertyGetResponse {
|
pub enum UntypedPropertyGetResponse {
|
||||||
/// Check that untyped properties works
|
/// Check that untyped properties works
|
||||||
Status200_CheckThatUntypedPropertiesWorks
|
Status200_CheckThatUntypedPropertiesWorks,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -238,8 +201,7 @@ pub enum UntypedPropertyGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum UuidGetResponse {
|
pub enum UuidGetResponse {
|
||||||
/// Duplicate Response long text. One.
|
/// Duplicate Response long text. One.
|
||||||
Status200_DuplicateResponseLongText
|
Status200_DuplicateResponseLongText(uuid::Uuid),
|
||||||
(uuid::Uuid)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -247,10 +209,9 @@ pub enum UuidGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum XmlExtraPostResponse {
|
pub enum XmlExtraPostResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status201_OK
|
Status201_OK,
|
||||||
,
|
|
||||||
/// Bad Request
|
/// Bad Request
|
||||||
Status400_BadRequest
|
Status400_BadRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -258,11 +219,9 @@ pub enum XmlExtraPostResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum XmlOtherPostResponse {
|
pub enum XmlOtherPostResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status201_OK
|
Status201_OK(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Bad Request
|
/// Bad Request
|
||||||
Status400_BadRequest
|
Status400_BadRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -270,10 +229,9 @@ pub enum XmlOtherPostResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum XmlOtherPutResponse {
|
pub enum XmlOtherPutResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status201_OK
|
Status201_OK,
|
||||||
,
|
|
||||||
/// Bad Request
|
/// Bad Request
|
||||||
Status400_BadRequest
|
Status400_BadRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -281,10 +239,9 @@ pub enum XmlOtherPutResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum XmlPostResponse {
|
pub enum XmlPostResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status201_OK
|
Status201_OK,
|
||||||
,
|
|
||||||
/// Bad Request
|
/// Bad Request
|
||||||
Status400_BadRequest
|
Status400_BadRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -292,10 +249,9 @@ pub enum XmlPostResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum XmlPutResponse {
|
pub enum XmlPutResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status201_OK
|
Status201_OK,
|
||||||
,
|
|
||||||
/// Bad Request
|
/// Bad Request
|
||||||
Status400_BadRequest
|
Status400_BadRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -303,7 +259,7 @@ pub enum XmlPutResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum CreateRepoResponse {
|
pub enum CreateRepoResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -311,16 +267,13 @@ pub enum CreateRepoResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum GetRepoInfoResponse {
|
pub enum GetRepoInfoResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status200_OK
|
Status200_OK(String),
|
||||||
(String)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// API
|
/// API
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
#[allow(clippy::ptr_arg)]
|
#[allow(clippy::ptr_arg)]
|
||||||
pub trait Api {
|
pub trait Api {
|
||||||
|
|
||||||
/// AnyOfGet - GET /any-of
|
/// AnyOfGet - GET /any-of
|
||||||
async fn any_of_get(
|
async fn any_of_get(
|
||||||
&self,
|
&self,
|
||||||
@ -330,7 +283,6 @@ pub trait Api {
|
|||||||
query_params: models::AnyOfGetQueryParams,
|
query_params: models::AnyOfGetQueryParams,
|
||||||
) -> Result<AnyOfGetResponse, String>;
|
) -> Result<AnyOfGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// CallbackWithHeaderPost - POST /callback-with-header
|
/// CallbackWithHeaderPost - POST /callback-with-header
|
||||||
async fn callback_with_header_post(
|
async fn callback_with_header_post(
|
||||||
&self,
|
&self,
|
||||||
@ -340,7 +292,6 @@ pub trait Api {
|
|||||||
query_params: models::CallbackWithHeaderPostQueryParams,
|
query_params: models::CallbackWithHeaderPostQueryParams,
|
||||||
) -> Result<CallbackWithHeaderPostResponse, String>;
|
) -> Result<CallbackWithHeaderPostResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// ComplexQueryParamGet - GET /complex-query-param
|
/// ComplexQueryParamGet - GET /complex-query-param
|
||||||
async fn complex_query_param_get(
|
async fn complex_query_param_get(
|
||||||
&self,
|
&self,
|
||||||
@ -350,7 +301,6 @@ pub trait Api {
|
|||||||
query_params: models::ComplexQueryParamGetQueryParams,
|
query_params: models::ComplexQueryParamGetQueryParams,
|
||||||
) -> Result<ComplexQueryParamGetResponse, String>;
|
) -> Result<ComplexQueryParamGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// EnumInPathPathParamGet - GET /enum_in_path/{path_param}
|
/// EnumInPathPathParamGet - GET /enum_in_path/{path_param}
|
||||||
async fn enum_in_path_path_param_get(
|
async fn enum_in_path_path_param_get(
|
||||||
&self,
|
&self,
|
||||||
@ -360,7 +310,6 @@ pub trait Api {
|
|||||||
path_params: models::EnumInPathPathParamGetPathParams,
|
path_params: models::EnumInPathPathParamGetPathParams,
|
||||||
) -> Result<EnumInPathPathParamGetResponse, String>;
|
) -> Result<EnumInPathPathParamGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// JsonComplexQueryParamGet - GET /json-complex-query-param
|
/// JsonComplexQueryParamGet - GET /json-complex-query-param
|
||||||
async fn json_complex_query_param_get(
|
async fn json_complex_query_param_get(
|
||||||
&self,
|
&self,
|
||||||
@ -370,7 +319,6 @@ pub trait Api {
|
|||||||
query_params: models::JsonComplexQueryParamGetQueryParams,
|
query_params: models::JsonComplexQueryParamGetQueryParams,
|
||||||
) -> Result<JsonComplexQueryParamGetResponse, String>;
|
) -> Result<JsonComplexQueryParamGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// MandatoryRequestHeaderGet - GET /mandatory-request-header
|
/// MandatoryRequestHeaderGet - GET /mandatory-request-header
|
||||||
async fn mandatory_request_header_get(
|
async fn mandatory_request_header_get(
|
||||||
&self,
|
&self,
|
||||||
@ -380,7 +328,6 @@ pub trait Api {
|
|||||||
header_params: models::MandatoryRequestHeaderGetHeaderParams,
|
header_params: models::MandatoryRequestHeaderGetHeaderParams,
|
||||||
) -> Result<MandatoryRequestHeaderGetResponse, String>;
|
) -> Result<MandatoryRequestHeaderGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// MergePatchJsonGet - GET /merge-patch-json
|
/// MergePatchJsonGet - GET /merge-patch-json
|
||||||
async fn merge_patch_json_get(
|
async fn merge_patch_json_get(
|
||||||
&self,
|
&self,
|
||||||
@ -389,7 +336,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<MergePatchJsonGetResponse, String>;
|
) -> Result<MergePatchJsonGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Get some stuff..
|
/// Get some stuff..
|
||||||
///
|
///
|
||||||
/// MultigetGet - GET /multiget
|
/// MultigetGet - GET /multiget
|
||||||
@ -400,7 +346,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<MultigetGetResponse, String>;
|
) -> Result<MultigetGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// MultipleAuthSchemeGet - GET /multiple_auth_scheme
|
/// MultipleAuthSchemeGet - GET /multiple_auth_scheme
|
||||||
async fn multiple_auth_scheme_get(
|
async fn multiple_auth_scheme_get(
|
||||||
&self,
|
&self,
|
||||||
@ -409,7 +354,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<MultipleAuthSchemeGetResponse, String>;
|
) -> Result<MultipleAuthSchemeGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// OneOfGet - GET /one-of
|
/// OneOfGet - GET /one-of
|
||||||
async fn one_of_get(
|
async fn one_of_get(
|
||||||
&self,
|
&self,
|
||||||
@ -418,7 +362,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<OneOfGetResponse, String>;
|
) -> Result<OneOfGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// OverrideServerGet - GET /override-server
|
/// OverrideServerGet - GET /override-server
|
||||||
async fn override_server_get(
|
async fn override_server_get(
|
||||||
&self,
|
&self,
|
||||||
@ -427,7 +370,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<OverrideServerGetResponse, String>;
|
) -> Result<OverrideServerGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Get some stuff with parameters..
|
/// Get some stuff with parameters..
|
||||||
///
|
///
|
||||||
/// ParamgetGet - GET /paramget
|
/// ParamgetGet - GET /paramget
|
||||||
@ -439,7 +381,6 @@ pub trait Api {
|
|||||||
query_params: models::ParamgetGetQueryParams,
|
query_params: models::ParamgetGetQueryParams,
|
||||||
) -> Result<ParamgetGetResponse, String>;
|
) -> Result<ParamgetGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme
|
/// ReadonlyAuthSchemeGet - GET /readonly_auth_scheme
|
||||||
async fn readonly_auth_scheme_get(
|
async fn readonly_auth_scheme_get(
|
||||||
&self,
|
&self,
|
||||||
@ -448,7 +389,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<ReadonlyAuthSchemeGetResponse, String>;
|
) -> Result<ReadonlyAuthSchemeGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// RegisterCallbackPost - POST /register-callback
|
/// RegisterCallbackPost - POST /register-callback
|
||||||
async fn register_callback_post(
|
async fn register_callback_post(
|
||||||
&self,
|
&self,
|
||||||
@ -458,7 +398,6 @@ pub trait Api {
|
|||||||
query_params: models::RegisterCallbackPostQueryParams,
|
query_params: models::RegisterCallbackPostQueryParams,
|
||||||
) -> Result<RegisterCallbackPostResponse, String>;
|
) -> Result<RegisterCallbackPostResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// RequiredOctetStreamPut - PUT /required_octet_stream
|
/// RequiredOctetStreamPut - PUT /required_octet_stream
|
||||||
async fn required_octet_stream_put(
|
async fn required_octet_stream_put(
|
||||||
&self,
|
&self,
|
||||||
@ -468,7 +407,6 @@ pub trait Api {
|
|||||||
body: Bytes,
|
body: Bytes,
|
||||||
) -> Result<RequiredOctetStreamPutResponse, String>;
|
) -> Result<RequiredOctetStreamPutResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// ResponsesWithHeadersGet - GET /responses_with_headers
|
/// ResponsesWithHeadersGet - GET /responses_with_headers
|
||||||
async fn responses_with_headers_get(
|
async fn responses_with_headers_get(
|
||||||
&self,
|
&self,
|
||||||
@ -477,7 +415,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<ResponsesWithHeadersGetResponse, String>;
|
) -> Result<ResponsesWithHeadersGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Rfc7807Get - GET /rfc7807
|
/// Rfc7807Get - GET /rfc7807
|
||||||
async fn rfc7807_get(
|
async fn rfc7807_get(
|
||||||
&self,
|
&self,
|
||||||
@ -486,7 +423,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<Rfc7807GetResponse, String>;
|
) -> Result<Rfc7807GetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// UntypedPropertyGet - GET /untyped_property
|
/// UntypedPropertyGet - GET /untyped_property
|
||||||
async fn untyped_property_get(
|
async fn untyped_property_get(
|
||||||
&self,
|
&self,
|
||||||
@ -496,7 +432,6 @@ pub trait Api {
|
|||||||
body: Option<models::ObjectUntypedProps>,
|
body: Option<models::ObjectUntypedProps>,
|
||||||
) -> Result<UntypedPropertyGetResponse, String>;
|
) -> Result<UntypedPropertyGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// UuidGet - GET /uuid
|
/// UuidGet - GET /uuid
|
||||||
async fn uuid_get(
|
async fn uuid_get(
|
||||||
&self,
|
&self,
|
||||||
@ -505,7 +440,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<UuidGetResponse, String>;
|
) -> Result<UuidGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// XmlExtraPost - POST /xml_extra
|
/// XmlExtraPost - POST /xml_extra
|
||||||
async fn xml_extra_post(
|
async fn xml_extra_post(
|
||||||
&self,
|
&self,
|
||||||
@ -515,7 +449,6 @@ pub trait Api {
|
|||||||
body: Bytes,
|
body: Bytes,
|
||||||
) -> Result<XmlExtraPostResponse, String>;
|
) -> Result<XmlExtraPostResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// XmlOtherPost - POST /xml_other
|
/// XmlOtherPost - POST /xml_other
|
||||||
async fn xml_other_post(
|
async fn xml_other_post(
|
||||||
&self,
|
&self,
|
||||||
@ -525,7 +458,6 @@ pub trait Api {
|
|||||||
body: Bytes,
|
body: Bytes,
|
||||||
) -> Result<XmlOtherPostResponse, String>;
|
) -> Result<XmlOtherPostResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// XmlOtherPut - PUT /xml_other
|
/// XmlOtherPut - PUT /xml_other
|
||||||
async fn xml_other_put(
|
async fn xml_other_put(
|
||||||
&self,
|
&self,
|
||||||
@ -535,7 +467,6 @@ pub trait Api {
|
|||||||
body: Bytes,
|
body: Bytes,
|
||||||
) -> Result<XmlOtherPutResponse, String>;
|
) -> Result<XmlOtherPutResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Post an array.
|
/// Post an array.
|
||||||
///
|
///
|
||||||
/// XmlPost - POST /xml
|
/// XmlPost - POST /xml
|
||||||
@ -547,7 +478,6 @@ pub trait Api {
|
|||||||
body: Bytes,
|
body: Bytes,
|
||||||
) -> Result<XmlPostResponse, String>;
|
) -> Result<XmlPostResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// XmlPut - PUT /xml
|
/// XmlPut - PUT /xml
|
||||||
async fn xml_put(
|
async fn xml_put(
|
||||||
&self,
|
&self,
|
||||||
@ -557,7 +487,6 @@ pub trait Api {
|
|||||||
body: Bytes,
|
body: Bytes,
|
||||||
) -> Result<XmlPutResponse, String>;
|
) -> Result<XmlPutResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// CreateRepo - POST /repos
|
/// CreateRepo - POST /repos
|
||||||
async fn create_repo(
|
async fn create_repo(
|
||||||
&self,
|
&self,
|
||||||
@ -567,7 +496,6 @@ pub trait Api {
|
|||||||
body: models::ObjectParam,
|
body: models::ObjectParam,
|
||||||
) -> Result<CreateRepoResponse, String>;
|
) -> Result<CreateRepoResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// GetRepoInfo - GET /repos/{repoId}
|
/// GetRepoInfo - GET /repos/{repoId}
|
||||||
async fn get_repo_info(
|
async fn get_repo_info(
|
||||||
&self,
|
&self,
|
||||||
@ -576,7 +504,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
path_params: models::GetRepoInfoPathParams,
|
path_params: models::GetRepoInfoPathParams,
|
||||||
) -> Result<GetRepoInfoResponse, String>;
|
) -> Result<GetRepoInfoResponse, String>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -30,11 +30,16 @@ macro_rules! ihv_generate {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||||
Err(e) => Err(format!("Unable to parse {} as a string: {}",
|
Err(e) => Err(format!(
|
||||||
stringify!($t), e)),
|
"Unable to parse {} as a string: {}",
|
||||||
|
stringify!($t),
|
||||||
|
e
|
||||||
|
)),
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to parse header {:?} as a string - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,9 +79,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
|
|||||||
"" => None,
|
"" => None,
|
||||||
y => Some(y.to_string()),
|
y => Some(y.to_string()),
|
||||||
})
|
})
|
||||||
.collect())),
|
.collect(),
|
||||||
Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
|
)),
|
||||||
hdr_value, e)),
|
Err(e) => Err(format!(
|
||||||
|
"Unable to parse header: {:?} as a string - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,8 +95,10 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert {:?} into a header - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,8 +111,7 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
|
|||||||
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
||||||
Err(e) => Err(format!("Unable to convert header {:?} to {}",
|
Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,8 +122,10 @@ impl TryFrom<IntoHeaderValue<String>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0) {
|
match HeaderValue::from_str(&hdr_value.0) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert {:?} from a header {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,11 +139,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match hdr_value.parse() {
|
Ok(hdr_value) => match hdr_value.parse() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||||
Err(e) => Err(format!("Unable to parse bool from {} - {}",
|
Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert {:?} from a header {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,8 +155,10 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert: {:?} into a header: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,11 +172,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
||||||
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
||||||
Err(e) => Err(format!("Unable to parse: {} as date - {}",
|
Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to convert header {:?} to string {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert header {:?} to string {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,8 +188,10 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert {:?} to a header: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
#![allow(
|
||||||
|
missing_docs,
|
||||||
|
trivial_casts,
|
||||||
|
unused_variables,
|
||||||
|
unused_mut,
|
||||||
|
unused_imports,
|
||||||
|
unused_extern_crates,
|
||||||
|
non_camel_case_types
|
||||||
|
)]
|
||||||
#![allow(unused_imports, unused_attributes)]
|
#![allow(unused_imports, unused_attributes)]
|
||||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
||||||
|
|
||||||
@ -19,8 +27,7 @@ pub const API_VERSION: &str = "1.0.0";
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum TestSpecialTagsResponse {
|
pub enum TestSpecialTagsResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(models::Client),
|
||||||
(models::Client)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -28,7 +35,7 @@ pub enum TestSpecialTagsResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum Call123exampleResponse {
|
pub enum Call123exampleResponse {
|
||||||
/// success
|
/// success
|
||||||
Status200_Success
|
Status200_Success,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -36,8 +43,7 @@ pub enum Call123exampleResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum FakeOuterBooleanSerializeResponse {
|
pub enum FakeOuterBooleanSerializeResponse {
|
||||||
/// Output boolean
|
/// Output boolean
|
||||||
Status200_OutputBoolean
|
Status200_OutputBoolean(bool),
|
||||||
(bool)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -45,8 +51,7 @@ pub enum FakeOuterBooleanSerializeResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum FakeOuterCompositeSerializeResponse {
|
pub enum FakeOuterCompositeSerializeResponse {
|
||||||
/// Output composite
|
/// Output composite
|
||||||
Status200_OutputComposite
|
Status200_OutputComposite(models::OuterComposite),
|
||||||
(models::OuterComposite)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -54,8 +59,7 @@ pub enum FakeOuterCompositeSerializeResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum FakeOuterNumberSerializeResponse {
|
pub enum FakeOuterNumberSerializeResponse {
|
||||||
/// Output number
|
/// Output number
|
||||||
Status200_OutputNumber
|
Status200_OutputNumber(f64),
|
||||||
(f64)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -63,8 +67,7 @@ pub enum FakeOuterNumberSerializeResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum FakeOuterStringSerializeResponse {
|
pub enum FakeOuterStringSerializeResponse {
|
||||||
/// Output string
|
/// Output string
|
||||||
Status200_OutputString
|
Status200_OutputString(String),
|
||||||
(String)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -72,7 +75,7 @@ pub enum FakeOuterStringSerializeResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum FakeResponseWithNumericalDescriptionResponse {
|
pub enum FakeResponseWithNumericalDescriptionResponse {
|
||||||
/// 1234
|
/// 1234
|
||||||
Status200
|
Status200,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -80,7 +83,7 @@ pub enum FakeResponseWithNumericalDescriptionResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum HyphenParamResponse {
|
pub enum HyphenParamResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -88,7 +91,7 @@ pub enum HyphenParamResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum TestBodyWithQueryParamsResponse {
|
pub enum TestBodyWithQueryParamsResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -96,8 +99,7 @@ pub enum TestBodyWithQueryParamsResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum TestClientModelResponse {
|
pub enum TestClientModelResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(models::Client),
|
||||||
(models::Client)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -105,10 +107,9 @@ pub enum TestClientModelResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum TestEndpointParametersResponse {
|
pub enum TestEndpointParametersResponse {
|
||||||
/// Invalid username supplied
|
/// Invalid username supplied
|
||||||
Status400_InvalidUsernameSupplied
|
Status400_InvalidUsernameSupplied,
|
||||||
,
|
|
||||||
/// User not found
|
/// User not found
|
||||||
Status404_UserNotFound
|
Status404_UserNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -116,10 +117,9 @@ pub enum TestEndpointParametersResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum TestEnumParametersResponse {
|
pub enum TestEnumParametersResponse {
|
||||||
/// Invalid request
|
/// Invalid request
|
||||||
Status400_InvalidRequest
|
Status400_InvalidRequest,
|
||||||
,
|
|
||||||
/// Not found
|
/// Not found
|
||||||
Status404_NotFound
|
Status404_NotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -127,7 +127,7 @@ pub enum TestEnumParametersResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum TestInlineAdditionalPropertiesResponse {
|
pub enum TestInlineAdditionalPropertiesResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -135,7 +135,7 @@ pub enum TestInlineAdditionalPropertiesResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum TestJsonFormDataResponse {
|
pub enum TestJsonFormDataResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -143,8 +143,7 @@ pub enum TestJsonFormDataResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum TestClassnameResponse {
|
pub enum TestClassnameResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(models::Client),
|
||||||
(models::Client)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -152,7 +151,7 @@ pub enum TestClassnameResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum AddPetResponse {
|
pub enum AddPetResponse {
|
||||||
/// Invalid input
|
/// Invalid input
|
||||||
Status405_InvalidInput
|
Status405_InvalidInput,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -160,7 +159,7 @@ pub enum AddPetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum DeletePetResponse {
|
pub enum DeletePetResponse {
|
||||||
/// Invalid pet value
|
/// Invalid pet value
|
||||||
Status400_InvalidPetValue
|
Status400_InvalidPetValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -168,11 +167,9 @@ pub enum DeletePetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum FindPetsByStatusResponse {
|
pub enum FindPetsByStatusResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Invalid status value
|
/// Invalid status value
|
||||||
Status400_InvalidStatusValue
|
Status400_InvalidStatusValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -180,11 +177,9 @@ pub enum FindPetsByStatusResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum FindPetsByTagsResponse {
|
pub enum FindPetsByTagsResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Invalid tag value
|
/// Invalid tag value
|
||||||
Status400_InvalidTagValue
|
Status400_InvalidTagValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -192,14 +187,11 @@ pub enum FindPetsByTagsResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum GetPetByIdResponse {
|
pub enum GetPetByIdResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Invalid ID supplied
|
/// Invalid ID supplied
|
||||||
Status400_InvalidIDSupplied
|
Status400_InvalidIDSupplied,
|
||||||
,
|
|
||||||
/// Pet not found
|
/// Pet not found
|
||||||
Status404_PetNotFound
|
Status404_PetNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -207,13 +199,11 @@ pub enum GetPetByIdResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum UpdatePetResponse {
|
pub enum UpdatePetResponse {
|
||||||
/// Invalid ID supplied
|
/// Invalid ID supplied
|
||||||
Status400_InvalidIDSupplied
|
Status400_InvalidIDSupplied,
|
||||||
,
|
|
||||||
/// Pet not found
|
/// Pet not found
|
||||||
Status404_PetNotFound
|
Status404_PetNotFound,
|
||||||
,
|
|
||||||
/// Validation exception
|
/// Validation exception
|
||||||
Status405_ValidationException
|
Status405_ValidationException,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -221,7 +211,7 @@ pub enum UpdatePetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum UpdatePetWithFormResponse {
|
pub enum UpdatePetWithFormResponse {
|
||||||
/// Invalid input
|
/// Invalid input
|
||||||
Status405_InvalidInput
|
Status405_InvalidInput,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -229,8 +219,7 @@ pub enum UpdatePetWithFormResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum UploadFileResponse {
|
pub enum UploadFileResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(models::ApiResponse),
|
||||||
(models::ApiResponse)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -238,10 +227,9 @@ pub enum UploadFileResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum DeleteOrderResponse {
|
pub enum DeleteOrderResponse {
|
||||||
/// Invalid ID supplied
|
/// Invalid ID supplied
|
||||||
Status400_InvalidIDSupplied
|
Status400_InvalidIDSupplied,
|
||||||
,
|
|
||||||
/// Order not found
|
/// Order not found
|
||||||
Status404_OrderNotFound
|
Status404_OrderNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -249,8 +237,7 @@ pub enum DeleteOrderResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum GetInventoryResponse {
|
pub enum GetInventoryResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(std::collections::HashMap<String, i32>),
|
||||||
(std::collections::HashMap<String, i32>)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -258,14 +245,11 @@ pub enum GetInventoryResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum GetOrderByIdResponse {
|
pub enum GetOrderByIdResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Invalid ID supplied
|
/// Invalid ID supplied
|
||||||
Status400_InvalidIDSupplied
|
Status400_InvalidIDSupplied,
|
||||||
,
|
|
||||||
/// Order not found
|
/// Order not found
|
||||||
Status404_OrderNotFound
|
Status404_OrderNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -273,11 +257,9 @@ pub enum GetOrderByIdResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum PlaceOrderResponse {
|
pub enum PlaceOrderResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Invalid Order
|
/// Invalid Order
|
||||||
Status400_InvalidOrder
|
Status400_InvalidOrder,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -285,7 +267,7 @@ pub enum PlaceOrderResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum CreateUserResponse {
|
pub enum CreateUserResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status0_SuccessfulOperation
|
Status0_SuccessfulOperation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -293,7 +275,7 @@ pub enum CreateUserResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum CreateUsersWithArrayInputResponse {
|
pub enum CreateUsersWithArrayInputResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status0_SuccessfulOperation
|
Status0_SuccessfulOperation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -301,7 +283,7 @@ pub enum CreateUsersWithArrayInputResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum CreateUsersWithListInputResponse {
|
pub enum CreateUsersWithListInputResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status0_SuccessfulOperation
|
Status0_SuccessfulOperation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -309,10 +291,9 @@ pub enum CreateUsersWithListInputResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum DeleteUserResponse {
|
pub enum DeleteUserResponse {
|
||||||
/// Invalid username supplied
|
/// Invalid username supplied
|
||||||
Status400_InvalidUsernameSupplied
|
Status400_InvalidUsernameSupplied,
|
||||||
,
|
|
||||||
/// User not found
|
/// User not found
|
||||||
Status404_UserNotFound
|
Status404_UserNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -320,14 +301,11 @@ pub enum DeleteUserResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum GetUserByNameResponse {
|
pub enum GetUserByNameResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Invalid username supplied
|
/// Invalid username supplied
|
||||||
Status400_InvalidUsernameSupplied
|
Status400_InvalidUsernameSupplied,
|
||||||
,
|
|
||||||
/// User not found
|
/// User not found
|
||||||
Status404_UserNotFound
|
Status404_UserNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -335,22 +313,13 @@ pub enum GetUserByNameResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum LoginUserResponse {
|
pub enum LoginUserResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation {
|
||||||
{
|
|
||||||
body: String,
|
body: String,
|
||||||
x_rate_limit:
|
x_rate_limit: Option<i32>,
|
||||||
Option<
|
x_expires_after: Option<chrono::DateTime<chrono::Utc>>,
|
||||||
i32
|
},
|
||||||
>
|
|
||||||
,
|
|
||||||
x_expires_after:
|
|
||||||
Option<
|
|
||||||
chrono::DateTime::<chrono::Utc>
|
|
||||||
>
|
|
||||||
}
|
|
||||||
,
|
|
||||||
/// Invalid username/password supplied
|
/// Invalid username/password supplied
|
||||||
Status400_InvalidUsername
|
Status400_InvalidUsername,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -358,7 +327,7 @@ pub enum LoginUserResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum LogoutUserResponse {
|
pub enum LogoutUserResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status0_SuccessfulOperation
|
Status0_SuccessfulOperation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -366,18 +335,15 @@ pub enum LogoutUserResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum UpdateUserResponse {
|
pub enum UpdateUserResponse {
|
||||||
/// Invalid user supplied
|
/// Invalid user supplied
|
||||||
Status400_InvalidUserSupplied
|
Status400_InvalidUserSupplied,
|
||||||
,
|
|
||||||
/// User not found
|
/// User not found
|
||||||
Status404_UserNotFound
|
Status404_UserNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// API
|
/// API
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
#[allow(clippy::ptr_arg)]
|
#[allow(clippy::ptr_arg)]
|
||||||
pub trait Api {
|
pub trait Api {
|
||||||
|
|
||||||
/// To test special tags.
|
/// To test special tags.
|
||||||
///
|
///
|
||||||
/// TestSpecialTags - PATCH /v2/another-fake/dummy
|
/// TestSpecialTags - PATCH /v2/another-fake/dummy
|
||||||
@ -389,7 +355,6 @@ pub trait Api {
|
|||||||
body: models::Client,
|
body: models::Client,
|
||||||
) -> Result<TestSpecialTagsResponse, String>;
|
) -> Result<TestSpecialTagsResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Call123example - GET /v2/fake/operation-with-numeric-id
|
/// Call123example - GET /v2/fake/operation-with-numeric-id
|
||||||
async fn call123example(
|
async fn call123example(
|
||||||
&self,
|
&self,
|
||||||
@ -398,7 +363,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<Call123exampleResponse, String>;
|
) -> Result<Call123exampleResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// FakeOuterBooleanSerialize - POST /v2/fake/outer/boolean
|
/// FakeOuterBooleanSerialize - POST /v2/fake/outer/boolean
|
||||||
async fn fake_outer_boolean_serialize(
|
async fn fake_outer_boolean_serialize(
|
||||||
&self,
|
&self,
|
||||||
@ -408,7 +372,6 @@ pub trait Api {
|
|||||||
body: Option<models::OuterBoolean>,
|
body: Option<models::OuterBoolean>,
|
||||||
) -> Result<FakeOuterBooleanSerializeResponse, String>;
|
) -> Result<FakeOuterBooleanSerializeResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// FakeOuterCompositeSerialize - POST /v2/fake/outer/composite
|
/// FakeOuterCompositeSerialize - POST /v2/fake/outer/composite
|
||||||
async fn fake_outer_composite_serialize(
|
async fn fake_outer_composite_serialize(
|
||||||
&self,
|
&self,
|
||||||
@ -418,7 +381,6 @@ pub trait Api {
|
|||||||
body: Option<models::OuterComposite>,
|
body: Option<models::OuterComposite>,
|
||||||
) -> Result<FakeOuterCompositeSerializeResponse, String>;
|
) -> Result<FakeOuterCompositeSerializeResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// FakeOuterNumberSerialize - POST /v2/fake/outer/number
|
/// FakeOuterNumberSerialize - POST /v2/fake/outer/number
|
||||||
async fn fake_outer_number_serialize(
|
async fn fake_outer_number_serialize(
|
||||||
&self,
|
&self,
|
||||||
@ -428,7 +390,6 @@ pub trait Api {
|
|||||||
body: Option<models::OuterNumber>,
|
body: Option<models::OuterNumber>,
|
||||||
) -> Result<FakeOuterNumberSerializeResponse, String>;
|
) -> Result<FakeOuterNumberSerializeResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// FakeOuterStringSerialize - POST /v2/fake/outer/string
|
/// FakeOuterStringSerialize - POST /v2/fake/outer/string
|
||||||
async fn fake_outer_string_serialize(
|
async fn fake_outer_string_serialize(
|
||||||
&self,
|
&self,
|
||||||
@ -438,7 +399,6 @@ pub trait Api {
|
|||||||
body: Option<models::OuterString>,
|
body: Option<models::OuterString>,
|
||||||
) -> Result<FakeOuterStringSerializeResponse, String>;
|
) -> Result<FakeOuterStringSerializeResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// FakeResponseWithNumericalDescription - GET /v2/fake/response-with-numerical-description
|
/// FakeResponseWithNumericalDescription - GET /v2/fake/response-with-numerical-description
|
||||||
async fn fake_response_with_numerical_description(
|
async fn fake_response_with_numerical_description(
|
||||||
&self,
|
&self,
|
||||||
@ -447,7 +407,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<FakeResponseWithNumericalDescriptionResponse, String>;
|
) -> Result<FakeResponseWithNumericalDescriptionResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// HyphenParam - GET /v2/fake/hyphenParam/{hyphen-param}
|
/// HyphenParam - GET /v2/fake/hyphenParam/{hyphen-param}
|
||||||
async fn hyphen_param(
|
async fn hyphen_param(
|
||||||
&self,
|
&self,
|
||||||
@ -457,7 +416,6 @@ pub trait Api {
|
|||||||
path_params: models::HyphenParamPathParams,
|
path_params: models::HyphenParamPathParams,
|
||||||
) -> Result<HyphenParamResponse, String>;
|
) -> Result<HyphenParamResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// TestBodyWithQueryParams - PUT /v2/fake/body-with-query-params
|
/// TestBodyWithQueryParams - PUT /v2/fake/body-with-query-params
|
||||||
async fn test_body_with_query_params(
|
async fn test_body_with_query_params(
|
||||||
&self,
|
&self,
|
||||||
@ -468,7 +426,6 @@ pub trait Api {
|
|||||||
body: models::User,
|
body: models::User,
|
||||||
) -> Result<TestBodyWithQueryParamsResponse, String>;
|
) -> Result<TestBodyWithQueryParamsResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// To test \"client\" model.
|
/// To test \"client\" model.
|
||||||
///
|
///
|
||||||
/// TestClientModel - PATCH /v2/fake
|
/// TestClientModel - PATCH /v2/fake
|
||||||
@ -480,7 +437,6 @@ pub trait Api {
|
|||||||
body: models::Client,
|
body: models::Client,
|
||||||
) -> Result<TestClientModelResponse, String>;
|
) -> Result<TestClientModelResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트.
|
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트.
|
||||||
///
|
///
|
||||||
/// TestEndpointParameters - POST /v2/fake
|
/// TestEndpointParameters - POST /v2/fake
|
||||||
@ -491,7 +447,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<TestEndpointParametersResponse, String>;
|
) -> Result<TestEndpointParametersResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// To test enum parameters.
|
/// To test enum parameters.
|
||||||
///
|
///
|
||||||
/// TestEnumParameters - GET /v2/fake
|
/// TestEnumParameters - GET /v2/fake
|
||||||
@ -504,7 +459,6 @@ pub trait Api {
|
|||||||
query_params: models::TestEnumParametersQueryParams,
|
query_params: models::TestEnumParametersQueryParams,
|
||||||
) -> Result<TestEnumParametersResponse, String>;
|
) -> Result<TestEnumParametersResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// test inline additionalProperties.
|
/// test inline additionalProperties.
|
||||||
///
|
///
|
||||||
/// TestInlineAdditionalProperties - POST /v2/fake/inline-additionalProperties
|
/// TestInlineAdditionalProperties - POST /v2/fake/inline-additionalProperties
|
||||||
@ -516,7 +470,6 @@ pub trait Api {
|
|||||||
body: std::collections::HashMap<String, String>,
|
body: std::collections::HashMap<String, String>,
|
||||||
) -> Result<TestInlineAdditionalPropertiesResponse, String>;
|
) -> Result<TestInlineAdditionalPropertiesResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// test json serialization of form data.
|
/// test json serialization of form data.
|
||||||
///
|
///
|
||||||
/// TestJsonFormData - GET /v2/fake/jsonFormData
|
/// TestJsonFormData - GET /v2/fake/jsonFormData
|
||||||
@ -527,7 +480,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<TestJsonFormDataResponse, String>;
|
) -> Result<TestJsonFormDataResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// To test class name in snake case.
|
/// To test class name in snake case.
|
||||||
///
|
///
|
||||||
/// TestClassname - PATCH /v2/fake_classname_test
|
/// TestClassname - PATCH /v2/fake_classname_test
|
||||||
@ -539,7 +491,6 @@ pub trait Api {
|
|||||||
body: models::Client,
|
body: models::Client,
|
||||||
) -> Result<TestClassnameResponse, String>;
|
) -> Result<TestClassnameResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Add a new pet to the store.
|
/// Add a new pet to the store.
|
||||||
///
|
///
|
||||||
/// AddPet - POST /v2/pet
|
/// AddPet - POST /v2/pet
|
||||||
@ -551,7 +502,6 @@ pub trait Api {
|
|||||||
body: models::Pet,
|
body: models::Pet,
|
||||||
) -> Result<AddPetResponse, String>;
|
) -> Result<AddPetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Deletes a pet.
|
/// Deletes a pet.
|
||||||
///
|
///
|
||||||
/// DeletePet - DELETE /v2/pet/{petId}
|
/// DeletePet - DELETE /v2/pet/{petId}
|
||||||
@ -564,7 +514,6 @@ pub trait Api {
|
|||||||
path_params: models::DeletePetPathParams,
|
path_params: models::DeletePetPathParams,
|
||||||
) -> Result<DeletePetResponse, String>;
|
) -> Result<DeletePetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Finds Pets by status.
|
/// Finds Pets by status.
|
||||||
///
|
///
|
||||||
/// FindPetsByStatus - GET /v2/pet/findByStatus
|
/// FindPetsByStatus - GET /v2/pet/findByStatus
|
||||||
@ -576,7 +525,6 @@ pub trait Api {
|
|||||||
query_params: models::FindPetsByStatusQueryParams,
|
query_params: models::FindPetsByStatusQueryParams,
|
||||||
) -> Result<FindPetsByStatusResponse, String>;
|
) -> Result<FindPetsByStatusResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Finds Pets by tags.
|
/// Finds Pets by tags.
|
||||||
///
|
///
|
||||||
/// FindPetsByTags - GET /v2/pet/findByTags
|
/// FindPetsByTags - GET /v2/pet/findByTags
|
||||||
@ -588,7 +536,6 @@ pub trait Api {
|
|||||||
query_params: models::FindPetsByTagsQueryParams,
|
query_params: models::FindPetsByTagsQueryParams,
|
||||||
) -> Result<FindPetsByTagsResponse, String>;
|
) -> Result<FindPetsByTagsResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Find pet by ID.
|
/// Find pet by ID.
|
||||||
///
|
///
|
||||||
/// GetPetById - GET /v2/pet/{petId}
|
/// GetPetById - GET /v2/pet/{petId}
|
||||||
@ -600,7 +547,6 @@ pub trait Api {
|
|||||||
path_params: models::GetPetByIdPathParams,
|
path_params: models::GetPetByIdPathParams,
|
||||||
) -> Result<GetPetByIdResponse, String>;
|
) -> Result<GetPetByIdResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Update an existing pet.
|
/// Update an existing pet.
|
||||||
///
|
///
|
||||||
/// UpdatePet - PUT /v2/pet
|
/// UpdatePet - PUT /v2/pet
|
||||||
@ -612,7 +558,6 @@ pub trait Api {
|
|||||||
body: models::Pet,
|
body: models::Pet,
|
||||||
) -> Result<UpdatePetResponse, String>;
|
) -> Result<UpdatePetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Updates a pet in the store with form data.
|
/// Updates a pet in the store with form data.
|
||||||
///
|
///
|
||||||
/// UpdatePetWithForm - POST /v2/pet/{petId}
|
/// UpdatePetWithForm - POST /v2/pet/{petId}
|
||||||
@ -624,7 +569,6 @@ pub trait Api {
|
|||||||
path_params: models::UpdatePetWithFormPathParams,
|
path_params: models::UpdatePetWithFormPathParams,
|
||||||
) -> Result<UpdatePetWithFormResponse, String>;
|
) -> Result<UpdatePetWithFormResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// uploads an image.
|
/// uploads an image.
|
||||||
///
|
///
|
||||||
/// UploadFile - POST /v2/pet/{petId}/uploadImage
|
/// UploadFile - POST /v2/pet/{petId}/uploadImage
|
||||||
@ -637,7 +581,6 @@ pub trait Api {
|
|||||||
body: Multipart,
|
body: Multipart,
|
||||||
) -> Result<UploadFileResponse, String>;
|
) -> Result<UploadFileResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Delete purchase order by ID.
|
/// Delete purchase order by ID.
|
||||||
///
|
///
|
||||||
/// DeleteOrder - DELETE /v2/store/order/{order_id}
|
/// DeleteOrder - DELETE /v2/store/order/{order_id}
|
||||||
@ -649,7 +592,6 @@ pub trait Api {
|
|||||||
path_params: models::DeleteOrderPathParams,
|
path_params: models::DeleteOrderPathParams,
|
||||||
) -> Result<DeleteOrderResponse, String>;
|
) -> Result<DeleteOrderResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Returns pet inventories by status.
|
/// Returns pet inventories by status.
|
||||||
///
|
///
|
||||||
/// GetInventory - GET /v2/store/inventory
|
/// GetInventory - GET /v2/store/inventory
|
||||||
@ -660,7 +602,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<GetInventoryResponse, String>;
|
) -> Result<GetInventoryResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Find purchase order by ID.
|
/// Find purchase order by ID.
|
||||||
///
|
///
|
||||||
/// GetOrderById - GET /v2/store/order/{order_id}
|
/// GetOrderById - GET /v2/store/order/{order_id}
|
||||||
@ -672,7 +613,6 @@ pub trait Api {
|
|||||||
path_params: models::GetOrderByIdPathParams,
|
path_params: models::GetOrderByIdPathParams,
|
||||||
) -> Result<GetOrderByIdResponse, String>;
|
) -> Result<GetOrderByIdResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Place an order for a pet.
|
/// Place an order for a pet.
|
||||||
///
|
///
|
||||||
/// PlaceOrder - POST /v2/store/order
|
/// PlaceOrder - POST /v2/store/order
|
||||||
@ -684,7 +624,6 @@ pub trait Api {
|
|||||||
body: models::Order,
|
body: models::Order,
|
||||||
) -> Result<PlaceOrderResponse, String>;
|
) -> Result<PlaceOrderResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Create user.
|
/// Create user.
|
||||||
///
|
///
|
||||||
/// CreateUser - POST /v2/user
|
/// CreateUser - POST /v2/user
|
||||||
@ -696,7 +635,6 @@ pub trait Api {
|
|||||||
body: models::User,
|
body: models::User,
|
||||||
) -> Result<CreateUserResponse, String>;
|
) -> Result<CreateUserResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Creates list of users with given input array.
|
/// Creates list of users with given input array.
|
||||||
///
|
///
|
||||||
/// CreateUsersWithArrayInput - POST /v2/user/createWithArray
|
/// CreateUsersWithArrayInput - POST /v2/user/createWithArray
|
||||||
@ -708,7 +646,6 @@ pub trait Api {
|
|||||||
body: Vec<models::User>,
|
body: Vec<models::User>,
|
||||||
) -> Result<CreateUsersWithArrayInputResponse, String>;
|
) -> Result<CreateUsersWithArrayInputResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Creates list of users with given input array.
|
/// Creates list of users with given input array.
|
||||||
///
|
///
|
||||||
/// CreateUsersWithListInput - POST /v2/user/createWithList
|
/// CreateUsersWithListInput - POST /v2/user/createWithList
|
||||||
@ -720,7 +657,6 @@ pub trait Api {
|
|||||||
body: Vec<models::User>,
|
body: Vec<models::User>,
|
||||||
) -> Result<CreateUsersWithListInputResponse, String>;
|
) -> Result<CreateUsersWithListInputResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Delete user.
|
/// Delete user.
|
||||||
///
|
///
|
||||||
/// DeleteUser - DELETE /v2/user/{username}
|
/// DeleteUser - DELETE /v2/user/{username}
|
||||||
@ -732,7 +668,6 @@ pub trait Api {
|
|||||||
path_params: models::DeleteUserPathParams,
|
path_params: models::DeleteUserPathParams,
|
||||||
) -> Result<DeleteUserResponse, String>;
|
) -> Result<DeleteUserResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Get user by user name.
|
/// Get user by user name.
|
||||||
///
|
///
|
||||||
/// GetUserByName - GET /v2/user/{username}
|
/// GetUserByName - GET /v2/user/{username}
|
||||||
@ -744,7 +679,6 @@ pub trait Api {
|
|||||||
path_params: models::GetUserByNamePathParams,
|
path_params: models::GetUserByNamePathParams,
|
||||||
) -> Result<GetUserByNameResponse, String>;
|
) -> Result<GetUserByNameResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Logs user into the system.
|
/// Logs user into the system.
|
||||||
///
|
///
|
||||||
/// LoginUser - GET /v2/user/login
|
/// LoginUser - GET /v2/user/login
|
||||||
@ -756,7 +690,6 @@ pub trait Api {
|
|||||||
query_params: models::LoginUserQueryParams,
|
query_params: models::LoginUserQueryParams,
|
||||||
) -> Result<LoginUserResponse, String>;
|
) -> Result<LoginUserResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Logs out current logged in user session.
|
/// Logs out current logged in user session.
|
||||||
///
|
///
|
||||||
/// LogoutUser - GET /v2/user/logout
|
/// LogoutUser - GET /v2/user/logout
|
||||||
@ -767,7 +700,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<LogoutUserResponse, String>;
|
) -> Result<LogoutUserResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Updated user.
|
/// Updated user.
|
||||||
///
|
///
|
||||||
/// UpdateUser - PUT /v2/user/{username}
|
/// UpdateUser - PUT /v2/user/{username}
|
||||||
@ -779,7 +711,6 @@ pub trait Api {
|
|||||||
path_params: models::UpdateUserPathParams,
|
path_params: models::UpdateUserPathParams,
|
||||||
body: models::User,
|
body: models::User,
|
||||||
) -> Result<UpdateUserResponse, String>;
|
) -> Result<UpdateUserResponse, String>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -30,11 +30,16 @@ macro_rules! ihv_generate {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||||
Err(e) => Err(format!("Unable to parse {} as a string: {}",
|
Err(e) => Err(format!(
|
||||||
stringify!($t), e)),
|
"Unable to parse {} as a string: {}",
|
||||||
|
stringify!($t),
|
||||||
|
e
|
||||||
|
)),
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to parse header {:?} as a string - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,9 +79,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
|
|||||||
"" => None,
|
"" => None,
|
||||||
y => Some(y.to_string()),
|
y => Some(y.to_string()),
|
||||||
})
|
})
|
||||||
.collect())),
|
.collect(),
|
||||||
Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
|
)),
|
||||||
hdr_value, e)),
|
Err(e) => Err(format!(
|
||||||
|
"Unable to parse header: {:?} as a string - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,8 +95,10 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert {:?} into a header - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,8 +111,7 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
|
|||||||
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
||||||
Err(e) => Err(format!("Unable to convert header {:?} to {}",
|
Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,8 +122,10 @@ impl TryFrom<IntoHeaderValue<String>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0) {
|
match HeaderValue::from_str(&hdr_value.0) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert {:?} from a header {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,11 +139,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match hdr_value.parse() {
|
Ok(hdr_value) => match hdr_value.parse() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||||
Err(e) => Err(format!("Unable to parse bool from {} - {}",
|
Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert {:?} from a header {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,8 +155,10 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert: {:?} into a header: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,11 +172,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
||||||
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
||||||
Err(e) => Err(format!("Unable to parse: {} as date - {}",
|
Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to convert header {:?} to string {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert header {:?} to string {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,8 +188,10 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert {:?} to a header: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
#![allow(
|
||||||
|
missing_docs,
|
||||||
|
trivial_casts,
|
||||||
|
unused_variables,
|
||||||
|
unused_mut,
|
||||||
|
unused_imports,
|
||||||
|
unused_extern_crates,
|
||||||
|
non_camel_case_types
|
||||||
|
)]
|
||||||
#![allow(unused_imports, unused_attributes)]
|
#![allow(unused_imports, unused_attributes)]
|
||||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
||||||
|
|
||||||
@ -19,11 +27,9 @@ pub const API_VERSION: &str = "1.0.0";
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum AddPetResponse {
|
pub enum AddPetResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Invalid input
|
/// Invalid input
|
||||||
Status405_InvalidInput
|
Status405_InvalidInput,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -31,7 +37,7 @@ pub enum AddPetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum DeletePetResponse {
|
pub enum DeletePetResponse {
|
||||||
/// Invalid pet value
|
/// Invalid pet value
|
||||||
Status400_InvalidPetValue
|
Status400_InvalidPetValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -39,11 +45,9 @@ pub enum DeletePetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum FindPetsByStatusResponse {
|
pub enum FindPetsByStatusResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Invalid status value
|
/// Invalid status value
|
||||||
Status400_InvalidStatusValue
|
Status400_InvalidStatusValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -51,11 +55,9 @@ pub enum FindPetsByStatusResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum FindPetsByTagsResponse {
|
pub enum FindPetsByTagsResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Invalid tag value
|
/// Invalid tag value
|
||||||
Status400_InvalidTagValue
|
Status400_InvalidTagValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -63,14 +65,11 @@ pub enum FindPetsByTagsResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum GetPetByIdResponse {
|
pub enum GetPetByIdResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Invalid ID supplied
|
/// Invalid ID supplied
|
||||||
Status400_InvalidIDSupplied
|
Status400_InvalidIDSupplied,
|
||||||
,
|
|
||||||
/// Pet not found
|
/// Pet not found
|
||||||
Status404_PetNotFound
|
Status404_PetNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -78,17 +77,13 @@ pub enum GetPetByIdResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum UpdatePetResponse {
|
pub enum UpdatePetResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Invalid ID supplied
|
/// Invalid ID supplied
|
||||||
Status400_InvalidIDSupplied
|
Status400_InvalidIDSupplied,
|
||||||
,
|
|
||||||
/// Pet not found
|
/// Pet not found
|
||||||
Status404_PetNotFound
|
Status404_PetNotFound,
|
||||||
,
|
|
||||||
/// Validation exception
|
/// Validation exception
|
||||||
Status405_ValidationException
|
Status405_ValidationException,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -96,7 +91,7 @@ pub enum UpdatePetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum UpdatePetWithFormResponse {
|
pub enum UpdatePetWithFormResponse {
|
||||||
/// Invalid input
|
/// Invalid input
|
||||||
Status405_InvalidInput
|
Status405_InvalidInput,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -104,8 +99,7 @@ pub enum UpdatePetWithFormResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum UploadFileResponse {
|
pub enum UploadFileResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(models::ApiResponse),
|
||||||
(models::ApiResponse)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -113,10 +107,9 @@ pub enum UploadFileResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum DeleteOrderResponse {
|
pub enum DeleteOrderResponse {
|
||||||
/// Invalid ID supplied
|
/// Invalid ID supplied
|
||||||
Status400_InvalidIDSupplied
|
Status400_InvalidIDSupplied,
|
||||||
,
|
|
||||||
/// Order not found
|
/// Order not found
|
||||||
Status404_OrderNotFound
|
Status404_OrderNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -124,8 +117,7 @@ pub enum DeleteOrderResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum GetInventoryResponse {
|
pub enum GetInventoryResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(std::collections::HashMap<String, i32>),
|
||||||
(std::collections::HashMap<String, i32>)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -133,14 +125,11 @@ pub enum GetInventoryResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum GetOrderByIdResponse {
|
pub enum GetOrderByIdResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Invalid ID supplied
|
/// Invalid ID supplied
|
||||||
Status400_InvalidIDSupplied
|
Status400_InvalidIDSupplied,
|
||||||
,
|
|
||||||
/// Order not found
|
/// Order not found
|
||||||
Status404_OrderNotFound
|
Status404_OrderNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -148,11 +137,9 @@ pub enum GetOrderByIdResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum PlaceOrderResponse {
|
pub enum PlaceOrderResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Invalid Order
|
/// Invalid Order
|
||||||
Status400_InvalidOrder
|
Status400_InvalidOrder,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -160,7 +147,7 @@ pub enum PlaceOrderResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum CreateUserResponse {
|
pub enum CreateUserResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status0_SuccessfulOperation
|
Status0_SuccessfulOperation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -168,7 +155,7 @@ pub enum CreateUserResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum CreateUsersWithArrayInputResponse {
|
pub enum CreateUsersWithArrayInputResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status0_SuccessfulOperation
|
Status0_SuccessfulOperation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -176,7 +163,7 @@ pub enum CreateUsersWithArrayInputResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum CreateUsersWithListInputResponse {
|
pub enum CreateUsersWithListInputResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status0_SuccessfulOperation
|
Status0_SuccessfulOperation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -184,10 +171,9 @@ pub enum CreateUsersWithListInputResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum DeleteUserResponse {
|
pub enum DeleteUserResponse {
|
||||||
/// Invalid username supplied
|
/// Invalid username supplied
|
||||||
Status400_InvalidUsernameSupplied
|
Status400_InvalidUsernameSupplied,
|
||||||
,
|
|
||||||
/// User not found
|
/// User not found
|
||||||
Status404_UserNotFound
|
Status404_UserNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -195,14 +181,11 @@ pub enum DeleteUserResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum GetUserByNameResponse {
|
pub enum GetUserByNameResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation(String),
|
||||||
(String)
|
|
||||||
,
|
|
||||||
/// Invalid username supplied
|
/// Invalid username supplied
|
||||||
Status400_InvalidUsernameSupplied
|
Status400_InvalidUsernameSupplied,
|
||||||
,
|
|
||||||
/// User not found
|
/// User not found
|
||||||
Status404_UserNotFound
|
Status404_UserNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -210,27 +193,14 @@ pub enum GetUserByNameResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum LoginUserResponse {
|
pub enum LoginUserResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status200_SuccessfulOperation
|
Status200_SuccessfulOperation {
|
||||||
{
|
|
||||||
body: String,
|
body: String,
|
||||||
set_cookie:
|
set_cookie: Option<String>,
|
||||||
Option<
|
x_rate_limit: Option<i32>,
|
||||||
String
|
x_expires_after: Option<chrono::DateTime<chrono::Utc>>,
|
||||||
>
|
},
|
||||||
,
|
|
||||||
x_rate_limit:
|
|
||||||
Option<
|
|
||||||
i32
|
|
||||||
>
|
|
||||||
,
|
|
||||||
x_expires_after:
|
|
||||||
Option<
|
|
||||||
chrono::DateTime::<chrono::Utc>
|
|
||||||
>
|
|
||||||
}
|
|
||||||
,
|
|
||||||
/// Invalid username/password supplied
|
/// Invalid username/password supplied
|
||||||
Status400_InvalidUsername
|
Status400_InvalidUsername,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -238,7 +208,7 @@ pub enum LoginUserResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum LogoutUserResponse {
|
pub enum LogoutUserResponse {
|
||||||
/// successful operation
|
/// successful operation
|
||||||
Status0_SuccessfulOperation
|
Status0_SuccessfulOperation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -246,18 +216,15 @@ pub enum LogoutUserResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum UpdateUserResponse {
|
pub enum UpdateUserResponse {
|
||||||
/// Invalid user supplied
|
/// Invalid user supplied
|
||||||
Status400_InvalidUserSupplied
|
Status400_InvalidUserSupplied,
|
||||||
,
|
|
||||||
/// User not found
|
/// User not found
|
||||||
Status404_UserNotFound
|
Status404_UserNotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// API
|
/// API
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
#[allow(clippy::ptr_arg)]
|
#[allow(clippy::ptr_arg)]
|
||||||
pub trait Api {
|
pub trait Api {
|
||||||
|
|
||||||
/// Add a new pet to the store.
|
/// Add a new pet to the store.
|
||||||
///
|
///
|
||||||
/// AddPet - POST /v2/pet
|
/// AddPet - POST /v2/pet
|
||||||
@ -269,7 +236,6 @@ pub trait Api {
|
|||||||
body: models::Pet,
|
body: models::Pet,
|
||||||
) -> Result<AddPetResponse, String>;
|
) -> Result<AddPetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Deletes a pet.
|
/// Deletes a pet.
|
||||||
///
|
///
|
||||||
/// DeletePet - DELETE /v2/pet/{petId}
|
/// DeletePet - DELETE /v2/pet/{petId}
|
||||||
@ -282,7 +248,6 @@ pub trait Api {
|
|||||||
path_params: models::DeletePetPathParams,
|
path_params: models::DeletePetPathParams,
|
||||||
) -> Result<DeletePetResponse, String>;
|
) -> Result<DeletePetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Finds Pets by status.
|
/// Finds Pets by status.
|
||||||
///
|
///
|
||||||
/// FindPetsByStatus - GET /v2/pet/findByStatus
|
/// FindPetsByStatus - GET /v2/pet/findByStatus
|
||||||
@ -294,7 +259,6 @@ pub trait Api {
|
|||||||
query_params: models::FindPetsByStatusQueryParams,
|
query_params: models::FindPetsByStatusQueryParams,
|
||||||
) -> Result<FindPetsByStatusResponse, String>;
|
) -> Result<FindPetsByStatusResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Finds Pets by tags.
|
/// Finds Pets by tags.
|
||||||
///
|
///
|
||||||
/// FindPetsByTags - GET /v2/pet/findByTags
|
/// FindPetsByTags - GET /v2/pet/findByTags
|
||||||
@ -306,7 +270,6 @@ pub trait Api {
|
|||||||
query_params: models::FindPetsByTagsQueryParams,
|
query_params: models::FindPetsByTagsQueryParams,
|
||||||
) -> Result<FindPetsByTagsResponse, String>;
|
) -> Result<FindPetsByTagsResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Find pet by ID.
|
/// Find pet by ID.
|
||||||
///
|
///
|
||||||
/// GetPetById - GET /v2/pet/{petId}
|
/// GetPetById - GET /v2/pet/{petId}
|
||||||
@ -318,7 +281,6 @@ pub trait Api {
|
|||||||
path_params: models::GetPetByIdPathParams,
|
path_params: models::GetPetByIdPathParams,
|
||||||
) -> Result<GetPetByIdResponse, String>;
|
) -> Result<GetPetByIdResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Update an existing pet.
|
/// Update an existing pet.
|
||||||
///
|
///
|
||||||
/// UpdatePet - PUT /v2/pet
|
/// UpdatePet - PUT /v2/pet
|
||||||
@ -330,7 +292,6 @@ pub trait Api {
|
|||||||
body: models::Pet,
|
body: models::Pet,
|
||||||
) -> Result<UpdatePetResponse, String>;
|
) -> Result<UpdatePetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Updates a pet in the store with form data.
|
/// Updates a pet in the store with form data.
|
||||||
///
|
///
|
||||||
/// UpdatePetWithForm - POST /v2/pet/{petId}
|
/// UpdatePetWithForm - POST /v2/pet/{petId}
|
||||||
@ -342,7 +303,6 @@ pub trait Api {
|
|||||||
path_params: models::UpdatePetWithFormPathParams,
|
path_params: models::UpdatePetWithFormPathParams,
|
||||||
) -> Result<UpdatePetWithFormResponse, String>;
|
) -> Result<UpdatePetWithFormResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// uploads an image.
|
/// uploads an image.
|
||||||
///
|
///
|
||||||
/// UploadFile - POST /v2/pet/{petId}/uploadImage
|
/// UploadFile - POST /v2/pet/{petId}/uploadImage
|
||||||
@ -355,7 +315,6 @@ pub trait Api {
|
|||||||
body: Multipart,
|
body: Multipart,
|
||||||
) -> Result<UploadFileResponse, String>;
|
) -> Result<UploadFileResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Delete purchase order by ID.
|
/// Delete purchase order by ID.
|
||||||
///
|
///
|
||||||
/// DeleteOrder - DELETE /v2/store/order/{orderId}
|
/// DeleteOrder - DELETE /v2/store/order/{orderId}
|
||||||
@ -367,7 +326,6 @@ pub trait Api {
|
|||||||
path_params: models::DeleteOrderPathParams,
|
path_params: models::DeleteOrderPathParams,
|
||||||
) -> Result<DeleteOrderResponse, String>;
|
) -> Result<DeleteOrderResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Returns pet inventories by status.
|
/// Returns pet inventories by status.
|
||||||
///
|
///
|
||||||
/// GetInventory - GET /v2/store/inventory
|
/// GetInventory - GET /v2/store/inventory
|
||||||
@ -378,7 +336,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<GetInventoryResponse, String>;
|
) -> Result<GetInventoryResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Find purchase order by ID.
|
/// Find purchase order by ID.
|
||||||
///
|
///
|
||||||
/// GetOrderById - GET /v2/store/order/{orderId}
|
/// GetOrderById - GET /v2/store/order/{orderId}
|
||||||
@ -390,7 +347,6 @@ pub trait Api {
|
|||||||
path_params: models::GetOrderByIdPathParams,
|
path_params: models::GetOrderByIdPathParams,
|
||||||
) -> Result<GetOrderByIdResponse, String>;
|
) -> Result<GetOrderByIdResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Place an order for a pet.
|
/// Place an order for a pet.
|
||||||
///
|
///
|
||||||
/// PlaceOrder - POST /v2/store/order
|
/// PlaceOrder - POST /v2/store/order
|
||||||
@ -402,7 +358,6 @@ pub trait Api {
|
|||||||
body: models::Order,
|
body: models::Order,
|
||||||
) -> Result<PlaceOrderResponse, String>;
|
) -> Result<PlaceOrderResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Create user.
|
/// Create user.
|
||||||
///
|
///
|
||||||
/// CreateUser - POST /v2/user
|
/// CreateUser - POST /v2/user
|
||||||
@ -414,7 +369,6 @@ pub trait Api {
|
|||||||
body: models::User,
|
body: models::User,
|
||||||
) -> Result<CreateUserResponse, String>;
|
) -> Result<CreateUserResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Creates list of users with given input array.
|
/// Creates list of users with given input array.
|
||||||
///
|
///
|
||||||
/// CreateUsersWithArrayInput - POST /v2/user/createWithArray
|
/// CreateUsersWithArrayInput - POST /v2/user/createWithArray
|
||||||
@ -426,7 +380,6 @@ pub trait Api {
|
|||||||
body: Vec<models::User>,
|
body: Vec<models::User>,
|
||||||
) -> Result<CreateUsersWithArrayInputResponse, String>;
|
) -> Result<CreateUsersWithArrayInputResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Creates list of users with given input array.
|
/// Creates list of users with given input array.
|
||||||
///
|
///
|
||||||
/// CreateUsersWithListInput - POST /v2/user/createWithList
|
/// CreateUsersWithListInput - POST /v2/user/createWithList
|
||||||
@ -438,7 +391,6 @@ pub trait Api {
|
|||||||
body: Vec<models::User>,
|
body: Vec<models::User>,
|
||||||
) -> Result<CreateUsersWithListInputResponse, String>;
|
) -> Result<CreateUsersWithListInputResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Delete user.
|
/// Delete user.
|
||||||
///
|
///
|
||||||
/// DeleteUser - DELETE /v2/user/{username}
|
/// DeleteUser - DELETE /v2/user/{username}
|
||||||
@ -450,7 +402,6 @@ pub trait Api {
|
|||||||
path_params: models::DeleteUserPathParams,
|
path_params: models::DeleteUserPathParams,
|
||||||
) -> Result<DeleteUserResponse, String>;
|
) -> Result<DeleteUserResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Get user by user name.
|
/// Get user by user name.
|
||||||
///
|
///
|
||||||
/// GetUserByName - GET /v2/user/{username}
|
/// GetUserByName - GET /v2/user/{username}
|
||||||
@ -462,7 +413,6 @@ pub trait Api {
|
|||||||
path_params: models::GetUserByNamePathParams,
|
path_params: models::GetUserByNamePathParams,
|
||||||
) -> Result<GetUserByNameResponse, String>;
|
) -> Result<GetUserByNameResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Logs user into the system.
|
/// Logs user into the system.
|
||||||
///
|
///
|
||||||
/// LoginUser - GET /v2/user/login
|
/// LoginUser - GET /v2/user/login
|
||||||
@ -474,7 +424,6 @@ pub trait Api {
|
|||||||
query_params: models::LoginUserQueryParams,
|
query_params: models::LoginUserQueryParams,
|
||||||
) -> Result<LoginUserResponse, String>;
|
) -> Result<LoginUserResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Logs out current logged in user session.
|
/// Logs out current logged in user session.
|
||||||
///
|
///
|
||||||
/// LogoutUser - GET /v2/user/logout
|
/// LogoutUser - GET /v2/user/logout
|
||||||
@ -485,7 +434,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<LogoutUserResponse, String>;
|
) -> Result<LogoutUserResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Updated user.
|
/// Updated user.
|
||||||
///
|
///
|
||||||
/// UpdateUser - PUT /v2/user/{username}
|
/// UpdateUser - PUT /v2/user/{username}
|
||||||
@ -497,7 +445,6 @@ pub trait Api {
|
|||||||
path_params: models::UpdateUserPathParams,
|
path_params: models::UpdateUserPathParams,
|
||||||
body: models::User,
|
body: models::User,
|
||||||
) -> Result<UpdateUserResponse, String>;
|
) -> Result<UpdateUserResponse, String>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -30,11 +30,16 @@ macro_rules! ihv_generate {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||||
Err(e) => Err(format!("Unable to parse {} as a string: {}",
|
Err(e) => Err(format!(
|
||||||
stringify!($t), e)),
|
"Unable to parse {} as a string: {}",
|
||||||
|
stringify!($t),
|
||||||
|
e
|
||||||
|
)),
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to parse header {:?} as a string - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,9 +79,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
|
|||||||
"" => None,
|
"" => None,
|
||||||
y => Some(y.to_string()),
|
y => Some(y.to_string()),
|
||||||
})
|
})
|
||||||
.collect())),
|
.collect(),
|
||||||
Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
|
)),
|
||||||
hdr_value, e)),
|
Err(e) => Err(format!(
|
||||||
|
"Unable to parse header: {:?} as a string - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,8 +95,10 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert {:?} into a header - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,8 +111,7 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
|
|||||||
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
||||||
Err(e) => Err(format!("Unable to convert header {:?} to {}",
|
Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,8 +122,10 @@ impl TryFrom<IntoHeaderValue<String>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0) {
|
match HeaderValue::from_str(&hdr_value.0) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert {:?} from a header {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,11 +139,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match hdr_value.parse() {
|
Ok(hdr_value) => match hdr_value.parse() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||||
Err(e) => Err(format!("Unable to parse bool from {} - {}",
|
Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert {:?} from a header {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,8 +155,10 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert: {:?} into a header: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,11 +172,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
||||||
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
||||||
Err(e) => Err(format!("Unable to parse: {} as date - {}",
|
Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to convert header {:?} to string {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert header {:?} to string {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,8 +188,10 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert {:?} to a header: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
#![allow(
|
||||||
|
missing_docs,
|
||||||
|
trivial_casts,
|
||||||
|
unused_variables,
|
||||||
|
unused_mut,
|
||||||
|
unused_imports,
|
||||||
|
unused_extern_crates,
|
||||||
|
non_camel_case_types
|
||||||
|
)]
|
||||||
#![allow(unused_imports, unused_attributes)]
|
#![allow(unused_imports, unused_attributes)]
|
||||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
||||||
|
|
||||||
@ -19,15 +27,13 @@ pub const API_VERSION: &str = "1.0";
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum PingGetResponse {
|
pub enum PingGetResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status201_OK
|
Status201_OK,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// API
|
/// API
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
#[allow(clippy::ptr_arg)]
|
#[allow(clippy::ptr_arg)]
|
||||||
pub trait Api {
|
pub trait Api {
|
||||||
|
|
||||||
/// PingGet - GET /ping
|
/// PingGet - GET /ping
|
||||||
async fn ping_get(
|
async fn ping_get(
|
||||||
&self,
|
&self,
|
||||||
@ -35,7 +41,6 @@ pub trait Api {
|
|||||||
host: Host,
|
host: Host,
|
||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<PingGetResponse, String>;
|
) -> Result<PingGetResponse, String>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
|
@ -6,6 +6,3 @@ use validator::Validate;
|
|||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
use crate::header;
|
use crate::header;
|
||||||
use crate::{models, types::*};
|
use crate::{models, types::*};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,9 +12,7 @@ use crate::{header, types::*};
|
|||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::models;
|
use crate::models;
|
||||||
|
|
||||||
use crate::{Api,
|
use crate::{Api, PingGetResponse};
|
||||||
PingGetResponse
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Setup API Server.
|
/// Setup API Server.
|
||||||
pub fn new<I, A>(api_impl: I) -> Router
|
pub fn new<I, A>(api_impl: I) -> Router
|
||||||
@ -24,21 +22,13 @@ where
|
|||||||
{
|
{
|
||||||
// build our application with a route
|
// build our application with a route
|
||||||
Router::new()
|
Router::new()
|
||||||
.route("/ping",
|
.route("/ping", get(ping_get::<I, A>))
|
||||||
get(ping_get::<I, A>)
|
|
||||||
)
|
|
||||||
.with_state(api_impl)
|
.with_state(api_impl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn ping_get_validation(
|
fn ping_get_validation() -> std::result::Result<(), ValidationErrors> {
|
||||||
) -> std::result::Result<(
|
Ok(())
|
||||||
), ValidationErrors>
|
|
||||||
{
|
|
||||||
|
|
||||||
Ok((
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// PingGet - GET /ping
|
/// PingGet - GET /ping
|
||||||
@ -53,45 +43,38 @@ where
|
|||||||
I: AsRef<A> + Send + Sync,
|
I: AsRef<A> + Send + Sync,
|
||||||
A: Api,
|
A: Api,
|
||||||
{
|
{
|
||||||
|
|
||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
let validation = tokio::task::spawn_blocking(move ||
|
let validation = tokio::task::spawn_blocking(move || ping_get_validation())
|
||||||
ping_get_validation(
|
.await
|
||||||
)
|
.unwrap();
|
||||||
).await.unwrap();
|
|
||||||
|
|
||||||
let Ok((
|
let Ok(()) = validation else {
|
||||||
)) = validation else {
|
|
||||||
return Response::builder()
|
return Response::builder()
|
||||||
.status(StatusCode::BAD_REQUEST)
|
.status(StatusCode::BAD_REQUEST)
|
||||||
.body(Body::from(validation.unwrap_err().to_string()))
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = api_impl.as_ref().ping_get(
|
let result = api_impl.as_ref().ping_get(method, host, cookies).await;
|
||||||
method,
|
|
||||||
host,
|
|
||||||
cookies,
|
|
||||||
).await;
|
|
||||||
|
|
||||||
let mut response = Response::builder();
|
let mut response = Response::builder();
|
||||||
|
|
||||||
let resp = match result {
|
let resp = match result {
|
||||||
Ok(rsp) => match rsp {
|
Ok(rsp) => match rsp {
|
||||||
PingGetResponse::Status201_OK
|
PingGetResponse::Status201_OK => {
|
||||||
=> {
|
|
||||||
|
|
||||||
let mut response = response.status(201);
|
let mut response = response.status(201);
|
||||||
response.body(Body::empty())
|
response.body(Body::empty())
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Application code returned an error. This should not happen, as the implementation should
|
// Application code returned an error. This should not happen, as the implementation should
|
||||||
// return a valid response.
|
// return a valid response.
|
||||||
response.status(500).body(Body::empty())
|
response.status(500).body(Body::empty())
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
resp.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,11 +30,16 @@ macro_rules! ihv_generate {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
Ok(hdr_value) => match hdr_value.parse::<$t>() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||||
Err(e) => Err(format!("Unable to parse {} as a string: {}",
|
Err(e) => Err(format!(
|
||||||
stringify!($t), e)),
|
"Unable to parse {} as a string: {}",
|
||||||
|
stringify!($t),
|
||||||
|
e
|
||||||
|
)),
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to parse header {:?} as a string - {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to parse header {:?} as a string - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,9 +79,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<Vec<String>> {
|
|||||||
"" => None,
|
"" => None,
|
||||||
y => Some(y.to_string()),
|
y => Some(y.to_string()),
|
||||||
})
|
})
|
||||||
.collect())),
|
.collect(),
|
||||||
Err(e) => Err(format!("Unable to parse header: {:?} as a string - {}",
|
)),
|
||||||
hdr_value, e)),
|
Err(e) => Err(format!(
|
||||||
|
"Unable to parse header: {:?} as a string - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,8 +95,10 @@ impl TryFrom<IntoHeaderValue<Vec<String>>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<Vec<String>>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
match HeaderValue::from_str(&hdr_value.0.join(", ")) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} into a header - {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert {:?} into a header - {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,8 +111,7 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<String> {
|
|||||||
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: HeaderValue) -> Result<Self, Self::Error> {
|
||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value.to_string())),
|
||||||
Err(e) => Err(format!("Unable to convert header {:?} to {}",
|
Err(e) => Err(format!("Unable to convert header {:?} to {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,8 +122,10 @@ impl TryFrom<IntoHeaderValue<String>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<String>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0) {
|
match HeaderValue::from_str(&hdr_value.0) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert {:?} from a header {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,11 +139,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<bool> {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match hdr_value.parse() {
|
Ok(hdr_value) => match hdr_value.parse() {
|
||||||
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
Ok(hdr_value) => Ok(IntoHeaderValue(hdr_value)),
|
||||||
Err(e) => Err(format!("Unable to parse bool from {} - {}",
|
Err(e) => Err(format!("Unable to parse bool from {} - {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to convert {:?} from a header {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert {:?} from a header {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,8 +155,10 @@ impl TryFrom<IntoHeaderValue<bool>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<bool>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
match HeaderValue::from_str(&hdr_value.0.to_string()) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert: {:?} into a header: {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e))
|
"Unable to convert: {:?} into a header: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,11 +172,12 @@ impl TryFrom<HeaderValue> for IntoHeaderValue<DateTime<Utc>> {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
Ok(hdr_value) => match DateTime::parse_from_rfc3339(hdr_value) {
|
||||||
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
Ok(date) => Ok(IntoHeaderValue(date.with_timezone(&Utc))),
|
||||||
Err(e) => Err(format!("Unable to parse: {} as date - {}",
|
Err(e) => Err(format!("Unable to parse: {} as date - {}", hdr_value, e)),
|
||||||
hdr_value, e)),
|
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Unable to convert header {:?} to string {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert header {:?} to string {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,8 +188,10 @@ impl TryFrom<IntoHeaderValue<DateTime<Utc>>> for HeaderValue {
|
|||||||
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
fn try_from(hdr_value: IntoHeaderValue<DateTime<Utc>>) -> Result<Self, Self::Error> {
|
||||||
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
match HeaderValue::from_str(hdr_value.0.to_rfc3339().as_str()) {
|
||||||
Ok(hdr_value) => Ok(hdr_value),
|
Ok(hdr_value) => Ok(hdr_value),
|
||||||
Err(e) => Err(format!("Unable to convert {:?} to a header: {}",
|
Err(e) => Err(format!(
|
||||||
hdr_value, e)),
|
"Unable to convert {:?} to a header: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)]
|
#![allow(
|
||||||
|
missing_docs,
|
||||||
|
trivial_casts,
|
||||||
|
unused_variables,
|
||||||
|
unused_mut,
|
||||||
|
unused_imports,
|
||||||
|
unused_extern_crates,
|
||||||
|
non_camel_case_types
|
||||||
|
)]
|
||||||
#![allow(unused_imports, unused_attributes)]
|
#![allow(unused_imports, unused_attributes)]
|
||||||
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
#![allow(clippy::derive_partial_eq_without_eq, clippy::disallowed_names)]
|
||||||
|
|
||||||
@ -19,8 +27,7 @@ pub const API_VERSION: &str = "2.3.4";
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum AllOfGetResponse {
|
pub enum AllOfGetResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status200_OK
|
Status200_OK(models::AllOfObject),
|
||||||
(models::AllOfObject)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -28,7 +35,7 @@ pub enum AllOfGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum DummyGetResponse {
|
pub enum DummyGetResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -36,7 +43,7 @@ pub enum DummyGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum DummyPutResponse {
|
pub enum DummyPutResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -44,8 +51,7 @@ pub enum DummyPutResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum FileResponseGetResponse {
|
pub enum FileResponseGetResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success(ByteArray),
|
||||||
(ByteArray)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -53,8 +59,7 @@ pub enum FileResponseGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum GetStructuredYamlResponse {
|
pub enum GetStructuredYamlResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status200_OK
|
Status200_OK(String),
|
||||||
(String)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -62,8 +67,7 @@ pub enum GetStructuredYamlResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum HtmlPostResponse {
|
pub enum HtmlPostResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success(String),
|
||||||
(String)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -71,7 +75,7 @@ pub enum HtmlPostResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum PostYamlResponse {
|
pub enum PostYamlResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status204_OK
|
Status204_OK,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -79,8 +83,7 @@ pub enum PostYamlResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum RawJsonGetResponse {
|
pub enum RawJsonGetResponse {
|
||||||
/// Success
|
/// Success
|
||||||
Status200_Success
|
Status200_Success(crate::types::Object),
|
||||||
(crate::types::Object)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -88,15 +91,13 @@ pub enum RawJsonGetResponse {
|
|||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum SoloObjectPostResponse {
|
pub enum SoloObjectPostResponse {
|
||||||
/// OK
|
/// OK
|
||||||
Status204_OK
|
Status204_OK,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// API
|
/// API
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
#[allow(clippy::ptr_arg)]
|
#[allow(clippy::ptr_arg)]
|
||||||
pub trait Api {
|
pub trait Api {
|
||||||
|
|
||||||
/// AllOfGet - GET /allOf
|
/// AllOfGet - GET /allOf
|
||||||
async fn all_of_get(
|
async fn all_of_get(
|
||||||
&self,
|
&self,
|
||||||
@ -105,7 +106,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<AllOfGetResponse, String>;
|
) -> Result<AllOfGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// A dummy endpoint to make the spec valid..
|
/// A dummy endpoint to make the spec valid..
|
||||||
///
|
///
|
||||||
/// DummyGet - GET /dummy
|
/// DummyGet - GET /dummy
|
||||||
@ -116,7 +116,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<DummyGetResponse, String>;
|
) -> Result<DummyGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// DummyPut - PUT /dummy
|
/// DummyPut - PUT /dummy
|
||||||
async fn dummy_put(
|
async fn dummy_put(
|
||||||
&self,
|
&self,
|
||||||
@ -126,7 +125,6 @@ pub trait Api {
|
|||||||
body: models::DummyPutRequest,
|
body: models::DummyPutRequest,
|
||||||
) -> Result<DummyPutResponse, String>;
|
) -> Result<DummyPutResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Get a file.
|
/// Get a file.
|
||||||
///
|
///
|
||||||
/// FileResponseGet - GET /file_response
|
/// FileResponseGet - GET /file_response
|
||||||
@ -137,7 +135,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<FileResponseGetResponse, String>;
|
) -> Result<FileResponseGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// GetStructuredYaml - GET /get-structured-yaml
|
/// GetStructuredYaml - GET /get-structured-yaml
|
||||||
async fn get_structured_yaml(
|
async fn get_structured_yaml(
|
||||||
&self,
|
&self,
|
||||||
@ -146,7 +143,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<GetStructuredYamlResponse, String>;
|
) -> Result<GetStructuredYamlResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Test HTML handling.
|
/// Test HTML handling.
|
||||||
///
|
///
|
||||||
/// HtmlPost - POST /html
|
/// HtmlPost - POST /html
|
||||||
@ -158,7 +154,6 @@ pub trait Api {
|
|||||||
body: String,
|
body: String,
|
||||||
) -> Result<HtmlPostResponse, String>;
|
) -> Result<HtmlPostResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// PostYaml - POST /post-yaml
|
/// PostYaml - POST /post-yaml
|
||||||
async fn post_yaml(
|
async fn post_yaml(
|
||||||
&self,
|
&self,
|
||||||
@ -168,7 +163,6 @@ pub trait Api {
|
|||||||
body: String,
|
body: String,
|
||||||
) -> Result<PostYamlResponse, String>;
|
) -> Result<PostYamlResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Get an arbitrary JSON blob..
|
/// Get an arbitrary JSON blob..
|
||||||
///
|
///
|
||||||
/// RawJsonGet - GET /raw_json
|
/// RawJsonGet - GET /raw_json
|
||||||
@ -179,7 +173,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
) -> Result<RawJsonGetResponse, String>;
|
) -> Result<RawJsonGetResponse, String>;
|
||||||
|
|
||||||
|
|
||||||
/// Send an arbitrary JSON blob.
|
/// Send an arbitrary JSON blob.
|
||||||
///
|
///
|
||||||
/// SoloObjectPost - POST /solo-object
|
/// SoloObjectPost - POST /solo-object
|
||||||
@ -190,7 +183,6 @@ pub trait Api {
|
|||||||
cookies: CookieJar,
|
cookies: CookieJar,
|
||||||
body: crate::types::Object,
|
body: crate::types::Object,
|
||||||
) -> Result<SoloObjectPostResponse, String>;
|
) -> Result<SoloObjectPostResponse, String>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
|
@ -7,20 +7,6 @@ use validator::Validate;
|
|||||||
use crate::header;
|
use crate::header;
|
||||||
use crate::{models, types::*};
|
use crate::{models, types::*};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct ANullableContainer {
|
pub struct ANullableContainer {
|
||||||
@ -32,13 +18,11 @@ pub struct ANullableContainer {
|
|||||||
|
|
||||||
#[serde(rename = "RequiredNullableThing")]
|
#[serde(rename = "RequiredNullableThing")]
|
||||||
pub required_nullable_thing: Nullable<String>,
|
pub required_nullable_thing: Nullable<String>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl ANullableContainer {
|
impl ANullableContainer {
|
||||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||||
pub fn new(required_nullable_thing: Nullable<String>, ) -> ANullableContainer {
|
pub fn new(required_nullable_thing: Nullable<String>) -> ANullableContainer {
|
||||||
ANullableContainer {
|
ANullableContainer {
|
||||||
nullable_thing: None,
|
nullable_thing: None,
|
||||||
required_nullable_thing,
|
required_nullable_thing,
|
||||||
@ -52,18 +36,21 @@ impl ANullableContainer {
|
|||||||
impl std::string::ToString for ANullableContainer {
|
impl std::string::ToString for ANullableContainer {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
let params: Vec<Option<String>> = vec![
|
let params: Vec<Option<String>> = vec![
|
||||||
|
|
||||||
self.nullable_thing.as_ref().map(|nullable_thing| {
|
self.nullable_thing.as_ref().map(|nullable_thing| {
|
||||||
[
|
[
|
||||||
"NullableThing".to_string(),
|
"NullableThing".to_string(),
|
||||||
nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string()),
|
nullable_thing
|
||||||
].join(",")
|
.as_ref()
|
||||||
|
.map_or("null".to_string(), |x| x.to_string()),
|
||||||
|
]
|
||||||
|
.join(",")
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
||||||
Some("RequiredNullableThing".to_string()),
|
Some("RequiredNullableThing".to_string()),
|
||||||
Some(self.required_nullable_thing.as_ref().map_or("null".to_string(), |x| x.to_string())),
|
Some(
|
||||||
|
self.required_nullable_thing
|
||||||
|
.as_ref()
|
||||||
|
.map_or("null".to_string(), |x| x.to_string()),
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||||
@ -94,7 +81,11 @@ impl std::str::FromStr for ANullableContainer {
|
|||||||
while key_result.is_some() {
|
while key_result.is_some() {
|
||||||
let val = match string_iter.next() {
|
let val = match string_iter.next() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => return std::result::Result::Err("Missing value while parsing ANullableContainer".to_string())
|
None => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Missing value while parsing ANullableContainer".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(key) = key_result {
|
if let Some(key) = key_result {
|
||||||
@ -112,8 +103,12 @@ impl std::str::FromStr for ANullableContainer {
|
|||||||
|
|
||||||
// Use the intermediate representation to return the struct
|
// Use the intermediate representation to return the struct
|
||||||
std::result::Result::Ok(ANullableContainer {
|
std::result::Result::Ok(ANullableContainer {
|
||||||
nullable_thing: std::result::Result::Err("Nullable types not supported in ANullableContainer".to_string())?,
|
nullable_thing: std::result::Result::Err(
|
||||||
required_nullable_thing: std::result::Result::Err("Nullable types not supported in ANullableContainer".to_string())?,
|
"Nullable types not supported in ANullableContainer".to_string(),
|
||||||
|
)?,
|
||||||
|
required_nullable_thing: std::result::Result::Err(
|
||||||
|
"Nullable types not supported in ANullableContainer".to_string(),
|
||||||
|
)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,13 +119,16 @@ impl std::str::FromStr for ANullableContainer {
|
|||||||
impl std::convert::TryFrom<header::IntoHeaderValue<ANullableContainer>> for HeaderValue {
|
impl std::convert::TryFrom<header::IntoHeaderValue<ANullableContainer>> for HeaderValue {
|
||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
fn try_from(hdr_value: header::IntoHeaderValue<ANullableContainer>) -> std::result::Result<Self, Self::Error> {
|
fn try_from(
|
||||||
|
hdr_value: header::IntoHeaderValue<ANullableContainer>,
|
||||||
|
) -> std::result::Result<Self, Self::Error> {
|
||||||
let hdr_value = hdr_value.to_string();
|
let hdr_value = hdr_value.to_string();
|
||||||
match HeaderValue::from_str(&hdr_value) {
|
match HeaderValue::from_str(&hdr_value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
format!("Invalid header value for ANullableContainer - value: {} is invalid {}",
|
"Invalid header value for ANullableContainer - value: {} is invalid {}",
|
||||||
hdr_value, e))
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,22 +141,23 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<ANullableCon
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
std::result::Result::Ok(value) => {
|
std::result::Result::Ok(value) => {
|
||||||
match <ANullableContainer as std::str::FromStr>::from_str(value) {
|
match <ANullableContainer as std::str::FromStr>::from_str(value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
std::result::Result::Ok(value) => {
|
||||||
std::result::Result::Err(err) => std::result::Result::Err(
|
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||||
format!("Unable to convert header value '{}' into ANullableContainer - {}",
|
|
||||||
value, err))
|
|
||||||
}
|
}
|
||||||
},
|
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
"Unable to convert header value '{}' into ANullableContainer - {}",
|
||||||
format!("Unable to convert header: {:?} to string: {}",
|
value, err
|
||||||
hdr_value, e))
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
|
"Unable to convert header: {:?} to string: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// An additionalPropertiesObject
|
/// An additionalPropertiesObject
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
@ -212,14 +211,12 @@ impl ::std::str::FromStr for AdditionalPropertiesObject {
|
|||||||
type Err = &'static str;
|
type Err = &'static str;
|
||||||
|
|
||||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||||
std::result::Result::Err("Parsing additionalProperties for AdditionalPropertiesObject is not supported")
|
std::result::Result::Err(
|
||||||
|
"Parsing additionalProperties for AdditionalPropertiesObject is not supported",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct AllOfObject {
|
pub struct AllOfObject {
|
||||||
@ -230,10 +227,8 @@ pub struct AllOfObject {
|
|||||||
#[serde(rename = "sampleBaseProperty")]
|
#[serde(rename = "sampleBaseProperty")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub sample_base_property: Option<String>,
|
pub sample_base_property: Option<String>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl AllOfObject {
|
impl AllOfObject {
|
||||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||||
pub fn new() -> AllOfObject {
|
pub fn new() -> AllOfObject {
|
||||||
@ -250,22 +245,18 @@ impl AllOfObject {
|
|||||||
impl std::string::ToString for AllOfObject {
|
impl std::string::ToString for AllOfObject {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
let params: Vec<Option<String>> = vec![
|
let params: Vec<Option<String>> = vec![
|
||||||
|
|
||||||
self.sample_property.as_ref().map(|sample_property| {
|
self.sample_property.as_ref().map(|sample_property| {
|
||||||
[
|
["sampleProperty".to_string(), sample_property.to_string()].join(",")
|
||||||
"sampleProperty".to_string(),
|
|
||||||
sample_property.to_string(),
|
|
||||||
].join(",")
|
|
||||||
}),
|
}),
|
||||||
|
self.sample_base_property
|
||||||
|
.as_ref()
|
||||||
self.sample_base_property.as_ref().map(|sample_base_property| {
|
.map(|sample_base_property| {
|
||||||
[
|
[
|
||||||
"sampleBaseProperty".to_string(),
|
"sampleBaseProperty".to_string(),
|
||||||
sample_base_property.to_string(),
|
sample_base_property.to_string(),
|
||||||
].join(",")
|
]
|
||||||
|
.join(",")
|
||||||
}),
|
}),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||||
@ -296,17 +287,29 @@ impl std::str::FromStr for AllOfObject {
|
|||||||
while key_result.is_some() {
|
while key_result.is_some() {
|
||||||
let val = match string_iter.next() {
|
let val = match string_iter.next() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => return std::result::Result::Err("Missing value while parsing AllOfObject".to_string())
|
None => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Missing value while parsing AllOfObject".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(key) = key_result {
|
if let Some(key) = key_result {
|
||||||
#[allow(clippy::match_single_binding)]
|
#[allow(clippy::match_single_binding)]
|
||||||
match key {
|
match key {
|
||||||
#[allow(clippy::redundant_clone)]
|
#[allow(clippy::redundant_clone)]
|
||||||
"sampleProperty" => intermediate_rep.sample_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
"sampleProperty" => intermediate_rep.sample_property.push(
|
||||||
|
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
|
||||||
|
),
|
||||||
#[allow(clippy::redundant_clone)]
|
#[allow(clippy::redundant_clone)]
|
||||||
"sampleBaseProperty" => intermediate_rep.sample_base_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
"sampleBaseProperty" => intermediate_rep.sample_base_property.push(
|
||||||
_ => return std::result::Result::Err("Unexpected key while parsing AllOfObject".to_string())
|
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
|
||||||
|
),
|
||||||
|
_ => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Unexpected key while parsing AllOfObject".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,13 +331,16 @@ impl std::str::FromStr for AllOfObject {
|
|||||||
impl std::convert::TryFrom<header::IntoHeaderValue<AllOfObject>> for HeaderValue {
|
impl std::convert::TryFrom<header::IntoHeaderValue<AllOfObject>> for HeaderValue {
|
||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
fn try_from(hdr_value: header::IntoHeaderValue<AllOfObject>) -> std::result::Result<Self, Self::Error> {
|
fn try_from(
|
||||||
|
hdr_value: header::IntoHeaderValue<AllOfObject>,
|
||||||
|
) -> std::result::Result<Self, Self::Error> {
|
||||||
let hdr_value = hdr_value.to_string();
|
let hdr_value = hdr_value.to_string();
|
||||||
match HeaderValue::from_str(&hdr_value) {
|
match HeaderValue::from_str(&hdr_value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
format!("Invalid header value for AllOfObject - value: {} is invalid {}",
|
"Invalid header value for AllOfObject - value: {} is invalid {}",
|
||||||
hdr_value, e))
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -347,35 +353,31 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<AllOfObject>
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
std::result::Result::Ok(value) => {
|
std::result::Result::Ok(value) => {
|
||||||
match <AllOfObject as std::str::FromStr>::from_str(value) {
|
match <AllOfObject as std::str::FromStr>::from_str(value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
std::result::Result::Ok(value) => {
|
||||||
std::result::Result::Err(err) => std::result::Result::Err(
|
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||||
format!("Unable to convert header value '{}' into AllOfObject - {}",
|
|
||||||
value, err))
|
|
||||||
}
|
}
|
||||||
},
|
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
"Unable to convert header value '{}' into AllOfObject - {}",
|
||||||
format!("Unable to convert header: {:?} to string: {}",
|
value, err
|
||||||
hdr_value, e))
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
|
"Unable to convert header: {:?} to string: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct BaseAllOf {
|
pub struct BaseAllOf {
|
||||||
#[serde(rename = "sampleBaseProperty")]
|
#[serde(rename = "sampleBaseProperty")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub sample_base_property: Option<String>,
|
pub sample_base_property: Option<String>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl BaseAllOf {
|
impl BaseAllOf {
|
||||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||||
pub fn new() -> BaseAllOf {
|
pub fn new() -> BaseAllOf {
|
||||||
@ -390,16 +392,17 @@ impl BaseAllOf {
|
|||||||
/// Should be implemented in a serde serializer
|
/// Should be implemented in a serde serializer
|
||||||
impl std::string::ToString for BaseAllOf {
|
impl std::string::ToString for BaseAllOf {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
let params: Vec<Option<String>> = vec![
|
let params: Vec<Option<String>> =
|
||||||
|
vec![self
|
||||||
self.sample_base_property.as_ref().map(|sample_base_property| {
|
.sample_base_property
|
||||||
|
.as_ref()
|
||||||
|
.map(|sample_base_property| {
|
||||||
[
|
[
|
||||||
"sampleBaseProperty".to_string(),
|
"sampleBaseProperty".to_string(),
|
||||||
sample_base_property.to_string(),
|
sample_base_property.to_string(),
|
||||||
].join(",")
|
]
|
||||||
}),
|
.join(",")
|
||||||
|
})];
|
||||||
];
|
|
||||||
|
|
||||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||||
}
|
}
|
||||||
@ -428,15 +431,25 @@ impl std::str::FromStr for BaseAllOf {
|
|||||||
while key_result.is_some() {
|
while key_result.is_some() {
|
||||||
let val = match string_iter.next() {
|
let val = match string_iter.next() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => return std::result::Result::Err("Missing value while parsing BaseAllOf".to_string())
|
None => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Missing value while parsing BaseAllOf".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(key) = key_result {
|
if let Some(key) = key_result {
|
||||||
#[allow(clippy::match_single_binding)]
|
#[allow(clippy::match_single_binding)]
|
||||||
match key {
|
match key {
|
||||||
#[allow(clippy::redundant_clone)]
|
#[allow(clippy::redundant_clone)]
|
||||||
"sampleBaseProperty" => intermediate_rep.sample_base_property.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
"sampleBaseProperty" => intermediate_rep.sample_base_property.push(
|
||||||
_ => return std::result::Result::Err("Unexpected key while parsing BaseAllOf".to_string())
|
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
|
||||||
|
),
|
||||||
|
_ => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Unexpected key while parsing BaseAllOf".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,13 +470,16 @@ impl std::str::FromStr for BaseAllOf {
|
|||||||
impl std::convert::TryFrom<header::IntoHeaderValue<BaseAllOf>> for HeaderValue {
|
impl std::convert::TryFrom<header::IntoHeaderValue<BaseAllOf>> for HeaderValue {
|
||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
fn try_from(hdr_value: header::IntoHeaderValue<BaseAllOf>) -> std::result::Result<Self, Self::Error> {
|
fn try_from(
|
||||||
|
hdr_value: header::IntoHeaderValue<BaseAllOf>,
|
||||||
|
) -> std::result::Result<Self, Self::Error> {
|
||||||
let hdr_value = hdr_value.to_string();
|
let hdr_value = hdr_value.to_string();
|
||||||
match HeaderValue::from_str(&hdr_value) {
|
match HeaderValue::from_str(&hdr_value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
format!("Invalid header value for BaseAllOf - value: {} is invalid {}",
|
"Invalid header value for BaseAllOf - value: {} is invalid {}",
|
||||||
hdr_value, e))
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -476,25 +492,23 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<BaseAllOf> {
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
std::result::Result::Ok(value) => {
|
std::result::Result::Ok(value) => {
|
||||||
match <BaseAllOf as std::str::FromStr>::from_str(value) {
|
match <BaseAllOf as std::str::FromStr>::from_str(value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
std::result::Result::Ok(value) => {
|
||||||
std::result::Result::Err(err) => std::result::Result::Err(
|
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||||
format!("Unable to convert header value '{}' into BaseAllOf - {}",
|
|
||||||
value, err))
|
|
||||||
}
|
}
|
||||||
},
|
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
"Unable to convert header value '{}' into BaseAllOf - {}",
|
||||||
format!("Unable to convert header: {:?} to string: {}",
|
value, err
|
||||||
hdr_value, e))
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
|
"Unable to convert header: {:?} to string: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct DummyPutRequest {
|
pub struct DummyPutRequest {
|
||||||
@ -504,17 +518,12 @@ pub struct DummyPutRequest {
|
|||||||
#[serde(rename = "password")]
|
#[serde(rename = "password")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub password: Option<String>,
|
pub password: Option<String>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl DummyPutRequest {
|
impl DummyPutRequest {
|
||||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||||
pub fn new(id: String, ) -> DummyPutRequest {
|
pub fn new(id: String) -> DummyPutRequest {
|
||||||
DummyPutRequest {
|
DummyPutRequest { id, password: None }
|
||||||
id,
|
|
||||||
password: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,18 +533,11 @@ impl DummyPutRequest {
|
|||||||
impl std::string::ToString for DummyPutRequest {
|
impl std::string::ToString for DummyPutRequest {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
let params: Vec<Option<String>> = vec![
|
let params: Vec<Option<String>> = vec![
|
||||||
|
|
||||||
Some("id".to_string()),
|
Some("id".to_string()),
|
||||||
Some(self.id.to_string()),
|
Some(self.id.to_string()),
|
||||||
|
self.password
|
||||||
|
.as_ref()
|
||||||
self.password.as_ref().map(|password| {
|
.map(|password| ["password".to_string(), password.to_string()].join(",")),
|
||||||
[
|
|
||||||
"password".to_string(),
|
|
||||||
password.to_string(),
|
|
||||||
].join(",")
|
|
||||||
}),
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||||
@ -566,17 +568,29 @@ impl std::str::FromStr for DummyPutRequest {
|
|||||||
while key_result.is_some() {
|
while key_result.is_some() {
|
||||||
let val = match string_iter.next() {
|
let val = match string_iter.next() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => return std::result::Result::Err("Missing value while parsing DummyPutRequest".to_string())
|
None => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Missing value while parsing DummyPutRequest".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(key) = key_result {
|
if let Some(key) = key_result {
|
||||||
#[allow(clippy::match_single_binding)]
|
#[allow(clippy::match_single_binding)]
|
||||||
match key {
|
match key {
|
||||||
#[allow(clippy::redundant_clone)]
|
#[allow(clippy::redundant_clone)]
|
||||||
"id" => intermediate_rep.id.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
"id" => intermediate_rep.id.push(
|
||||||
|
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
|
||||||
|
),
|
||||||
#[allow(clippy::redundant_clone)]
|
#[allow(clippy::redundant_clone)]
|
||||||
"password" => intermediate_rep.password.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
"password" => intermediate_rep.password.push(
|
||||||
_ => return std::result::Result::Err("Unexpected key while parsing DummyPutRequest".to_string())
|
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
|
||||||
|
),
|
||||||
|
_ => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Unexpected key while parsing DummyPutRequest".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,7 +600,11 @@ impl std::str::FromStr for DummyPutRequest {
|
|||||||
|
|
||||||
// Use the intermediate representation to return the struct
|
// Use the intermediate representation to return the struct
|
||||||
std::result::Result::Ok(DummyPutRequest {
|
std::result::Result::Ok(DummyPutRequest {
|
||||||
id: intermediate_rep.id.into_iter().next().ok_or_else(|| "id missing in DummyPutRequest".to_string())?,
|
id: intermediate_rep
|
||||||
|
.id
|
||||||
|
.into_iter()
|
||||||
|
.next()
|
||||||
|
.ok_or_else(|| "id missing in DummyPutRequest".to_string())?,
|
||||||
password: intermediate_rep.password.into_iter().next(),
|
password: intermediate_rep.password.into_iter().next(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -598,13 +616,16 @@ impl std::str::FromStr for DummyPutRequest {
|
|||||||
impl std::convert::TryFrom<header::IntoHeaderValue<DummyPutRequest>> for HeaderValue {
|
impl std::convert::TryFrom<header::IntoHeaderValue<DummyPutRequest>> for HeaderValue {
|
||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
fn try_from(hdr_value: header::IntoHeaderValue<DummyPutRequest>) -> std::result::Result<Self, Self::Error> {
|
fn try_from(
|
||||||
|
hdr_value: header::IntoHeaderValue<DummyPutRequest>,
|
||||||
|
) -> std::result::Result<Self, Self::Error> {
|
||||||
let hdr_value = hdr_value.to_string();
|
let hdr_value = hdr_value.to_string();
|
||||||
match HeaderValue::from_str(&hdr_value) {
|
match HeaderValue::from_str(&hdr_value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
format!("Invalid header value for DummyPutRequest - value: {} is invalid {}",
|
"Invalid header value for DummyPutRequest - value: {} is invalid {}",
|
||||||
hdr_value, e))
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -617,26 +638,25 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<DummyPutRequ
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
std::result::Result::Ok(value) => {
|
std::result::Result::Ok(value) => {
|
||||||
match <DummyPutRequest as std::str::FromStr>::from_str(value) {
|
match <DummyPutRequest as std::str::FromStr>::from_str(value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
std::result::Result::Ok(value) => {
|
||||||
std::result::Result::Err(err) => std::result::Result::Err(
|
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||||
format!("Unable to convert header value '{}' into DummyPutRequest - {}",
|
|
||||||
value, err))
|
|
||||||
}
|
}
|
||||||
},
|
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
"Unable to convert header value '{}' into DummyPutRequest - {}",
|
||||||
format!("Unable to convert header: {:?} to string: {}",
|
value, err
|
||||||
hdr_value, e))
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
|
"Unable to convert header: {:?} to string: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// structured response
|
/// structured response
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct GetYamlResponse {
|
pub struct GetYamlResponse {
|
||||||
@ -644,16 +664,12 @@ pub struct GetYamlResponse {
|
|||||||
#[serde(rename = "value")]
|
#[serde(rename = "value")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub value: Option<String>,
|
pub value: Option<String>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl GetYamlResponse {
|
impl GetYamlResponse {
|
||||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||||
pub fn new() -> GetYamlResponse {
|
pub fn new() -> GetYamlResponse {
|
||||||
GetYamlResponse {
|
GetYamlResponse { value: None }
|
||||||
value: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,16 +678,10 @@ impl GetYamlResponse {
|
|||||||
/// Should be implemented in a serde serializer
|
/// Should be implemented in a serde serializer
|
||||||
impl std::string::ToString for GetYamlResponse {
|
impl std::string::ToString for GetYamlResponse {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
let params: Vec<Option<String>> = vec![
|
let params: Vec<Option<String>> = vec![self
|
||||||
|
.value
|
||||||
self.value.as_ref().map(|value| {
|
.as_ref()
|
||||||
[
|
.map(|value| ["value".to_string(), value.to_string()].join(","))];
|
||||||
"value".to_string(),
|
|
||||||
value.to_string(),
|
|
||||||
].join(",")
|
|
||||||
}),
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||||
}
|
}
|
||||||
@ -700,15 +710,25 @@ impl std::str::FromStr for GetYamlResponse {
|
|||||||
while key_result.is_some() {
|
while key_result.is_some() {
|
||||||
let val = match string_iter.next() {
|
let val = match string_iter.next() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => return std::result::Result::Err("Missing value while parsing GetYamlResponse".to_string())
|
None => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Missing value while parsing GetYamlResponse".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(key) = key_result {
|
if let Some(key) = key_result {
|
||||||
#[allow(clippy::match_single_binding)]
|
#[allow(clippy::match_single_binding)]
|
||||||
match key {
|
match key {
|
||||||
#[allow(clippy::redundant_clone)]
|
#[allow(clippy::redundant_clone)]
|
||||||
"value" => intermediate_rep.value.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
"value" => intermediate_rep.value.push(
|
||||||
_ => return std::result::Result::Err("Unexpected key while parsing GetYamlResponse".to_string())
|
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
|
||||||
|
),
|
||||||
|
_ => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Unexpected key while parsing GetYamlResponse".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,13 +749,16 @@ impl std::str::FromStr for GetYamlResponse {
|
|||||||
impl std::convert::TryFrom<header::IntoHeaderValue<GetYamlResponse>> for HeaderValue {
|
impl std::convert::TryFrom<header::IntoHeaderValue<GetYamlResponse>> for HeaderValue {
|
||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
fn try_from(hdr_value: header::IntoHeaderValue<GetYamlResponse>) -> std::result::Result<Self, Self::Error> {
|
fn try_from(
|
||||||
|
hdr_value: header::IntoHeaderValue<GetYamlResponse>,
|
||||||
|
) -> std::result::Result<Self, Self::Error> {
|
||||||
let hdr_value = hdr_value.to_string();
|
let hdr_value = hdr_value.to_string();
|
||||||
match HeaderValue::from_str(&hdr_value) {
|
match HeaderValue::from_str(&hdr_value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
format!("Invalid header value for GetYamlResponse - value: {} is invalid {}",
|
"Invalid header value for GetYamlResponse - value: {} is invalid {}",
|
||||||
hdr_value, e))
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -748,42 +771,37 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<GetYamlRespo
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
std::result::Result::Ok(value) => {
|
std::result::Result::Ok(value) => {
|
||||||
match <GetYamlResponse as std::str::FromStr>::from_str(value) {
|
match <GetYamlResponse as std::str::FromStr>::from_str(value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
std::result::Result::Ok(value) => {
|
||||||
std::result::Result::Err(err) => std::result::Result::Err(
|
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||||
format!("Unable to convert header value '{}' into GetYamlResponse - {}",
|
|
||||||
value, err))
|
|
||||||
}
|
}
|
||||||
},
|
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
"Unable to convert header value '{}' into GetYamlResponse - {}",
|
||||||
format!("Unable to convert header: {:?} to string: {}",
|
value, err
|
||||||
hdr_value, e))
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
|
"Unable to convert header: {:?} to string: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// An object of objects
|
/// An object of objects
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct ObjectOfObjects {
|
pub struct ObjectOfObjects {
|
||||||
#[serde(rename = "inner")]
|
#[serde(rename = "inner")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub inner: Option<models::ObjectOfObjectsInner>,
|
pub inner: Option<models::ObjectOfObjectsInner>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl ObjectOfObjects {
|
impl ObjectOfObjects {
|
||||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||||
pub fn new() -> ObjectOfObjects {
|
pub fn new() -> ObjectOfObjects {
|
||||||
ObjectOfObjects {
|
ObjectOfObjects { inner: None }
|
||||||
inner: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -824,15 +842,26 @@ impl std::str::FromStr for ObjectOfObjects {
|
|||||||
while key_result.is_some() {
|
while key_result.is_some() {
|
||||||
let val = match string_iter.next() {
|
let val = match string_iter.next() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => return std::result::Result::Err("Missing value while parsing ObjectOfObjects".to_string())
|
None => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Missing value while parsing ObjectOfObjects".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(key) = key_result {
|
if let Some(key) = key_result {
|
||||||
#[allow(clippy::match_single_binding)]
|
#[allow(clippy::match_single_binding)]
|
||||||
match key {
|
match key {
|
||||||
#[allow(clippy::redundant_clone)]
|
#[allow(clippy::redundant_clone)]
|
||||||
"inner" => intermediate_rep.inner.push(<models::ObjectOfObjectsInner as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
"inner" => intermediate_rep.inner.push(
|
||||||
_ => return std::result::Result::Err("Unexpected key while parsing ObjectOfObjects".to_string())
|
<models::ObjectOfObjectsInner as std::str::FromStr>::from_str(val)
|
||||||
|
.map_err(|x| x.to_string())?,
|
||||||
|
),
|
||||||
|
_ => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Unexpected key while parsing ObjectOfObjects".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,13 +882,16 @@ impl std::str::FromStr for ObjectOfObjects {
|
|||||||
impl std::convert::TryFrom<header::IntoHeaderValue<ObjectOfObjects>> for HeaderValue {
|
impl std::convert::TryFrom<header::IntoHeaderValue<ObjectOfObjects>> for HeaderValue {
|
||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
fn try_from(hdr_value: header::IntoHeaderValue<ObjectOfObjects>) -> std::result::Result<Self, Self::Error> {
|
fn try_from(
|
||||||
|
hdr_value: header::IntoHeaderValue<ObjectOfObjects>,
|
||||||
|
) -> std::result::Result<Self, Self::Error> {
|
||||||
let hdr_value = hdr_value.to_string();
|
let hdr_value = hdr_value.to_string();
|
||||||
match HeaderValue::from_str(&hdr_value) {
|
match HeaderValue::from_str(&hdr_value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
format!("Invalid header value for ObjectOfObjects - value: {} is invalid {}",
|
"Invalid header value for ObjectOfObjects - value: {} is invalid {}",
|
||||||
hdr_value, e))
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -872,25 +904,23 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<ObjectOfObje
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
std::result::Result::Ok(value) => {
|
std::result::Result::Ok(value) => {
|
||||||
match <ObjectOfObjects as std::str::FromStr>::from_str(value) {
|
match <ObjectOfObjects as std::str::FromStr>::from_str(value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
std::result::Result::Ok(value) => {
|
||||||
std::result::Result::Err(err) => std::result::Result::Err(
|
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||||
format!("Unable to convert header value '{}' into ObjectOfObjects - {}",
|
|
||||||
value, err))
|
|
||||||
}
|
}
|
||||||
},
|
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
"Unable to convert header value '{}' into ObjectOfObjects - {}",
|
||||||
format!("Unable to convert header: {:?} to string: {}",
|
value, err
|
||||||
hdr_value, e))
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
|
"Unable to convert header: {:?} to string: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)]
|
||||||
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
|
||||||
pub struct ObjectOfObjectsInner {
|
pub struct ObjectOfObjectsInner {
|
||||||
@ -900,13 +930,11 @@ pub struct ObjectOfObjectsInner {
|
|||||||
#[serde(rename = "optional_thing")]
|
#[serde(rename = "optional_thing")]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub optional_thing: Option<i32>,
|
pub optional_thing: Option<i32>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl ObjectOfObjectsInner {
|
impl ObjectOfObjectsInner {
|
||||||
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
#[allow(clippy::new_without_default, clippy::too_many_arguments)]
|
||||||
pub fn new(required_thing: String, ) -> ObjectOfObjectsInner {
|
pub fn new(required_thing: String) -> ObjectOfObjectsInner {
|
||||||
ObjectOfObjectsInner {
|
ObjectOfObjectsInner {
|
||||||
required_thing,
|
required_thing,
|
||||||
optional_thing: None,
|
optional_thing: None,
|
||||||
@ -920,18 +948,11 @@ impl ObjectOfObjectsInner {
|
|||||||
impl std::string::ToString for ObjectOfObjectsInner {
|
impl std::string::ToString for ObjectOfObjectsInner {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
let params: Vec<Option<String>> = vec![
|
let params: Vec<Option<String>> = vec![
|
||||||
|
|
||||||
Some("required_thing".to_string()),
|
Some("required_thing".to_string()),
|
||||||
Some(self.required_thing.to_string()),
|
Some(self.required_thing.to_string()),
|
||||||
|
|
||||||
|
|
||||||
self.optional_thing.as_ref().map(|optional_thing| {
|
self.optional_thing.as_ref().map(|optional_thing| {
|
||||||
[
|
["optional_thing".to_string(), optional_thing.to_string()].join(",")
|
||||||
"optional_thing".to_string(),
|
|
||||||
optional_thing.to_string(),
|
|
||||||
].join(",")
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
params.into_iter().flatten().collect::<Vec<_>>().join(",")
|
||||||
@ -962,17 +983,29 @@ impl std::str::FromStr for ObjectOfObjectsInner {
|
|||||||
while key_result.is_some() {
|
while key_result.is_some() {
|
||||||
let val = match string_iter.next() {
|
let val = match string_iter.next() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => return std::result::Result::Err("Missing value while parsing ObjectOfObjectsInner".to_string())
|
None => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Missing value while parsing ObjectOfObjectsInner".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(key) = key_result {
|
if let Some(key) = key_result {
|
||||||
#[allow(clippy::match_single_binding)]
|
#[allow(clippy::match_single_binding)]
|
||||||
match key {
|
match key {
|
||||||
#[allow(clippy::redundant_clone)]
|
#[allow(clippy::redundant_clone)]
|
||||||
"required_thing" => intermediate_rep.required_thing.push(<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
"required_thing" => intermediate_rep.required_thing.push(
|
||||||
|
<String as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
|
||||||
|
),
|
||||||
#[allow(clippy::redundant_clone)]
|
#[allow(clippy::redundant_clone)]
|
||||||
"optional_thing" => intermediate_rep.optional_thing.push(<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?),
|
"optional_thing" => intermediate_rep.optional_thing.push(
|
||||||
_ => return std::result::Result::Err("Unexpected key while parsing ObjectOfObjectsInner".to_string())
|
<i32 as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?,
|
||||||
|
),
|
||||||
|
_ => {
|
||||||
|
return std::result::Result::Err(
|
||||||
|
"Unexpected key while parsing ObjectOfObjectsInner".to_string(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -982,7 +1015,11 @@ impl std::str::FromStr for ObjectOfObjectsInner {
|
|||||||
|
|
||||||
// Use the intermediate representation to return the struct
|
// Use the intermediate representation to return the struct
|
||||||
std::result::Result::Ok(ObjectOfObjectsInner {
|
std::result::Result::Ok(ObjectOfObjectsInner {
|
||||||
required_thing: intermediate_rep.required_thing.into_iter().next().ok_or_else(|| "required_thing missing in ObjectOfObjectsInner".to_string())?,
|
required_thing: intermediate_rep
|
||||||
|
.required_thing
|
||||||
|
.into_iter()
|
||||||
|
.next()
|
||||||
|
.ok_or_else(|| "required_thing missing in ObjectOfObjectsInner".to_string())?,
|
||||||
optional_thing: intermediate_rep.optional_thing.into_iter().next(),
|
optional_thing: intermediate_rep.optional_thing.into_iter().next(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -994,13 +1031,16 @@ impl std::str::FromStr for ObjectOfObjectsInner {
|
|||||||
impl std::convert::TryFrom<header::IntoHeaderValue<ObjectOfObjectsInner>> for HeaderValue {
|
impl std::convert::TryFrom<header::IntoHeaderValue<ObjectOfObjectsInner>> for HeaderValue {
|
||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
fn try_from(hdr_value: header::IntoHeaderValue<ObjectOfObjectsInner>) -> std::result::Result<Self, Self::Error> {
|
fn try_from(
|
||||||
|
hdr_value: header::IntoHeaderValue<ObjectOfObjectsInner>,
|
||||||
|
) -> std::result::Result<Self, Self::Error> {
|
||||||
let hdr_value = hdr_value.to_string();
|
let hdr_value = hdr_value.to_string();
|
||||||
match HeaderValue::from_str(&hdr_value) {
|
match HeaderValue::from_str(&hdr_value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
std::result::Result::Ok(value) => std::result::Result::Ok(value),
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
format!("Invalid header value for ObjectOfObjectsInner - value: {} is invalid {}",
|
"Invalid header value for ObjectOfObjectsInner - value: {} is invalid {}",
|
||||||
hdr_value, e))
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1013,18 +1053,19 @@ impl std::convert::TryFrom<HeaderValue> for header::IntoHeaderValue<ObjectOfObje
|
|||||||
match hdr_value.to_str() {
|
match hdr_value.to_str() {
|
||||||
std::result::Result::Ok(value) => {
|
std::result::Result::Ok(value) => {
|
||||||
match <ObjectOfObjectsInner as std::str::FromStr>::from_str(value) {
|
match <ObjectOfObjectsInner as std::str::FromStr>::from_str(value) {
|
||||||
std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
|
std::result::Result::Ok(value) => {
|
||||||
std::result::Result::Err(err) => std::result::Result::Err(
|
std::result::Result::Ok(header::IntoHeaderValue(value))
|
||||||
format!("Unable to convert header value '{}' into ObjectOfObjectsInner - {}",
|
|
||||||
value, err))
|
|
||||||
}
|
}
|
||||||
},
|
std::result::Result::Err(err) => std::result::Result::Err(format!(
|
||||||
std::result::Result::Err(e) => std::result::Result::Err(
|
"Unable to convert header value '{}' into ObjectOfObjectsInner - {}",
|
||||||
format!("Unable to convert header: {:?} to string: {}",
|
value, err
|
||||||
hdr_value, e))
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::result::Result::Err(e) => std::result::Result::Err(format!(
|
||||||
|
"Unable to convert header: {:?} to string: {}",
|
||||||
|
hdr_value, e
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,16 +12,10 @@ use crate::{header, types::*};
|
|||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::models;
|
use crate::models;
|
||||||
|
|
||||||
use crate::{Api,
|
use crate::{
|
||||||
AllOfGetResponse,
|
AllOfGetResponse, Api, DummyGetResponse, DummyPutResponse, FileResponseGetResponse,
|
||||||
DummyGetResponse,
|
GetStructuredYamlResponse, HtmlPostResponse, PostYamlResponse, RawJsonGetResponse,
|
||||||
DummyPutResponse,
|
SoloObjectPostResponse,
|
||||||
FileResponseGetResponse,
|
|
||||||
GetStructuredYamlResponse,
|
|
||||||
HtmlPostResponse,
|
|
||||||
PostYamlResponse,
|
|
||||||
RawJsonGetResponse,
|
|
||||||
SoloObjectPostResponse
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Setup API Server.
|
/// Setup API Server.
|
||||||
@ -32,42 +26,20 @@ where
|
|||||||
{
|
{
|
||||||
// build our application with a route
|
// build our application with a route
|
||||||
Router::new()
|
Router::new()
|
||||||
.route("/allOf",
|
.route("/allOf", get(all_of_get::<I, A>))
|
||||||
get(all_of_get::<I, A>)
|
.route("/dummy", get(dummy_get::<I, A>).put(dummy_put::<I, A>))
|
||||||
)
|
.route("/file_response", get(file_response_get::<I, A>))
|
||||||
.route("/dummy",
|
.route("/get-structured-yaml", get(get_structured_yaml::<I, A>))
|
||||||
get(dummy_get::<I, A>).put(dummy_put::<I, A>)
|
.route("/html", post(html_post::<I, A>))
|
||||||
)
|
.route("/post-yaml", post(post_yaml::<I, A>))
|
||||||
.route("/file_response",
|
.route("/raw_json", get(raw_json_get::<I, A>))
|
||||||
get(file_response_get::<I, A>)
|
.route("/solo-object", post(solo_object_post::<I, A>))
|
||||||
)
|
|
||||||
.route("/get-structured-yaml",
|
|
||||||
get(get_structured_yaml::<I, A>)
|
|
||||||
)
|
|
||||||
.route("/html",
|
|
||||||
post(html_post::<I, A>)
|
|
||||||
)
|
|
||||||
.route("/post-yaml",
|
|
||||||
post(post_yaml::<I, A>)
|
|
||||||
)
|
|
||||||
.route("/raw_json",
|
|
||||||
get(raw_json_get::<I, A>)
|
|
||||||
)
|
|
||||||
.route("/solo-object",
|
|
||||||
post(solo_object_post::<I, A>)
|
|
||||||
)
|
|
||||||
.with_state(api_impl)
|
.with_state(api_impl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn all_of_get_validation(
|
fn all_of_get_validation() -> std::result::Result<(), ValidationErrors> {
|
||||||
) -> std::result::Result<(
|
Ok(())
|
||||||
), ValidationErrors>
|
|
||||||
{
|
|
||||||
|
|
||||||
Ok((
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// AllOfGet - GET /allOf
|
/// AllOfGet - GET /allOf
|
||||||
@ -82,70 +54,64 @@ where
|
|||||||
I: AsRef<A> + Send + Sync,
|
I: AsRef<A> + Send + Sync,
|
||||||
A: Api,
|
A: Api,
|
||||||
{
|
{
|
||||||
|
|
||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
let validation = tokio::task::spawn_blocking(move ||
|
let validation = tokio::task::spawn_blocking(move || all_of_get_validation())
|
||||||
all_of_get_validation(
|
.await
|
||||||
)
|
.unwrap();
|
||||||
).await.unwrap();
|
|
||||||
|
|
||||||
let Ok((
|
let Ok(()) = validation else {
|
||||||
)) = validation else {
|
|
||||||
return Response::builder()
|
return Response::builder()
|
||||||
.status(StatusCode::BAD_REQUEST)
|
.status(StatusCode::BAD_REQUEST)
|
||||||
.body(Body::from(validation.unwrap_err().to_string()))
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = api_impl.as_ref().all_of_get(
|
let result = api_impl.as_ref().all_of_get(method, host, cookies).await;
|
||||||
method,
|
|
||||||
host,
|
|
||||||
cookies,
|
|
||||||
).await;
|
|
||||||
|
|
||||||
let mut response = Response::builder();
|
let mut response = Response::builder();
|
||||||
|
|
||||||
let resp = match result {
|
let resp = match result {
|
||||||
Ok(rsp) => match rsp {
|
Ok(rsp) => match rsp {
|
||||||
AllOfGetResponse::Status200_OK
|
AllOfGetResponse::Status200_OK(body) => {
|
||||||
(body)
|
|
||||||
=> {
|
|
||||||
|
|
||||||
let mut response = response.status(200);
|
let mut response = response.status(200);
|
||||||
{
|
{
|
||||||
let mut response_headers = response.headers_mut().unwrap();
|
let mut response_headers = response.headers_mut().unwrap();
|
||||||
response_headers.insert(
|
response_headers.insert(
|
||||||
CONTENT_TYPE,
|
CONTENT_TYPE,
|
||||||
HeaderValue::from_str("*/*").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?);
|
HeaderValue::from_str("*/*").map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})?,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let body_content = tokio::task::spawn_blocking(move ||
|
let body_content = tokio::task::spawn_blocking(move || {
|
||||||
serde_json::to_vec(&body).map_err(|e| {
|
serde_json::to_vec(&body).map_err(|e| {
|
||||||
error!(error = ?e);
|
error!(error = ?e);
|
||||||
StatusCode::INTERNAL_SERVER_ERROR
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
})).await.unwrap()?;
|
})
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap()?;
|
||||||
response.body(Body::from(body_content))
|
response.body(Body::from(body_content))
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Application code returned an error. This should not happen, as the implementation should
|
// Application code returned an error. This should not happen, as the implementation should
|
||||||
// return a valid response.
|
// return a valid response.
|
||||||
response.status(500).body(Body::empty())
|
response.status(500).body(Body::empty())
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
resp.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn dummy_get_validation(
|
fn dummy_get_validation() -> std::result::Result<(), ValidationErrors> {
|
||||||
) -> std::result::Result<(
|
Ok(())
|
||||||
), ValidationErrors>
|
|
||||||
{
|
|
||||||
|
|
||||||
Ok((
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// DummyGet - GET /dummy
|
/// DummyGet - GET /dummy
|
||||||
@ -160,46 +126,40 @@ where
|
|||||||
I: AsRef<A> + Send + Sync,
|
I: AsRef<A> + Send + Sync,
|
||||||
A: Api,
|
A: Api,
|
||||||
{
|
{
|
||||||
|
|
||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
let validation = tokio::task::spawn_blocking(move ||
|
let validation = tokio::task::spawn_blocking(move || dummy_get_validation())
|
||||||
dummy_get_validation(
|
.await
|
||||||
)
|
.unwrap();
|
||||||
).await.unwrap();
|
|
||||||
|
|
||||||
let Ok((
|
let Ok(()) = validation else {
|
||||||
)) = validation else {
|
|
||||||
return Response::builder()
|
return Response::builder()
|
||||||
.status(StatusCode::BAD_REQUEST)
|
.status(StatusCode::BAD_REQUEST)
|
||||||
.body(Body::from(validation.unwrap_err().to_string()))
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = api_impl.as_ref().dummy_get(
|
let result = api_impl.as_ref().dummy_get(method, host, cookies).await;
|
||||||
method,
|
|
||||||
host,
|
|
||||||
cookies,
|
|
||||||
).await;
|
|
||||||
|
|
||||||
let mut response = Response::builder();
|
let mut response = Response::builder();
|
||||||
|
|
||||||
let resp = match result {
|
let resp = match result {
|
||||||
Ok(rsp) => match rsp {
|
Ok(rsp) => match rsp {
|
||||||
DummyGetResponse::Status200_Success
|
DummyGetResponse::Status200_Success => {
|
||||||
=> {
|
|
||||||
|
|
||||||
let mut response = response.status(200);
|
let mut response = response.status(200);
|
||||||
response.body(Body::empty())
|
response.body(Body::empty())
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Application code returned an error. This should not happen, as the implementation should
|
// Application code returned an error. This should not happen, as the implementation should
|
||||||
// return a valid response.
|
// return a valid response.
|
||||||
response.status(500).body(Body::empty())
|
response.status(500).body(Body::empty())
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
resp.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(validator::Validate)]
|
#[derive(validator::Validate)]
|
||||||
@ -209,20 +169,14 @@ where
|
|||||||
body: &'a models::DummyPutRequest,
|
body: &'a models::DummyPutRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn dummy_put_validation(
|
fn dummy_put_validation(
|
||||||
body: models::DummyPutRequest,
|
body: models::DummyPutRequest,
|
||||||
) -> std::result::Result<(
|
) -> std::result::Result<(models::DummyPutRequest,), ValidationErrors> {
|
||||||
models::DummyPutRequest,
|
|
||||||
), ValidationErrors>
|
|
||||||
{
|
|
||||||
let b = DummyPutBodyValidator { body: &body };
|
let b = DummyPutBodyValidator { body: &body };
|
||||||
b.validate()?;
|
b.validate()?;
|
||||||
|
|
||||||
Ok((
|
Ok((body,))
|
||||||
body,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// DummyPut - PUT /dummy
|
/// DummyPut - PUT /dummy
|
||||||
@ -238,60 +192,48 @@ where
|
|||||||
I: AsRef<A> + Send + Sync,
|
I: AsRef<A> + Send + Sync,
|
||||||
A: Api,
|
A: Api,
|
||||||
{
|
{
|
||||||
|
|
||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
let validation = tokio::task::spawn_blocking(move ||
|
let validation = tokio::task::spawn_blocking(move || dummy_put_validation(body))
|
||||||
dummy_put_validation(
|
.await
|
||||||
body,
|
.unwrap();
|
||||||
)
|
|
||||||
).await.unwrap();
|
|
||||||
|
|
||||||
let Ok((
|
let Ok((body,)) = validation else {
|
||||||
body,
|
|
||||||
)) = validation else {
|
|
||||||
return Response::builder()
|
return Response::builder()
|
||||||
.status(StatusCode::BAD_REQUEST)
|
.status(StatusCode::BAD_REQUEST)
|
||||||
.body(Body::from(validation.unwrap_err().to_string()))
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = api_impl.as_ref().dummy_put(
|
let result = api_impl
|
||||||
method,
|
.as_ref()
|
||||||
host,
|
.dummy_put(method, host, cookies, body)
|
||||||
cookies,
|
.await;
|
||||||
body,
|
|
||||||
).await;
|
|
||||||
|
|
||||||
let mut response = Response::builder();
|
let mut response = Response::builder();
|
||||||
|
|
||||||
let resp = match result {
|
let resp = match result {
|
||||||
Ok(rsp) => match rsp {
|
Ok(rsp) => match rsp {
|
||||||
DummyPutResponse::Status200_Success
|
DummyPutResponse::Status200_Success => {
|
||||||
=> {
|
|
||||||
|
|
||||||
let mut response = response.status(200);
|
let mut response = response.status(200);
|
||||||
response.body(Body::empty())
|
response.body(Body::empty())
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Application code returned an error. This should not happen, as the implementation should
|
// Application code returned an error. This should not happen, as the implementation should
|
||||||
// return a valid response.
|
// return a valid response.
|
||||||
response.status(500).body(Body::empty())
|
response.status(500).body(Body::empty())
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
resp.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn file_response_get_validation(
|
fn file_response_get_validation() -> std::result::Result<(), ValidationErrors> {
|
||||||
) -> std::result::Result<(
|
Ok(())
|
||||||
), ValidationErrors>
|
|
||||||
{
|
|
||||||
|
|
||||||
Ok((
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// FileResponseGet - GET /file_response
|
/// FileResponseGet - GET /file_response
|
||||||
@ -306,70 +248,67 @@ where
|
|||||||
I: AsRef<A> + Send + Sync,
|
I: AsRef<A> + Send + Sync,
|
||||||
A: Api,
|
A: Api,
|
||||||
{
|
{
|
||||||
|
|
||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
let validation = tokio::task::spawn_blocking(move ||
|
let validation = tokio::task::spawn_blocking(move || file_response_get_validation())
|
||||||
file_response_get_validation(
|
.await
|
||||||
)
|
.unwrap();
|
||||||
).await.unwrap();
|
|
||||||
|
|
||||||
let Ok((
|
let Ok(()) = validation else {
|
||||||
)) = validation else {
|
|
||||||
return Response::builder()
|
return Response::builder()
|
||||||
.status(StatusCode::BAD_REQUEST)
|
.status(StatusCode::BAD_REQUEST)
|
||||||
.body(Body::from(validation.unwrap_err().to_string()))
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = api_impl.as_ref().file_response_get(
|
let result = api_impl
|
||||||
method,
|
.as_ref()
|
||||||
host,
|
.file_response_get(method, host, cookies)
|
||||||
cookies,
|
.await;
|
||||||
).await;
|
|
||||||
|
|
||||||
let mut response = Response::builder();
|
let mut response = Response::builder();
|
||||||
|
|
||||||
let resp = match result {
|
let resp = match result {
|
||||||
Ok(rsp) => match rsp {
|
Ok(rsp) => match rsp {
|
||||||
FileResponseGetResponse::Status200_Success
|
FileResponseGetResponse::Status200_Success(body) => {
|
||||||
(body)
|
|
||||||
=> {
|
|
||||||
|
|
||||||
let mut response = response.status(200);
|
let mut response = response.status(200);
|
||||||
{
|
{
|
||||||
let mut response_headers = response.headers_mut().unwrap();
|
let mut response_headers = response.headers_mut().unwrap();
|
||||||
response_headers.insert(
|
response_headers.insert(
|
||||||
CONTENT_TYPE,
|
CONTENT_TYPE,
|
||||||
HeaderValue::from_str("application/json").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?);
|
HeaderValue::from_str("application/json").map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})?,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let body_content = tokio::task::spawn_blocking(move ||
|
let body_content = tokio::task::spawn_blocking(move || {
|
||||||
serde_json::to_vec(&body).map_err(|e| {
|
serde_json::to_vec(&body).map_err(|e| {
|
||||||
error!(error = ?e);
|
error!(error = ?e);
|
||||||
StatusCode::INTERNAL_SERVER_ERROR
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
})).await.unwrap()?;
|
})
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap()?;
|
||||||
response.body(Body::from(body_content))
|
response.body(Body::from(body_content))
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Application code returned an error. This should not happen, as the implementation should
|
// Application code returned an error. This should not happen, as the implementation should
|
||||||
// return a valid response.
|
// return a valid response.
|
||||||
response.status(500).body(Body::empty())
|
response.status(500).body(Body::empty())
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
resp.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn get_structured_yaml_validation(
|
fn get_structured_yaml_validation() -> std::result::Result<(), ValidationErrors> {
|
||||||
) -> std::result::Result<(
|
Ok(())
|
||||||
), ValidationErrors>
|
|
||||||
{
|
|
||||||
|
|
||||||
Ok((
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GetStructuredYaml - GET /get-structured-yaml
|
/// GetStructuredYaml - GET /get-structured-yaml
|
||||||
@ -384,55 +323,55 @@ where
|
|||||||
I: AsRef<A> + Send + Sync,
|
I: AsRef<A> + Send + Sync,
|
||||||
A: Api,
|
A: Api,
|
||||||
{
|
{
|
||||||
|
|
||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
let validation = tokio::task::spawn_blocking(move ||
|
let validation = tokio::task::spawn_blocking(move || get_structured_yaml_validation())
|
||||||
get_structured_yaml_validation(
|
.await
|
||||||
)
|
.unwrap();
|
||||||
).await.unwrap();
|
|
||||||
|
|
||||||
let Ok((
|
let Ok(()) = validation else {
|
||||||
)) = validation else {
|
|
||||||
return Response::builder()
|
return Response::builder()
|
||||||
.status(StatusCode::BAD_REQUEST)
|
.status(StatusCode::BAD_REQUEST)
|
||||||
.body(Body::from(validation.unwrap_err().to_string()))
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = api_impl.as_ref().get_structured_yaml(
|
let result = api_impl
|
||||||
method,
|
.as_ref()
|
||||||
host,
|
.get_structured_yaml(method, host, cookies)
|
||||||
cookies,
|
.await;
|
||||||
).await;
|
|
||||||
|
|
||||||
let mut response = Response::builder();
|
let mut response = Response::builder();
|
||||||
|
|
||||||
let resp = match result {
|
let resp = match result {
|
||||||
Ok(rsp) => match rsp {
|
Ok(rsp) => match rsp {
|
||||||
GetStructuredYamlResponse::Status200_OK
|
GetStructuredYamlResponse::Status200_OK(body) => {
|
||||||
(body)
|
|
||||||
=> {
|
|
||||||
|
|
||||||
let mut response = response.status(200);
|
let mut response = response.status(200);
|
||||||
{
|
{
|
||||||
let mut response_headers = response.headers_mut().unwrap();
|
let mut response_headers = response.headers_mut().unwrap();
|
||||||
response_headers.insert(
|
response_headers.insert(
|
||||||
CONTENT_TYPE,
|
CONTENT_TYPE,
|
||||||
HeaderValue::from_str("application/yaml").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?);
|
HeaderValue::from_str("application/yaml").map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})?,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let body_content = body;
|
let body_content = body;
|
||||||
response.body(Body::from(body_content))
|
response.body(Body::from(body_content))
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Application code returned an error. This should not happen, as the implementation should
|
// Application code returned an error. This should not happen, as the implementation should
|
||||||
// return a valid response.
|
// return a valid response.
|
||||||
response.status(500).body(Body::empty())
|
response.status(500).body(Body::empty())
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
resp.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(validator::Validate)]
|
#[derive(validator::Validate)]
|
||||||
@ -441,18 +380,9 @@ where
|
|||||||
body: &'a String,
|
body: &'a String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn html_post_validation(
|
fn html_post_validation(body: String) -> std::result::Result<(String,), ValidationErrors> {
|
||||||
body: String,
|
Ok((body,))
|
||||||
) -> std::result::Result<(
|
|
||||||
String,
|
|
||||||
), ValidationErrors>
|
|
||||||
{
|
|
||||||
|
|
||||||
Ok((
|
|
||||||
body,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// HtmlPost - POST /html
|
/// HtmlPost - POST /html
|
||||||
@ -468,58 +398,55 @@ where
|
|||||||
I: AsRef<A> + Send + Sync,
|
I: AsRef<A> + Send + Sync,
|
||||||
A: Api,
|
A: Api,
|
||||||
{
|
{
|
||||||
|
|
||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
let validation = tokio::task::spawn_blocking(move ||
|
let validation = tokio::task::spawn_blocking(move || html_post_validation(body))
|
||||||
html_post_validation(
|
.await
|
||||||
body,
|
.unwrap();
|
||||||
)
|
|
||||||
).await.unwrap();
|
|
||||||
|
|
||||||
let Ok((
|
let Ok((body,)) = validation else {
|
||||||
body,
|
|
||||||
)) = validation else {
|
|
||||||
return Response::builder()
|
return Response::builder()
|
||||||
.status(StatusCode::BAD_REQUEST)
|
.status(StatusCode::BAD_REQUEST)
|
||||||
.body(Body::from(validation.unwrap_err().to_string()))
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = api_impl.as_ref().html_post(
|
let result = api_impl
|
||||||
method,
|
.as_ref()
|
||||||
host,
|
.html_post(method, host, cookies, body)
|
||||||
cookies,
|
.await;
|
||||||
body,
|
|
||||||
).await;
|
|
||||||
|
|
||||||
let mut response = Response::builder();
|
let mut response = Response::builder();
|
||||||
|
|
||||||
let resp = match result {
|
let resp = match result {
|
||||||
Ok(rsp) => match rsp {
|
Ok(rsp) => match rsp {
|
||||||
HtmlPostResponse::Status200_Success
|
HtmlPostResponse::Status200_Success(body) => {
|
||||||
(body)
|
|
||||||
=> {
|
|
||||||
|
|
||||||
let mut response = response.status(200);
|
let mut response = response.status(200);
|
||||||
{
|
{
|
||||||
let mut response_headers = response.headers_mut().unwrap();
|
let mut response_headers = response.headers_mut().unwrap();
|
||||||
response_headers.insert(
|
response_headers.insert(
|
||||||
CONTENT_TYPE,
|
CONTENT_TYPE,
|
||||||
HeaderValue::from_str("text/html").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?);
|
HeaderValue::from_str("text/html").map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})?,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let body_content = body;
|
let body_content = body;
|
||||||
response.body(Body::from(body_content))
|
response.body(Body::from(body_content))
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Application code returned an error. This should not happen, as the implementation should
|
// Application code returned an error. This should not happen, as the implementation should
|
||||||
// return a valid response.
|
// return a valid response.
|
||||||
response.status(500).body(Body::empty())
|
response.status(500).body(Body::empty())
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
resp.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(validator::Validate)]
|
#[derive(validator::Validate)]
|
||||||
@ -528,18 +455,9 @@ where
|
|||||||
body: &'a String,
|
body: &'a String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn post_yaml_validation(
|
fn post_yaml_validation(body: String) -> std::result::Result<(String,), ValidationErrors> {
|
||||||
body: String,
|
Ok((body,))
|
||||||
) -> std::result::Result<(
|
|
||||||
String,
|
|
||||||
), ValidationErrors>
|
|
||||||
{
|
|
||||||
|
|
||||||
Ok((
|
|
||||||
body,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// PostYaml - POST /post-yaml
|
/// PostYaml - POST /post-yaml
|
||||||
@ -555,60 +473,48 @@ where
|
|||||||
I: AsRef<A> + Send + Sync,
|
I: AsRef<A> + Send + Sync,
|
||||||
A: Api,
|
A: Api,
|
||||||
{
|
{
|
||||||
|
|
||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
let validation = tokio::task::spawn_blocking(move ||
|
let validation = tokio::task::spawn_blocking(move || post_yaml_validation(body))
|
||||||
post_yaml_validation(
|
.await
|
||||||
body,
|
.unwrap();
|
||||||
)
|
|
||||||
).await.unwrap();
|
|
||||||
|
|
||||||
let Ok((
|
let Ok((body,)) = validation else {
|
||||||
body,
|
|
||||||
)) = validation else {
|
|
||||||
return Response::builder()
|
return Response::builder()
|
||||||
.status(StatusCode::BAD_REQUEST)
|
.status(StatusCode::BAD_REQUEST)
|
||||||
.body(Body::from(validation.unwrap_err().to_string()))
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = api_impl.as_ref().post_yaml(
|
let result = api_impl
|
||||||
method,
|
.as_ref()
|
||||||
host,
|
.post_yaml(method, host, cookies, body)
|
||||||
cookies,
|
.await;
|
||||||
body,
|
|
||||||
).await;
|
|
||||||
|
|
||||||
let mut response = Response::builder();
|
let mut response = Response::builder();
|
||||||
|
|
||||||
let resp = match result {
|
let resp = match result {
|
||||||
Ok(rsp) => match rsp {
|
Ok(rsp) => match rsp {
|
||||||
PostYamlResponse::Status204_OK
|
PostYamlResponse::Status204_OK => {
|
||||||
=> {
|
|
||||||
|
|
||||||
let mut response = response.status(204);
|
let mut response = response.status(204);
|
||||||
response.body(Body::empty())
|
response.body(Body::empty())
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Application code returned an error. This should not happen, as the implementation should
|
// Application code returned an error. This should not happen, as the implementation should
|
||||||
// return a valid response.
|
// return a valid response.
|
||||||
response.status(500).body(Body::empty())
|
response.status(500).body(Body::empty())
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
resp.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn raw_json_get_validation(
|
fn raw_json_get_validation() -> std::result::Result<(), ValidationErrors> {
|
||||||
) -> std::result::Result<(
|
Ok(())
|
||||||
), ValidationErrors>
|
|
||||||
{
|
|
||||||
|
|
||||||
Ok((
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// RawJsonGet - GET /raw_json
|
/// RawJsonGet - GET /raw_json
|
||||||
@ -623,59 +529,59 @@ where
|
|||||||
I: AsRef<A> + Send + Sync,
|
I: AsRef<A> + Send + Sync,
|
||||||
A: Api,
|
A: Api,
|
||||||
{
|
{
|
||||||
|
|
||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
let validation = tokio::task::spawn_blocking(move ||
|
let validation = tokio::task::spawn_blocking(move || raw_json_get_validation())
|
||||||
raw_json_get_validation(
|
.await
|
||||||
)
|
.unwrap();
|
||||||
).await.unwrap();
|
|
||||||
|
|
||||||
let Ok((
|
let Ok(()) = validation else {
|
||||||
)) = validation else {
|
|
||||||
return Response::builder()
|
return Response::builder()
|
||||||
.status(StatusCode::BAD_REQUEST)
|
.status(StatusCode::BAD_REQUEST)
|
||||||
.body(Body::from(validation.unwrap_err().to_string()))
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = api_impl.as_ref().raw_json_get(
|
let result = api_impl.as_ref().raw_json_get(method, host, cookies).await;
|
||||||
method,
|
|
||||||
host,
|
|
||||||
cookies,
|
|
||||||
).await;
|
|
||||||
|
|
||||||
let mut response = Response::builder();
|
let mut response = Response::builder();
|
||||||
|
|
||||||
let resp = match result {
|
let resp = match result {
|
||||||
Ok(rsp) => match rsp {
|
Ok(rsp) => match rsp {
|
||||||
RawJsonGetResponse::Status200_Success
|
RawJsonGetResponse::Status200_Success(body) => {
|
||||||
(body)
|
|
||||||
=> {
|
|
||||||
|
|
||||||
let mut response = response.status(200);
|
let mut response = response.status(200);
|
||||||
{
|
{
|
||||||
let mut response_headers = response.headers_mut().unwrap();
|
let mut response_headers = response.headers_mut().unwrap();
|
||||||
response_headers.insert(
|
response_headers.insert(
|
||||||
CONTENT_TYPE,
|
CONTENT_TYPE,
|
||||||
HeaderValue::from_str("*/*").map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })?);
|
HeaderValue::from_str("*/*").map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})?,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let body_content = tokio::task::spawn_blocking(move ||
|
let body_content = tokio::task::spawn_blocking(move || {
|
||||||
serde_json::to_vec(&body).map_err(|e| {
|
serde_json::to_vec(&body).map_err(|e| {
|
||||||
error!(error = ?e);
|
error!(error = ?e);
|
||||||
StatusCode::INTERNAL_SERVER_ERROR
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
})).await.unwrap()?;
|
})
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap()?;
|
||||||
response.body(Body::from(body_content))
|
response.body(Body::from(body_content))
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Application code returned an error. This should not happen, as the implementation should
|
// Application code returned an error. This should not happen, as the implementation should
|
||||||
// return a valid response.
|
// return a valid response.
|
||||||
response.status(500).body(Body::empty())
|
response.status(500).body(Body::empty())
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
resp.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(validator::Validate)]
|
#[derive(validator::Validate)]
|
||||||
@ -684,20 +590,14 @@ where
|
|||||||
body: &'a crate::types::Object,
|
body: &'a crate::types::Object,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
fn solo_object_post_validation(
|
fn solo_object_post_validation(
|
||||||
body: crate::types::Object,
|
body: crate::types::Object,
|
||||||
) -> std::result::Result<(
|
) -> std::result::Result<(crate::types::Object,), ValidationErrors> {
|
||||||
crate::types::Object,
|
|
||||||
), ValidationErrors>
|
|
||||||
{
|
|
||||||
let b = SoloObjectPostBodyValidator { body: &body };
|
let b = SoloObjectPostBodyValidator { body: &body };
|
||||||
b.validate()?;
|
b.validate()?;
|
||||||
|
|
||||||
Ok((
|
Ok((body,))
|
||||||
body,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SoloObjectPost - POST /solo-object
|
/// SoloObjectPost - POST /solo-object
|
||||||
@ -713,48 +613,41 @@ where
|
|||||||
I: AsRef<A> + Send + Sync,
|
I: AsRef<A> + Send + Sync,
|
||||||
A: Api,
|
A: Api,
|
||||||
{
|
{
|
||||||
|
|
||||||
#[allow(clippy::redundant_closure)]
|
#[allow(clippy::redundant_closure)]
|
||||||
let validation = tokio::task::spawn_blocking(move ||
|
let validation = tokio::task::spawn_blocking(move || solo_object_post_validation(body))
|
||||||
solo_object_post_validation(
|
.await
|
||||||
body,
|
.unwrap();
|
||||||
)
|
|
||||||
).await.unwrap();
|
|
||||||
|
|
||||||
let Ok((
|
let Ok((body,)) = validation else {
|
||||||
body,
|
|
||||||
)) = validation else {
|
|
||||||
return Response::builder()
|
return Response::builder()
|
||||||
.status(StatusCode::BAD_REQUEST)
|
.status(StatusCode::BAD_REQUEST)
|
||||||
.body(Body::from(validation.unwrap_err().to_string()))
|
.body(Body::from(validation.unwrap_err().to_string()))
|
||||||
.map_err(|_| StatusCode::BAD_REQUEST);
|
.map_err(|_| StatusCode::BAD_REQUEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = api_impl.as_ref().solo_object_post(
|
let result = api_impl
|
||||||
method,
|
.as_ref()
|
||||||
host,
|
.solo_object_post(method, host, cookies, body)
|
||||||
cookies,
|
.await;
|
||||||
body,
|
|
||||||
).await;
|
|
||||||
|
|
||||||
let mut response = Response::builder();
|
let mut response = Response::builder();
|
||||||
|
|
||||||
let resp = match result {
|
let resp = match result {
|
||||||
Ok(rsp) => match rsp {
|
Ok(rsp) => match rsp {
|
||||||
SoloObjectPostResponse::Status204_OK
|
SoloObjectPostResponse::Status204_OK => {
|
||||||
=> {
|
|
||||||
|
|
||||||
let mut response = response.status(204);
|
let mut response = response.status(204);
|
||||||
response.body(Body::empty())
|
response.body(Body::empty())
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Application code returned an error. This should not happen, as the implementation should
|
// Application code returned an error. This should not happen, as the implementation should
|
||||||
// return a valid response.
|
// return a valid response.
|
||||||
response.status(500).body(Body::empty())
|
response.status(500).body(Body::empty())
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resp.map_err(|e| { error!(error = ?e); StatusCode::INTERNAL_SERVER_ERROR })
|
resp.map_err(|e| {
|
||||||
|
error!(error = ?e);
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user