mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
Merge remote-tracking branch 'origin/master' into 2.3.0
This commit is contained in:
commit
094dbd00ed
@ -24,7 +24,7 @@
|
|||||||
## Overview
|
## Overview
|
||||||
This is the swagger codegen project, which allows generation of API client libraries (SDK generation), server stubs and documentation automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification). Currently, the following languages/frameworks are supported:
|
This is the swagger codegen project, which allows generation of API client libraries (SDK generation), server stubs and documentation automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification). Currently, the following languages/frameworks are supported:
|
||||||
|
|
||||||
- **API clients**: **ActionScript**, **Apex**, **Bash**, **C#** (.net 2.0, 4.0 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Go**, **Groovy**, **Haskell**, **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy), **Kotlin**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **Ruby**, **Scala**, **Swift** (2.x, 3.x, 4.x), **Typescript** (Angular1.x, Angular2.x, Fetch, jQuery, Node)
|
- **API clients**: **ActionScript**, **Apex**, **Bash**, **C#** (.net 2.0, 4.0 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Eiffel**, **Go**, **Groovy**, **Haskell**, **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy), **Kotlin**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **Ruby**, **Scala**, **Swift** (2.x, 3.x, 4.x), **Typescript** (Angular1.x, Angular2.x, Fetch, jQuery, Node)
|
||||||
- **Server stubs**: **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell**, **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework), **PHP** (Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Scala** ([Finch](https://github.com/finagle/finch), Scalatra)
|
- **Server stubs**: **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell**, **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework), **PHP** (Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Scala** ([Finch](https://github.com/finagle/finch), Scalatra)
|
||||||
- **API documentation generators**: **HTML**, **Confluence Wiki**
|
- **API documentation generators**: **HTML**, **Confluence Wiki**
|
||||||
- **Configuration files**: [**Apache2**](https://httpd.apache.org/)
|
- **Configuration files**: [**Apache2**](https://httpd.apache.org/)
|
||||||
@ -839,6 +839,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
|
|||||||
- [Yelp](http://www.yelp.com/)
|
- [Yelp](http://www.yelp.com/)
|
||||||
- [Zalando](https://tech.zalando.com)
|
- [Zalando](https://tech.zalando.com)
|
||||||
- [ZEEF.com](https://zeef.com/)
|
- [ZEEF.com](https://zeef.com/)
|
||||||
|
- [zooplus](https://www.zooplus.com/)
|
||||||
|
|
||||||
Presentations/Videos/Tutorials/Books
|
Presentations/Videos/Tutorials/Books
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
@ -923,6 +924,7 @@ Here is a list of template creators:
|
|||||||
* Clojure: @xhh
|
* Clojure: @xhh
|
||||||
* Dart: @yissachar
|
* Dart: @yissachar
|
||||||
* Elixir: @niku
|
* Elixir: @niku
|
||||||
|
* Eiffel: @jvelilla
|
||||||
* Groovy: @victorgit
|
* Groovy: @victorgit
|
||||||
* Go: @wing328
|
* Go: @wing328
|
||||||
* Go (rewritten in 2.3.0): @antihax
|
* Go (rewritten in 2.3.0): @antihax
|
||||||
|
18
bin/windows/typescript-angular2-all.bat
Normal file
18
bin/windows/typescript-angular2-all.bat
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
|
||||||
|
|
||||||
|
If Not Exist %executable% (
|
||||||
|
mvn clean package
|
||||||
|
)
|
||||||
|
|
||||||
|
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||||
|
echo "Typescript Petstore API client (default)"
|
||||||
|
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l typescript-angular2 -o samples\client\petstore\typescript-angular2\default
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
||||||
|
|
||||||
|
echo "Typescript Petstore API client (with interfaces generated)"
|
||||||
|
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l typescript-angular2 -o samples\client\petstore\typescript-angular2\with-interfaces -D withInterfaces=true
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
||||||
|
|
||||||
|
echo "Typescript Petstore API client (npm setting)"
|
||||||
|
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l typescript-angular2 -c bin\typescript-petstore-npm.json -o samples\client\petstore\typescript-angular2\npm
|
||||||
|
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -0,0 +1,623 @@
|
|||||||
|
package io.swagger.codegen.languages;
|
||||||
|
|
||||||
|
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
|
import io.swagger.codegen.CliOption;
|
||||||
|
import io.swagger.codegen.CodegenConfig;
|
||||||
|
import io.swagger.codegen.CodegenConstants;
|
||||||
|
import io.swagger.codegen.CodegenModel;
|
||||||
|
import io.swagger.codegen.CodegenOperation;
|
||||||
|
import io.swagger.codegen.CodegenParameter;
|
||||||
|
import io.swagger.codegen.CodegenProperty;
|
||||||
|
import io.swagger.codegen.CodegenType;
|
||||||
|
import io.swagger.codegen.DefaultCodegen;
|
||||||
|
import io.swagger.codegen.SupportingFile;
|
||||||
|
import io.swagger.codegen.utils.ModelUtils;
|
||||||
|
import io.swagger.models.properties.ArrayProperty;
|
||||||
|
import io.swagger.models.properties.MapProperty;
|
||||||
|
import io.swagger.models.properties.Property;
|
||||||
|
|
||||||
|
public class EiffelClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||||
|
static Logger LOGGER = LoggerFactory.getLogger(EiffelClientCodegen.class);
|
||||||
|
|
||||||
|
protected String libraryTarget = "swagger_eiffel_client";
|
||||||
|
protected String packageName = "Eiffel";
|
||||||
|
protected String packageVersion = "1.0.0";
|
||||||
|
protected String apiDocPath = "docs";
|
||||||
|
protected String modelDocPath = "docs";
|
||||||
|
protected String modelPath = "domain";
|
||||||
|
|
||||||
|
protected UUID uuid;
|
||||||
|
protected UUID uuidTest;
|
||||||
|
|
||||||
|
private final Set<String> parentModels = new HashSet<>();
|
||||||
|
private final Multimap<String, CodegenModel> childrenByParent = ArrayListMultimap.create();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CodegenType getTag() {
|
||||||
|
return CodegenType.CLIENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "eiffel";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return "Generates a Eiffel client library (beta).";
|
||||||
|
}
|
||||||
|
|
||||||
|
public EiffelClientCodegen() {
|
||||||
|
super();
|
||||||
|
uuid = UUID.randomUUID();
|
||||||
|
uuidTest = UUID.randomUUID();
|
||||||
|
;
|
||||||
|
outputFolder = "generated-code/Eiffel";
|
||||||
|
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||||
|
modelTemplateFiles.put("model.mustache", ".e");
|
||||||
|
apiTemplateFiles.put("api.mustache", ".e");
|
||||||
|
apiTestTemplateFiles.put("test/api_test.mustache", ".e");
|
||||||
|
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||||
|
embeddedTemplateDir = templateDir = "Eiffel";
|
||||||
|
|
||||||
|
setReservedWordsLowerCase(Arrays.asList(
|
||||||
|
// language reserved words
|
||||||
|
"across", "agent", "alias", "all", "and", "as", "assign", "attribute", "check", "class", "convert",
|
||||||
|
"create", "Current", "debug", "deferred", "do", "else", "elseif", "end", "ensure", "expanded", "export",
|
||||||
|
"external", "False", "feature", "from", "frozen", "if", "implies", "inherit", "inspect", "invariant",
|
||||||
|
"like", "local", "loop", "not", "note", "obsolete", "old", "once", "only", "or", "Precursor",
|
||||||
|
"redefine", "rename", "require", "rescue", "Result", "retry", "select", "separate", "then", "True",
|
||||||
|
"TUPLE", "undefine", "until", "variant", "Void", "when", "xor"));
|
||||||
|
|
||||||
|
defaultIncludes = new HashSet<String>(Arrays.asList("map", "array"));
|
||||||
|
|
||||||
|
languageSpecificPrimitives = new HashSet<String>(
|
||||||
|
Arrays.asList("BOOLEAN", "INTEGER_8", "INTEGER_16", "INTEGER_32", "INTEGER_64", "NATURAL_8",
|
||||||
|
"NATURAL_16", "NATURAL_32", "NATURAL_64", "REAL_32", "REAL_64"));
|
||||||
|
|
||||||
|
instantiationTypes.clear();
|
||||||
|
|
||||||
|
typeMapping.clear();
|
||||||
|
typeMapping.put("integer", "INTEGER_32");
|
||||||
|
typeMapping.put("long", "INTEGER_64");
|
||||||
|
typeMapping.put("number", "REAL_32");
|
||||||
|
typeMapping.put("float", "REAL_32");
|
||||||
|
typeMapping.put("double", "REAL_64");
|
||||||
|
typeMapping.put("boolean", "BOOLEAN");
|
||||||
|
typeMapping.put("string", "STRING_32");
|
||||||
|
typeMapping.put("UUID", "UUID"); //
|
||||||
|
typeMapping.put("date", "DATE");
|
||||||
|
typeMapping.put("DateTime", "DATE_TIME");
|
||||||
|
typeMapping.put("date-time", "DATE_TIME");
|
||||||
|
typeMapping.put("password", "STRING");
|
||||||
|
typeMapping.put("File", "FILE");
|
||||||
|
typeMapping.put("file", "FILE");
|
||||||
|
typeMapping.put("binary", "STRING_32");
|
||||||
|
typeMapping.put("ByteArray", "ARRAY [NATURAL_8]");
|
||||||
|
typeMapping.put("object", "ANY");
|
||||||
|
typeMapping.put("map", "STRING_TABLE");
|
||||||
|
typeMapping.put("array", "LIST");
|
||||||
|
typeMapping.put("list", "LIST");
|
||||||
|
|
||||||
|
//instantiationTypes.put("array", "ARRAY");
|
||||||
|
//instantiationTypes.put("list", "ARRAYED_LIST");
|
||||||
|
//instantiationTypes.put("map", "STRING_TABLE");
|
||||||
|
|
||||||
|
|
||||||
|
cliOptions.clear();
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Eiffel Cluster name (convention: lowercase).")
|
||||||
|
.defaultValue("swagger"));
|
||||||
|
cliOptions
|
||||||
|
.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Eiffel package version.").defaultValue("1.0.0"));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
|
||||||
|
"hides the timestamp when files were generated").defaultValue(Boolean.TRUE.toString()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processOpts() {
|
||||||
|
super.processOpts();
|
||||||
|
|
||||||
|
// default HIDE_GENERATION_TIMESTAMP to true
|
||||||
|
if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) {
|
||||||
|
additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString());
|
||||||
|
} else {
|
||||||
|
additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP,
|
||||||
|
Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
|
||||||
|
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
|
||||||
|
} else {
|
||||||
|
setPackageName("swagger");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
|
||||||
|
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
|
||||||
|
} else {
|
||||||
|
setPackageVersion("1.0.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
||||||
|
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
|
||||||
|
|
||||||
|
additionalProperties.put("uuid", uuid.toString());
|
||||||
|
additionalProperties.put("uuidTest", uuidTest.toString());
|
||||||
|
additionalProperties.put("libraryTarget", libraryTarget);
|
||||||
|
additionalProperties.put("apiDocPath", apiDocPath);
|
||||||
|
additionalProperties.put("modelDocPath", modelDocPath);
|
||||||
|
|
||||||
|
modelPackage = packageName;
|
||||||
|
apiPackage = packageName;
|
||||||
|
|
||||||
|
final String authFolder = ("src/framework/auth");
|
||||||
|
final String serializerFolder = ("src/framework/serialization");
|
||||||
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
|
supportingFiles.add(new SupportingFile("ecf.mustache", "", "api_client.ecf"));
|
||||||
|
supportingFiles.add(new SupportingFile("test/ecf_test.mustache", "test", "api_test.ecf"));
|
||||||
|
supportingFiles.add(new SupportingFile("test/application.mustache", "test", "application.e"));
|
||||||
|
supportingFiles.add(new SupportingFile("api_client.mustache", "src", "api_client.e"));
|
||||||
|
supportingFiles.add(new SupportingFile("framework/api_i.mustache", "src/framework", "api_i.e"));
|
||||||
|
supportingFiles.add(
|
||||||
|
new SupportingFile("framework/api_client_request.mustache", "src/framework", "api_client_request.e"));
|
||||||
|
supportingFiles.add(
|
||||||
|
new SupportingFile("framework/api_client_response.mustache", "src/framework", "api_client_response.e"));
|
||||||
|
supportingFiles.add(new SupportingFile("framework/api_error.mustache", "src/framework", "api_error.e"));
|
||||||
|
supportingFiles.add(new SupportingFile("framework/configuration.mustache", "src/framework", "configuration.e"));
|
||||||
|
supportingFiles
|
||||||
|
.add(new SupportingFile("framework/auth/authentication.mustache", authFolder, "authentication.e"));
|
||||||
|
supportingFiles.add(new SupportingFile("framework/auth/api_key_auth.mustache", authFolder, "api_key_auth.e"));
|
||||||
|
supportingFiles
|
||||||
|
.add(new SupportingFile("framework/auth/http_basic_auth.mustache", authFolder, "http_basic_auth.e"));
|
||||||
|
supportingFiles.add(new SupportingFile("framework/auth/oauth.mustache", authFolder, "oauth.e"));
|
||||||
|
supportingFiles.add(new SupportingFile("framework/serialization/api_deserializer.mustache", serializerFolder,
|
||||||
|
"api_deserializer.e"));
|
||||||
|
supportingFiles.add(new SupportingFile("framework/serialization/api_json_deserializer.mustache",
|
||||||
|
serializerFolder, "api_json_deserializer.e"));
|
||||||
|
supportingFiles.add(new SupportingFile("framework/serialization/api_json_serializer.mustache", serializerFolder,
|
||||||
|
"api_json_serializer.e"));
|
||||||
|
supportingFiles.add(new SupportingFile("framework/serialization/api_serializer.mustache", serializerFolder,
|
||||||
|
"api_serializer.e"));
|
||||||
|
supportingFiles.add(new SupportingFile("framework/serialization/json_basic_reflector_deserializer.mustache",
|
||||||
|
serializerFolder, "json_basic_reflector_deserializer.e"));
|
||||||
|
supportingFiles.add(new SupportingFile("framework/serialization/json_type_utilities_ext.mustache",
|
||||||
|
serializerFolder, "json_type_utilities_ext.e"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeReservedWord(String name) {
|
||||||
|
// Can't start with an underscore, as our fields need to start with an
|
||||||
|
// UppercaseLetter so that Go treats them as public/visible.
|
||||||
|
|
||||||
|
// Options?
|
||||||
|
// - MyName
|
||||||
|
// - AName
|
||||||
|
// - TheName
|
||||||
|
// - XName
|
||||||
|
// - X_Name
|
||||||
|
// ... or maybe a suffix?
|
||||||
|
// - Name_ ... think this will work.
|
||||||
|
if (this.reservedWordsMappings().containsKey(name)) {
|
||||||
|
return this.reservedWordsMappings().get(name);
|
||||||
|
}
|
||||||
|
return camelize(name) + '_';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiFileFolder() {
|
||||||
|
return outputFolder + File.separator + "src" + File.separator + "api";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String modelFileFolder() {
|
||||||
|
return outputFolder + File.separator + "src" + File.separator + modelPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String apiTestFileFolder() {
|
||||||
|
return outputFolder + File.separator + "test" + File.separator + "apis";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toVarName(String name) {
|
||||||
|
// replace - with _ e.g. created-at => created_at
|
||||||
|
name = sanitizeName(name.replaceAll("-", "_"));
|
||||||
|
|
||||||
|
// if it's all uppper case, do nothing
|
||||||
|
if (name.matches("^[A-Z_]*$")) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// pet_id
|
||||||
|
// petId => pet_id
|
||||||
|
name = unCamelize(name);
|
||||||
|
|
||||||
|
// for reserved word or word starting with number, append _
|
||||||
|
if (isReservedWord(name)) {
|
||||||
|
name = escapeReservedWord(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// for reserved word or word starting with number, append _
|
||||||
|
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||||
|
name = escapeReservedWord(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toParamName(String name) {
|
||||||
|
// params should be lowercase. E.g. "person: PERSON"
|
||||||
|
return toVarName(name).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelName(String name) {
|
||||||
|
// phone_number => PHONE_NUMBER
|
||||||
|
return toModelFilename(name).toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelFilename(String name) {
|
||||||
|
if (!StringUtils.isEmpty(modelNamePrefix)) {
|
||||||
|
name = modelNamePrefix + "_" + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isEmpty(modelNameSuffix)) {
|
||||||
|
name = name + "_" + modelNameSuffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
name = sanitizeName(name);
|
||||||
|
|
||||||
|
// model name cannot use reserved keyword, e.g. return
|
||||||
|
if (isReservedWord(name)) {
|
||||||
|
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + ("model_" + name));
|
||||||
|
name = "model_" + name; // e.g. return => ModelReturn (after
|
||||||
|
// camelize)
|
||||||
|
}
|
||||||
|
|
||||||
|
// model name starts with number
|
||||||
|
if (name.matches("^\\d.*")) {
|
||||||
|
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to "
|
||||||
|
+ ("model_" + name));
|
||||||
|
name = "model_" + name; // e.g. 200Response => Model200Response
|
||||||
|
// (after camelize)
|
||||||
|
}
|
||||||
|
|
||||||
|
return underscore(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiFilename(String name) {
|
||||||
|
// replace - with _ e.g. created-at => created_at
|
||||||
|
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be
|
||||||
|
// assigned. Also declare the
|
||||||
|
// methods parameters as 'final'.
|
||||||
|
|
||||||
|
// e.g. PetApi.go => pet_api.go
|
||||||
|
return underscore(name) + "_api";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiTestFilename(String name) {
|
||||||
|
return toApiName(name).toLowerCase() + "_test";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiName(String name) {
|
||||||
|
if (name.length() == 0) {
|
||||||
|
return "DEFAULT_API";
|
||||||
|
}
|
||||||
|
return name.toUpperCase() + "_API";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overrides postProcessParameter to add a vendor extension
|
||||||
|
* "x-exportParamName". This is useful when paramName starts with a
|
||||||
|
* lowercase letter, but we need that param to be exportable (starts with an
|
||||||
|
* Uppercase letter).
|
||||||
|
*
|
||||||
|
* @param parameter
|
||||||
|
* CodegenParameter object to be processed.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void postProcessParameter(CodegenParameter parameter) {
|
||||||
|
|
||||||
|
// Give the base class a chance to process
|
||||||
|
super.postProcessParameter(parameter);
|
||||||
|
|
||||||
|
char firstChar = parameter.paramName.charAt(0);
|
||||||
|
|
||||||
|
if (Character.isUpperCase(firstChar)) {
|
||||||
|
// First char is already uppercase, just use paramName.
|
||||||
|
parameter.vendorExtensions.put("x-exportParamName", parameter.paramName);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// It's a lowercase first char, let's convert it to uppercase
|
||||||
|
StringBuilder sb = new StringBuilder(parameter.paramName);
|
||||||
|
sb.setCharAt(0, Character.toUpperCase(firstChar));
|
||||||
|
parameter.vendorExtensions.put("x-exportParamName", sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||||
|
if (!isNullOrEmpty(model.parent)) {
|
||||||
|
parentModels.add(model.parent);
|
||||||
|
if (!childrenByParent.containsEntry(model.parent, model)) {
|
||||||
|
childrenByParent.put(model.parent, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isNullOrEmpty(model.parentSchema)) {
|
||||||
|
model.parentSchema = model.parentSchema.toLowerCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apiDocFileFolder() {
|
||||||
|
return (outputFolder + "/" + apiDocPath).replace('/', File.separatorChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String modelDocFileFolder() {
|
||||||
|
return (outputFolder + "/" + modelDocPath).replace('/', File.separatorChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelDocFilename(String name) {
|
||||||
|
return toModelName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiDocFilename(String name) {
|
||||||
|
return toApiName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeDeclaration(Property p) {
|
||||||
|
if (p instanceof ArrayProperty) {
|
||||||
|
ArrayProperty ap = (ArrayProperty) p;
|
||||||
|
Property inner = ap.getItems();
|
||||||
|
return "LIST [" + getTypeDeclaration(inner) + "]";
|
||||||
|
} else if (p instanceof MapProperty) {
|
||||||
|
MapProperty mp = (MapProperty) p;
|
||||||
|
Property inner = mp.getAdditionalProperties();
|
||||||
|
|
||||||
|
return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
|
||||||
|
}
|
||||||
|
// return super.getTypeDeclaration(p);
|
||||||
|
|
||||||
|
// Not using the supertype invocation, because we want to UpperCamelize
|
||||||
|
// the type.
|
||||||
|
String swaggerType = getSwaggerType(p);
|
||||||
|
if (typeMapping.containsKey(swaggerType)) {
|
||||||
|
return typeMapping.get(swaggerType);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeMapping.containsValue(swaggerType)) {
|
||||||
|
return swaggerType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (languageSpecificPrimitives.contains(swaggerType)) {
|
||||||
|
return swaggerType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return toModelName(swaggerType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSwaggerType(Property p) {
|
||||||
|
String swaggerType = super.getSwaggerType(p);
|
||||||
|
String type = null;
|
||||||
|
if (typeMapping.containsKey(swaggerType)) {
|
||||||
|
type = typeMapping.get(swaggerType);
|
||||||
|
if (languageSpecificPrimitives.contains(type))
|
||||||
|
return (type);
|
||||||
|
} else
|
||||||
|
type = swaggerType;
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toOperationId(String operationId) {
|
||||||
|
String sanitizedOperationId = sanitizeName(operationId);
|
||||||
|
|
||||||
|
// method name cannot use reserved keyword, e.g. return
|
||||||
|
if (isReservedWord(sanitizedOperationId)) {
|
||||||
|
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to "
|
||||||
|
+ camelize("call_" + operationId));
|
||||||
|
sanitizedOperationId = "call_" + sanitizedOperationId;
|
||||||
|
}
|
||||||
|
// method name from updateSomething to update_Something.
|
||||||
|
sanitizedOperationId = unCamelize(sanitizedOperationId);
|
||||||
|
|
||||||
|
return toEiffelFeatureStyle(sanitizedOperationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||||
|
for (CodegenOperation operation : operations) {
|
||||||
|
// http method verb conversion (e.g. PUT => Put)
|
||||||
|
|
||||||
|
operation.httpMethod = camelize(operation.httpMethod.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove model imports to avoid error
|
||||||
|
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||||
|
if (imports == null)
|
||||||
|
return objs;
|
||||||
|
|
||||||
|
Iterator<Map<String, String>> iterator = imports.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
String _import = iterator.next().get("import");
|
||||||
|
if (_import.startsWith(apiPackage()))
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
// if the return type is not primitive, import encoding/json
|
||||||
|
for (CodegenOperation operation : operations) {
|
||||||
|
if (operation.returnBaseType != null && needToImport(operation.returnBaseType)) {
|
||||||
|
imports.add(createMapping("import", "encoding/json"));
|
||||||
|
break; // just need to import once
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// this will only import "fmt" if there are items in pathParams
|
||||||
|
for (CodegenOperation operation : operations) {
|
||||||
|
if (operation.pathParams != null && operation.pathParams.size() > 0) {
|
||||||
|
imports.add(createMapping("import", "fmt"));
|
||||||
|
break; // just need to import once
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// recursively add import for mapping one type to multiple imports
|
||||||
|
List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
|
||||||
|
if (recursiveImports == null)
|
||||||
|
return objs;
|
||||||
|
|
||||||
|
ListIterator<Map<String, String>> listIterator = imports.listIterator();
|
||||||
|
while (listIterator.hasNext()) {
|
||||||
|
String _import = listIterator.next().get("import");
|
||||||
|
// if the import package happens to be found in the importMapping
|
||||||
|
// (key)
|
||||||
|
// add the corresponding import package to the list
|
||||||
|
if (importMapping.containsKey(_import)) {
|
||||||
|
listIterator.add(createMapping("import", importMapping.get(_import)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return objs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||||
|
// remove model imports to avoid error
|
||||||
|
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
|
||||||
|
final String prefix = modelPackage();
|
||||||
|
Iterator<Map<String, String>> iterator = imports.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
String _import = iterator.next().get("import");
|
||||||
|
if (_import.startsWith(prefix))
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
// recursively add import for mapping one type to multiple imports
|
||||||
|
List<Map<String, String>> recursiveImports = (List<Map<String, String>>) objs.get("imports");
|
||||||
|
if (recursiveImports == null)
|
||||||
|
return objs;
|
||||||
|
|
||||||
|
ListIterator<Map<String, String>> listIterator = imports.listIterator();
|
||||||
|
while (listIterator.hasNext()) {
|
||||||
|
String _import = listIterator.next().get("import");
|
||||||
|
// if the import package happens to be found in the importMapping
|
||||||
|
// (key)
|
||||||
|
// add the corresponding import package to the list
|
||||||
|
if (importMapping.containsKey(_import)) {
|
||||||
|
listIterator.add(createMapping("import", importMapping.get(_import)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return objs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> postProcessAllModels(final Map<String, Object> models) {
|
||||||
|
|
||||||
|
final Map<String, Object> processed = super.postProcessAllModels(models);
|
||||||
|
postProcessParentModels(models);
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void postProcessParentModels(final Map<String, Object> models) {
|
||||||
|
for (final String parent : parentModels) {
|
||||||
|
final CodegenModel parentModel = ModelUtils.getModelByName(parent, models);
|
||||||
|
final Collection<CodegenModel> childrenModels = childrenByParent.get(parent);
|
||||||
|
for (final CodegenModel child : childrenModels) {
|
||||||
|
processParentPropertiesInChildModel(parentModel, child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the child property's isInherited flag to true if it is an inherited
|
||||||
|
* property
|
||||||
|
*/
|
||||||
|
private void processParentPropertiesInChildModel(final CodegenModel parent, final CodegenModel child) {
|
||||||
|
final Map<String, CodegenProperty> childPropertiesByName = new HashMap<>(child.vars.size());
|
||||||
|
for (final CodegenProperty childProperty : child.vars) {
|
||||||
|
childPropertiesByName.put(childProperty.name, childProperty);
|
||||||
|
}
|
||||||
|
for (final CodegenProperty parentProperty : parent.vars) {
|
||||||
|
final CodegenProperty duplicatedByParent = childPropertiesByName.get(parentProperty.name);
|
||||||
|
if (duplicatedByParent != null) {
|
||||||
|
duplicatedByParent.isInherited = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean needToImport(String type) {
|
||||||
|
return !defaultIncludes.contains(type) && !languageSpecificPrimitives.contains(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackageName(String packageName) {
|
||||||
|
this.packageName = packageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackageVersion(String packageVersion) {
|
||||||
|
this.packageVersion = packageVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeQuotationMark(String input) {
|
||||||
|
// remove " to avoid code injection
|
||||||
|
return input.replace("\"", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String escapeUnsafeCharacters(String input) {
|
||||||
|
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> createMapping(String key, String value) {
|
||||||
|
Map<String, String> customImport = new HashMap<String, String>();
|
||||||
|
customImport.put(key, value);
|
||||||
|
|
||||||
|
return customImport;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String unCamelize(String name) {
|
||||||
|
return name.replaceAll("(.)(\\p{Upper})", "$1_$2").toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toEiffelFeatureStyle(String operationId) {
|
||||||
|
if (operationId.startsWith("get_")) {
|
||||||
|
return operationId.substring(4, operationId.length());
|
||||||
|
} else {
|
||||||
|
return operationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -56,8 +56,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
"case", "defer", "go", "map", "struct",
|
"case", "defer", "go", "map", "struct",
|
||||||
"chan", "else", "goto", "package", "switch",
|
"chan", "else", "goto", "package", "switch",
|
||||||
"const", "fallthrough", "if", "range", "type",
|
"const", "fallthrough", "if", "range", "type",
|
||||||
"continue", "for", "import", "return", "var", "error", "ApiResponse",
|
"continue", "for", "import", "return", "var", "error", "ApiResponse", "nil")
|
||||||
"nil")
|
|
||||||
// Added "error" as it's used so frequently that it may as well be a keyword
|
// Added "error" as it's used so frequently that it may as well be a keyword
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
wget -nc https://nuget.org/nuget.exe;
|
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe;
|
||||||
mozroots --import --sync
|
mozroots --import --sync
|
||||||
mono nuget.exe install vendor/packages.config -o vendor;
|
mono nuget.exe install vendor/packages.config -o vendor;
|
||||||
mkdir -p bin;
|
mkdir -p bin;
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
# Eiffel API client for {{packageName}}
|
||||||
|
|
||||||
|
{{#appDescription}}
|
||||||
|
{{{appDescription}}}
|
||||||
|
{{/appDescription}}
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client.
|
||||||
|
|
||||||
|
- API version: {{appVersion}}
|
||||||
|
- Package version: {{packageVersion}}
|
||||||
|
{{^hideGenerationTimestamp}}
|
||||||
|
- Build date: {{generatedDate}}
|
||||||
|
{{/hideGenerationTimestamp}}
|
||||||
|
- Build package: {{generatorClass}}
|
||||||
|
{{#infoUrl}}
|
||||||
|
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||||
|
{{/infoUrl}}
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
Add the library into your Eiffel configuration file.
|
||||||
|
```
|
||||||
|
"<library name="api_client" location="%PATH_TO_EIFFEL_SWAGGER_CLIENT%\api_client.ecf"/>"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Documentation for API Endpoints
|
||||||
|
|
||||||
|
All URIs are relative to *{{basePath}}*
|
||||||
|
|
||||||
|
Class | Method | HTTP request | Description
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||||
|
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||||
|
|
||||||
|
## Documentation For Models
|
||||||
|
|
||||||
|
{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
|
||||||
|
{{/model}}{{/models}}
|
||||||
|
|
||||||
|
## Documentation For Authorization
|
||||||
|
|
||||||
|
{{^authMethods}} All endpoints do not require authorization.
|
||||||
|
{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
|
||||||
|
{{#authMethods}}## {{{name}}}
|
||||||
|
|
||||||
|
{{#isApiKey}}- **Type**: API key
|
||||||
|
- **API key parameter name**: {{{keyParamName}}}
|
||||||
|
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
||||||
|
{{/isApiKey}}
|
||||||
|
{{#isBasic}}- **Type**: HTTP basic authentication
|
||||||
|
{{/isBasic}}
|
||||||
|
{{#isOAuth}}- **Type**: OAuth
|
||||||
|
- **Flow**: {{{flow}}}
|
||||||
|
- **Authorization URL**: {{{authorizationUrl}}}
|
||||||
|
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
||||||
|
{{#scopes}} - **{{{scope}}}**: {{{description}}}
|
||||||
|
{{/scopes}}
|
||||||
|
{{/isOAuth}}
|
||||||
|
|
||||||
|
{{/authMethods}}
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}}
|
||||||
|
{{/hasMore}}{{/apis}}{{/apiInfo}}
|
@ -0,0 +1,75 @@
|
|||||||
|
{{>noteinfo}}
|
||||||
|
{{#operations}}
|
||||||
|
|
||||||
|
class
|
||||||
|
{{classname}}
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
API_I
|
||||||
|
|
||||||
|
|
||||||
|
feature -- API Access
|
||||||
|
|
||||||
|
{{#operation}}
|
||||||
|
|
||||||
|
{{operationId}} {{#hasParams}}({{#allParams}}{{paramName}}: {{#required}}{{{dataType}}}{{/required}}{{^required}}detachable {{{dataType}}}{{/required}}{{#hasMore}}; {{/hasMore}}{{/allParams}}){{/hasParams}}{{#returnType}}: detachable {{{returnType}}}{{/returnType}}{{^returnType}}{{/returnType}}
|
||||||
|
-- {{summary}}
|
||||||
|
-- {{notes}}
|
||||||
|
-- {{#allParams}}
|
||||||
|
-- argument: {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
|
||||||
|
-- {{/allParams}}
|
||||||
|
-- {{#returnType}}
|
||||||
|
-- Result {{returnType}}{{/returnType}}
|
||||||
|
local
|
||||||
|
l_path: STRING
|
||||||
|
l_request: API_CLIENT_REQUEST
|
||||||
|
l_response: API_CLIENT_RESPONSE
|
||||||
|
do
|
||||||
|
reset_error
|
||||||
|
create l_request
|
||||||
|
{{#bodyParam}}l_request.set_body({{paramName}}){{/bodyParam}}
|
||||||
|
l_path := "{{{path}}}"
|
||||||
|
{{#pathParams}}
|
||||||
|
l_path.replace_substring_all ("{"+"{{baseName}}"+"}", api_client.url_encode ({{{paramName}}}.out))
|
||||||
|
{{/pathParams}}
|
||||||
|
{{#queryParams}}
|
||||||
|
l_request.fill_query_params(api_client.parameter_to_tuple("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
|
||||||
|
{{/queryParams}}
|
||||||
|
{{#headerParams}}
|
||||||
|
if attached {{paramName}} as l_{{paramName}} then
|
||||||
|
l_request.add_header(l_{{paramName}}.out,"{{baseName}}");
|
||||||
|
end
|
||||||
|
{{/headerParams}}
|
||||||
|
{{#formParams}}
|
||||||
|
if attached {{paramName}} as l_{{paramName}} then
|
||||||
|
l_request.add_form(l_{{paramName}},"{{baseName}}");
|
||||||
|
end
|
||||||
|
{{/formParams}}
|
||||||
|
|
||||||
|
if attached {STRING} api_client.select_header_accept (<<{{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}>>) as l_accept then
|
||||||
|
l_request.add_header(l_accept,"Accept");
|
||||||
|
end
|
||||||
|
l_request.add_header(api_client.select_header_content_type (<<{{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}>>),"Content-Type")
|
||||||
|
l_request.set_auth_names (<<{{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}}>>)
|
||||||
|
l_response := api_client.call_api (l_path, "{{httpMethod}}", l_request, {{#returnType}}Void{{/returnType}}{{^returnType}}agent serializer{{/returnType}}, {{#returnType}}agent deserializer{{/returnType}}{{^returnType}}Void{{/returnType}})
|
||||||
|
{{#returnType}}
|
||||||
|
if l_response.has_error then
|
||||||
|
last_error := l_response.error
|
||||||
|
elseif attached { {{{returnType}}} } l_response.data ({ {{{returnType}}} }) as l_data then
|
||||||
|
Result := l_data
|
||||||
|
else
|
||||||
|
create last_error.make ("Unknown error: Status response [ " + l_response.status.out + "]")
|
||||||
|
end
|
||||||
|
{{/returnType}}
|
||||||
|
{{^returnType}}
|
||||||
|
if l_response.has_error then
|
||||||
|
last_error := l_response.error
|
||||||
|
end
|
||||||
|
{{/returnType}}
|
||||||
|
end
|
||||||
|
{{/operation}}
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
{{/operations}}
|
@ -0,0 +1,491 @@
|
|||||||
|
{{>noteInfo}}
|
||||||
|
|
||||||
|
class
|
||||||
|
API_CLIENT
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make
|
||||||
|
do
|
||||||
|
create default_header_map.make (0)
|
||||||
|
set_base_path (default_base_path)
|
||||||
|
|
||||||
|
--set default user_agent
|
||||||
|
set_user_agent("{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{artifactVersion}}}/Eiffel{{/httpUserAgent}}");
|
||||||
|
|
||||||
|
create authentications.make (3) {{#authMethods}}{{#isBasic}}
|
||||||
|
authentications.force (create {HTTP_BASIC_AUTH}, "{{name}}")
|
||||||
|
is_basic_auth_configured := True {{/isBasic}}{{#isApiKey}}
|
||||||
|
authentications.force (create {API_KEY_AUTH}.make ({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"), "{{name}}")
|
||||||
|
is_api_key_configured := True {{/isApiKey}}{{#isOAuth}}
|
||||||
|
authentications.force (create {OAUTH},"{{name}}")
|
||||||
|
is_oauth_configured := True {{/isOAuth}}{{/authMethods}}
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
default_base_path: STRING = "{{{basePath}}}"
|
||||||
|
-- default base path.
|
||||||
|
|
||||||
|
base_path: STRING
|
||||||
|
-- base path.
|
||||||
|
|
||||||
|
authentications: STRING_TABLE [AUTHENTICATION]
|
||||||
|
-- autentication table.
|
||||||
|
|
||||||
|
feature -- Status Report
|
||||||
|
|
||||||
|
is_basic_auth_configured: BOOLEAN
|
||||||
|
-- is basic auth configured.
|
||||||
|
|
||||||
|
is_api_key_configured: BOOLEAN
|
||||||
|
-- is api key auth configured.
|
||||||
|
|
||||||
|
is_oauth_configured: BOOLEAN
|
||||||
|
-- is oauth configured.
|
||||||
|
|
||||||
|
feature -- Access: Authentication
|
||||||
|
|
||||||
|
authentication_by_name (a_name: STRING): detachable AUTHENTICATION
|
||||||
|
-- Return the Authentication for the given name `a_name', Void if not found.
|
||||||
|
do
|
||||||
|
Result := authentications.at (a_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Helper: Basic Authentication
|
||||||
|
|
||||||
|
set_password (a_password: STRING_32)
|
||||||
|
-- Set basic auth `password' with `a_password'.
|
||||||
|
require
|
||||||
|
is_basic_auth_configured: is_basic_auth_configured
|
||||||
|
do
|
||||||
|
across authentications as ic loop
|
||||||
|
if attached {HTTP_BASIC_AUTH} ic.item as l_basic_auth then
|
||||||
|
l_basic_auth.set_password (a_password)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
set_username (a_username: STRING_32)
|
||||||
|
-- Set basic auth `username' with `a_username'.
|
||||||
|
require
|
||||||
|
is_basic_auth_configured: is_basic_auth_configured
|
||||||
|
do
|
||||||
|
across authentications as ic loop
|
||||||
|
if attached {HTTP_BASIC_AUTH} ic.item as l_basic_auth then
|
||||||
|
l_basic_auth.set_user_name (a_username)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Helper: Api Key Authentication
|
||||||
|
|
||||||
|
set_api_key (a_api_key: STRING_32)
|
||||||
|
-- Set `api_key' authentication key with `a_api_key'.
|
||||||
|
require
|
||||||
|
is_api_key_configured: is_api_key_configured
|
||||||
|
do
|
||||||
|
across authentications as ic loop
|
||||||
|
if attached {API_KEY_AUTH} ic.item as l_api_key then
|
||||||
|
l_api_key.set_api_key (a_api_key)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
set_api_prefix (a_api_prefix: STRING_32)
|
||||||
|
-- Set `api_key_prefix' authentication with `a_api_prefix'.
|
||||||
|
require
|
||||||
|
is_api_key_configured: is_api_key_configured
|
||||||
|
do
|
||||||
|
across authentications as ic loop
|
||||||
|
if attached {API_KEY_AUTH} ic.item as l_api_key then
|
||||||
|
l_api_key.set_api_key_prefix (a_api_prefix)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Helper: OAuth Authentication
|
||||||
|
|
||||||
|
set_access_token (a_token: STRING_32)
|
||||||
|
-- Set OAuth access token with `a_token'.
|
||||||
|
require
|
||||||
|
is_oauth_configured: is_oauth_configured
|
||||||
|
do
|
||||||
|
across authentications as ic loop
|
||||||
|
if attached {OAUTH} ic.item as l_oauth then
|
||||||
|
l_oauth.set_access_token (a_token)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Query Parameter Helpers
|
||||||
|
|
||||||
|
parameter_to_tuple (a_collection_format, a_name: STRING; a_value: ANY): LIST [TUPLE [name: STRING; value: STRING]]
|
||||||
|
-- A list of tuples with name and valule.
|
||||||
|
-- collectionFormat collection format (e.g. csv, tsv)
|
||||||
|
-- name Name
|
||||||
|
-- value Value
|
||||||
|
require
|
||||||
|
valid_name: not a_name.is_empty
|
||||||
|
local
|
||||||
|
l_format: STRING
|
||||||
|
l_delimiter: STRING
|
||||||
|
l_value: STRING
|
||||||
|
do
|
||||||
|
if attached {LIST [STRING_32]} a_value as a_list then
|
||||||
|
-- Collection
|
||||||
|
if a_list.is_empty then
|
||||||
|
-- Return an empty list
|
||||||
|
create {ARRAYED_LIST [TUPLE [name: STRING; value: STRING]]} Result.make (0)
|
||||||
|
else
|
||||||
|
-- collection format: multi, csv, ssv, tsv, pipes.
|
||||||
|
create {ARRAYED_LIST [TUPLE [name: STRING; value: STRING]]} Result.make (a_list.count)
|
||||||
|
if a_collection_format.is_empty then
|
||||||
|
l_format := "csv" -- default: csv
|
||||||
|
else
|
||||||
|
l_format := a_collection_format
|
||||||
|
end
|
||||||
|
if l_format.is_case_insensitive_equal ("multi") then
|
||||||
|
across a_list as ic loop
|
||||||
|
Result.force ([a_name, ic.item.as_string_8])
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if l_format.is_case_insensitive_equal ("csv") then
|
||||||
|
l_delimiter := ","
|
||||||
|
elseif l_format.is_case_insensitive_equal ("ssv") then
|
||||||
|
l_delimiter := " "
|
||||||
|
elseif l_format.is_case_insensitive_equal ("tsv") then
|
||||||
|
l_delimiter := "\t"
|
||||||
|
elseif l_format.is_case_insensitive_equal ("pipes") then
|
||||||
|
l_delimiter := "|"
|
||||||
|
else
|
||||||
|
l_delimiter := ","
|
||||||
|
end
|
||||||
|
across a_list as ic from create l_value.make_empty
|
||||||
|
loop
|
||||||
|
l_value.append (ic.item)
|
||||||
|
l_value.append (l_delimiter)
|
||||||
|
end
|
||||||
|
l_value.remove_tail (1)
|
||||||
|
Result.force ([a_name,l_value])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
create {ARRAYED_LIST [TUPLE [name: STRING; value: STRING]]} Result.make (1)
|
||||||
|
Result.force ([a_name,a_value.out])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
feature -- Status Report
|
||||||
|
|
||||||
|
is_valid_uri (a_uri: STRING): BOOLEAN
|
||||||
|
-- Is `a_uri' a valid uri?
|
||||||
|
local
|
||||||
|
l_uri: URI
|
||||||
|
do
|
||||||
|
create l_uri.make_from_string (a_uri)
|
||||||
|
Result := l_uri.is_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
feature --Helper: Http Client
|
||||||
|
|
||||||
|
select_header_accept (a_accept: ARRAY [STRING]): detachable STRING
|
||||||
|
-- Select the Accept header's value from the given accepts array.
|
||||||
|
do
|
||||||
|
a_accept.compare_objects
|
||||||
|
if a_accept.has ("application/json") then
|
||||||
|
Result := "application/json"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
select_header_content_type (a_content_types: ARRAY [STRING]): STRING
|
||||||
|
-- Select the Content-Type header's value from the given array.
|
||||||
|
-- at the moment `application/json'
|
||||||
|
do
|
||||||
|
a_content_types.compare_objects
|
||||||
|
if a_content_types.is_empty then
|
||||||
|
Result := "application/json"
|
||||||
|
elseif a_content_types.has ("application/json") then
|
||||||
|
Result := "application/json"
|
||||||
|
else
|
||||||
|
Result := a_content_types.at (1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
update_params_for_auth (a_auth_names: ARRAY [STRING]; a_query_params: LIST [TUPLE [name: STRING; value: STRING]]; a_header_params: STRING_TABLE [STRING] )
|
||||||
|
-- Update query and header parameters based on authentication settings.
|
||||||
|
-- a_auth_names:The authentications to apply.
|
||||||
|
-- a_queryParams List of query parameters.
|
||||||
|
-- a_headerParams Map of header parameters
|
||||||
|
do
|
||||||
|
across a_auth_names as ic loop
|
||||||
|
if attached authentications.at (ic.item) as l_auth then
|
||||||
|
l_auth.apply_to_params (a_query_params, a_header_params)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
accepts_request_body (a_method: STRING): BOOLEAN
|
||||||
|
-- Does the method `a_method' accepts a request body?
|
||||||
|
do
|
||||||
|
if
|
||||||
|
a_method.is_case_insensitive_equal_general ("POST") or else
|
||||||
|
a_method.is_case_insensitive_equal_general ("PUT") or else
|
||||||
|
a_method.is_case_insensitive_equal_general ("PATCH") or else
|
||||||
|
a_method.is_case_insensitive_equal_general ("DELETE")
|
||||||
|
then
|
||||||
|
Result := True
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
url_encode (a_val: STRING): STRING
|
||||||
|
-- Url encode `a_val'
|
||||||
|
do
|
||||||
|
Result := (create {URL_ENCODER}).encoded_string (a_val)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- HTTP client: call api
|
||||||
|
|
||||||
|
call_api (a_path: STRING_8; a_method: STRING_8; a_request: API_CLIENT_REQUEST; a_serializer: detachable FUNCTION [TUPLE [STRING, ANY], STRING]; a_deserializer: detachable FUNCTION [TUPLE [STRING, STRING, TYPE [detachable ANY]], detachable ANY] ): API_CLIENT_RESPONSE
|
||||||
|
-- Execute an HTTP request with the given options.
|
||||||
|
-- Relative path `a_path'
|
||||||
|
-- Method `a_method' "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
|
||||||
|
-- A request `a_request' wth
|
||||||
|
-- The query parameters: `query_params'.
|
||||||
|
-- The Header parameters: `header_params'.
|
||||||
|
-- The Request Body: `body' could be Void, object to be serialized using the serializer function `a_serializer' with a given content_type.
|
||||||
|
-- this function will need to be added by the user with the supported content types in the target API class.
|
||||||
|
-- The authentications to apply `auth_names'.
|
||||||
|
-- `a_deserializer': is a deserializer function that will need to be added by the user to map the string response to the target object with
|
||||||
|
-- with a content type.
|
||||||
|
|
||||||
|
local
|
||||||
|
l_url: STRING_8
|
||||||
|
l_response: HTTP_CLIENT_RESPONSE
|
||||||
|
l_context_executor: HTTP_CLIENT_REQUEST_CONTEXT
|
||||||
|
l_content_type: STRING
|
||||||
|
l_error: API_ERROR
|
||||||
|
do
|
||||||
|
--! TODO remove hardcoded values!!!.
|
||||||
|
--! Maybe we can create an object REQUEST_PARAMETERS
|
||||||
|
-- call_api (a_param: REQUEST_PARAMETERS)
|
||||||
|
|
||||||
|
-- create context executor per request.
|
||||||
|
create l_context_executor.make
|
||||||
|
update_params_for_auth (a_request.auth_names, a_request.query_params, a_request.header_params)
|
||||||
|
l_url := build_url (a_path, a_request.query_params)
|
||||||
|
add_header_params (l_context_executor, a_request.header_params)
|
||||||
|
|
||||||
|
if attached a_request.header_params.at ("Content-Type") as ll_content_type then
|
||||||
|
l_content_type := ll_content_type
|
||||||
|
else
|
||||||
|
l_content_type := "application/json"
|
||||||
|
end
|
||||||
|
|
||||||
|
if not accepts_request_body (a_method) then
|
||||||
|
-- do nothing
|
||||||
|
elseif l_content_type.is_case_insensitive_equal ("application/x-www-form-urlencoded") then
|
||||||
|
add_form_data (l_context_executor, a_request.form_params)
|
||||||
|
elseif l_content_type.is_case_insensitive_equal ("multipart/form-data") then
|
||||||
|
-- add_mulipart_data (l_context_executor, a_form_params, l_content_type)
|
||||||
|
-- here we need a way to identify files.
|
||||||
|
elseif a_request.body = Void then
|
||||||
|
if a_method.is_case_insensitive_equal ("DELETE") then
|
||||||
|
-- DELETE no need a request body.
|
||||||
|
else
|
||||||
|
-- use an empty request body (for POST, PUT and PATCH)
|
||||||
|
l_context_executor.set_upload_data ("")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if
|
||||||
|
attached a_request.body as l_body and then
|
||||||
|
attached a_serializer as l_custom_serializer
|
||||||
|
then
|
||||||
|
-- Serialize an object `a_body' to content-type `l_type'
|
||||||
|
-- if not support by default you will need to extend
|
||||||
|
-- the target API with the corresponding implementation.
|
||||||
|
l_context_executor.set_upload_data((create {API_SERIALIZER}).serializer (l_custom_serializer, l_content_type, l_body))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if
|
||||||
|
a_method.is_case_insensitive_equal ("GET")
|
||||||
|
then
|
||||||
|
l_response := execute_get (l_context_executor, l_url)
|
||||||
|
elseif a_method.is_case_insensitive_equal ("POST") then
|
||||||
|
l_response := execute_post (l_context_executor, l_url, Void)
|
||||||
|
else
|
||||||
|
create l_error.make ("Method [" + a_method + "] not supported")
|
||||||
|
create Result.make (l_response, l_error, a_deserializer)
|
||||||
|
end
|
||||||
|
create Result.make (l_response, l_error, a_deserializer)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
build_url (a_path: STRING_8; a_query_params: LIST [TUPLE [name: STRING; value: STRING]]): STRING_8
|
||||||
|
-- Build a relatative url to `base_path' with `a_path' and a list of
|
||||||
|
-- query parameters `a_query_params'.
|
||||||
|
local
|
||||||
|
l_query: STRING
|
||||||
|
do
|
||||||
|
if a_query_params.is_empty then
|
||||||
|
Result := a_path
|
||||||
|
else
|
||||||
|
Result := a_path
|
||||||
|
create l_query.make_empty
|
||||||
|
across a_query_params as ic loop
|
||||||
|
l_query.append (ic.item.name)
|
||||||
|
l_query.append_character ('=')
|
||||||
|
l_query.append (ic.item.value)
|
||||||
|
l_query.append_character ('&')
|
||||||
|
end
|
||||||
|
l_query.remove_tail (1)
|
||||||
|
if Result.has ('?') then
|
||||||
|
Result.append_character ('&')
|
||||||
|
Result.append (l_query)
|
||||||
|
else
|
||||||
|
Result.append_character ('?')
|
||||||
|
Result.append (l_query)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
add_header_params (a_content_executor:HTTP_CLIENT_REQUEST_CONTEXT; a_header_params: STRING_TABLE [STRING])
|
||||||
|
-- Set header parameters `a_header_params' to the request context executor `a_content_executor', including default headers.
|
||||||
|
do
|
||||||
|
-- headers
|
||||||
|
across a_header_params as ic loop
|
||||||
|
a_content_executor.add_header (ic.key.as_string_8, ic.item)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- default headers
|
||||||
|
across default_header_map as ic loop
|
||||||
|
if not a_header_params.has (ic.key) then
|
||||||
|
a_content_executor.add_header (ic.key.as_string_8, ic.item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
add_form_data (a_content_executor:HTTP_CLIENT_REQUEST_CONTEXT; a_form_params: STRING_TABLE [ANY])
|
||||||
|
-- Set form parameters `a_form_params' to the request context executor `a_content_executor'.
|
||||||
|
do
|
||||||
|
-- form params
|
||||||
|
across a_form_params as ic loop
|
||||||
|
if attached {STRING} ic.item as l_item then
|
||||||
|
a_content_executor.add_form_parameter (ic.key, l_item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
add_multipart_data (a_content_executor:HTTP_CLIENT_REQUEST_CONTEXT; a_form_params: STRING_TABLE [ANY]; a_content_type: STRING)
|
||||||
|
-- Set form parameters `a_form_params' to the request context executor `a_content_executor'.
|
||||||
|
do
|
||||||
|
-- multipart form params
|
||||||
|
across a_form_params as ic loop
|
||||||
|
if attached {FILE} ic.item as l_item then
|
||||||
|
a_content_executor.add_header ("Content-Type", a_content_type )
|
||||||
|
a_content_executor.set_upload_filename (l_item.path.absolute_path.name)
|
||||||
|
a_content_executor.add_form_parameter (ic.key, l_item.path.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- HTTP client: Change Element
|
||||||
|
|
||||||
|
set_base_path (a_path: STRING)
|
||||||
|
-- Set `base_path' with `a_path'.
|
||||||
|
require
|
||||||
|
is_valid_uri: is_valid_uri (a_path)
|
||||||
|
do
|
||||||
|
base_path := a_path
|
||||||
|
end
|
||||||
|
|
||||||
|
set_user_agent (a_agent: STRING_8)
|
||||||
|
-- Set user agent with `a_agent`.
|
||||||
|
do
|
||||||
|
add_header ("User-Agent", a_agent)
|
||||||
|
end
|
||||||
|
|
||||||
|
add_header (k: READABLE_STRING_8; v: READABLE_STRING_8)
|
||||||
|
-- Add http header line `k:v'.
|
||||||
|
do
|
||||||
|
default_header_map.force (v, k)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
|
default_header_map: STRING_TABLE [STRING]
|
||||||
|
-- default header map.
|
||||||
|
|
||||||
|
http_session: detachable HTTP_CLIENT_SESSION
|
||||||
|
-- http client session.
|
||||||
|
|
||||||
|
get_http_session
|
||||||
|
-- Initialize http client session.
|
||||||
|
local
|
||||||
|
h: DEFAULT_HTTP_CLIENT
|
||||||
|
b: like base_path
|
||||||
|
do
|
||||||
|
create h
|
||||||
|
b := base_path
|
||||||
|
if b = Void then
|
||||||
|
b := ""
|
||||||
|
end
|
||||||
|
b.left_adjust
|
||||||
|
b.right_justify
|
||||||
|
if attached {HTTP_CLIENT_SESSION} h.new_session (b) as sess then
|
||||||
|
http_session := sess
|
||||||
|
sess.set_timeout (-1)
|
||||||
|
sess.set_connect_timeout (-1)
|
||||||
|
sess.set_is_insecure (True)
|
||||||
|
sess.set_any_auth_type
|
||||||
|
debug ("curl")
|
||||||
|
sess.set_is_debug (True)
|
||||||
|
end
|
||||||
|
debug ("proxy8888")
|
||||||
|
sess.set_proxy ("127.0.0.1", 8888) --| inspect traffic with http://www.fiddler2.com/
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- HTTP client helpers
|
||||||
|
|
||||||
|
execute_get (context_executor: HTTP_CLIENT_REQUEST_CONTEXT; command_name: READABLE_STRING_8): detachable HTTP_CLIENT_RESPONSE
|
||||||
|
do
|
||||||
|
get_http_session
|
||||||
|
if attached http_session as sess then
|
||||||
|
Result := sess.get (command_name, context_executor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
execute_post (context_executor: HTTP_CLIENT_REQUEST_CONTEXT; command_name: READABLE_STRING_8; data: detachable READABLE_STRING_8): detachable HTTP_CLIENT_RESPONSE
|
||||||
|
do
|
||||||
|
get_http_session
|
||||||
|
if attached http_session as sess then
|
||||||
|
Result := sess.post (command_name, context_executor, data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
execute_delete (context_executor: HTTP_CLIENT_REQUEST_CONTEXT; command_name: READABLE_STRING_8): detachable HTTP_CLIENT_RESPONSE
|
||||||
|
do
|
||||||
|
get_http_session
|
||||||
|
if attached http_session as sess then
|
||||||
|
Result := sess.delete (command_name, context_executor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
execute_put (context_executor: HTTP_CLIENT_REQUEST_CONTEXT; command_name: READABLE_STRING_8; data: detachable READABLE_STRING_8): detachable HTTP_CLIENT_RESPONSE
|
||||||
|
do
|
||||||
|
get_http_session
|
||||||
|
if attached http_session as sess then
|
||||||
|
Result := sess.put (command_name, context_executor, data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,45 @@
|
|||||||
|
# {{classname}}{{#description}}
|
||||||
|
{{description}}{{/description}}
|
||||||
|
|
||||||
|
All URIs are relative to *{{basePath}}*
|
||||||
|
|
||||||
|
Feature | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||||
|
{{/operation}}{{/operations}}
|
||||||
|
|
||||||
|
{{#operations}}
|
||||||
|
{{#operation}}
|
||||||
|
# **{{{operationId}}}**
|
||||||
|
> {{operationId}} {{#hasParams}}({{#allParams}}{{paramName}}: {{#required}}{{{dataType}}}{{/required}}{{^required}} detachable {{{dataType}}}{{/required}} {{#hasMore}}; {{/hasMore}}{{/allParams}}){{/hasParams}}{{#returnType}}: detachable {{{returnType}}}{{/returnType}}{{^returnType}}{{/returnType}}
|
||||||
|
|
||||||
|
|
||||||
|
{{{summary}}}{{#notes}}
|
||||||
|
|
||||||
|
{{{notes}}}{{/notes}}
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
|
||||||
|
{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
|
||||||
|
{{/allParams}}
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}{empty response body){{/returnType}}
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
|
||||||
|
- **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
{{/operation}}
|
||||||
|
{{/operations}}
|
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-16-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-16-0 http://www.eiffel.com/developers/xml/configuration-1-16-0.xsd" name="{{libraryTarget}}" uuid="{{uuid}}" library_target="{{libraryTarget}}">
|
||||||
|
<target name="{{libraryTarget}}">
|
||||||
|
<root all_classes="true"/>
|
||||||
|
<file_rule>
|
||||||
|
<exclude>/\.git$</exclude>
|
||||||
|
<exclude>/\.svn$</exclude>
|
||||||
|
<exclude>/CVS$</exclude>
|
||||||
|
<exclude>/EIFGENs$</exclude>
|
||||||
|
</file_rule>
|
||||||
|
<option warning="true">
|
||||||
|
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||||
|
</option>
|
||||||
|
<setting name="console_application" value="true"/>
|
||||||
|
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
|
||||||
|
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf"/>
|
||||||
|
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||||
|
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
||||||
|
<library name="http_client" location="$ISE_LIBRARY\contrib\library\network\http_client\http_client-safe.ecf"/>
|
||||||
|
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||||
|
<library name="uri" location="$ISE_LIBRARY\library\text\uri\uri-safe.ecf"/>
|
||||||
|
<cluster name="client" location=".\src" recursive="true"/>
|
||||||
|
</target>
|
||||||
|
</system>
|
@ -0,0 +1,79 @@
|
|||||||
|
{{>noteinfo}}
|
||||||
|
|
||||||
|
class
|
||||||
|
API_CLIENT_REQUEST
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
ANY
|
||||||
|
redefine
|
||||||
|
default_create
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
default_create
|
||||||
|
do
|
||||||
|
create {ARRAYED_LIST [TUPLE [name: STRING; value: STRING]]} query_params.make (0)
|
||||||
|
create header_params.make (0)
|
||||||
|
create form_params.make (0)
|
||||||
|
create auth_names.make_empty
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
query_params: LIST [TUPLE [name: STRING; value: STRING]]
|
||||||
|
-- List of query parameters as a pair name, value.
|
||||||
|
|
||||||
|
header_params: STRING_TABLE [STRING]
|
||||||
|
-- table of header parameters.
|
||||||
|
|
||||||
|
form_params: STRING_TABLE [ANY]
|
||||||
|
-- table of form parameters.
|
||||||
|
|
||||||
|
body: detachable ANY
|
||||||
|
-- The request body object.
|
||||||
|
|
||||||
|
auth_names: ARRAY [STRING]
|
||||||
|
-- The authentications to apply .
|
||||||
|
|
||||||
|
feature -- Change Element
|
||||||
|
|
||||||
|
fill_query_params (a_params: like query_params)
|
||||||
|
-- Fill all of the elements in the specified list `a_params' to the end of
|
||||||
|
-- `query_params'.
|
||||||
|
do
|
||||||
|
query_params.fill (a_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
add_header (new: STRING; key: READABLE_STRING_GENERAL)
|
||||||
|
-- Update `header_params' so that `new' will be the item associated
|
||||||
|
-- with `key'.
|
||||||
|
do
|
||||||
|
header_params.force (new, key)
|
||||||
|
end
|
||||||
|
|
||||||
|
add_form (new: ANY; key: READABLE_STRING_GENERAL)
|
||||||
|
-- Update `form_params' so that `new' will be the item associated
|
||||||
|
-- with `key'.
|
||||||
|
do
|
||||||
|
form_params.force (new, key)
|
||||||
|
end
|
||||||
|
|
||||||
|
set_body (a_body: like body)
|
||||||
|
-- Set 'body' with 'a_body'.
|
||||||
|
do
|
||||||
|
body := a_body
|
||||||
|
ensure
|
||||||
|
body_set: body = a_body
|
||||||
|
end
|
||||||
|
|
||||||
|
set_auth_names (a_auth_names: like auth_names)
|
||||||
|
-- Set 'auth_names' with 'a_auth_names'.
|
||||||
|
do
|
||||||
|
auth_names := a_auth_names
|
||||||
|
ensure
|
||||||
|
auth_names_set: auth_names = a_auth_names
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,61 @@
|
|||||||
|
{{>noteinfo}}
|
||||||
|
class
|
||||||
|
API_CLIENT_RESPONSE
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make (a_response: detachable HTTP_CLIENT_RESPONSE; a_error: detachable API_ERROR; a_custom_deserializer: detachable FUNCTION [TUPLE [STRING, STRING, TYPE [detachable ANY]], detachable ANY])
|
||||||
|
do
|
||||||
|
response := a_response
|
||||||
|
error := a_error
|
||||||
|
deserializer := a_custom_deserializer
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
has_error: BOOLEAN
|
||||||
|
-- has error?
|
||||||
|
do
|
||||||
|
Result := response = Void and then attached error
|
||||||
|
end
|
||||||
|
|
||||||
|
status: INTEGER
|
||||||
|
do
|
||||||
|
if attached response as l_response then
|
||||||
|
Result := l_response.status
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Data
|
||||||
|
|
||||||
|
data (a_type: TYPE [detachable ANY]): detachable ANY
|
||||||
|
-- Data representation of the HTTP Response
|
||||||
|
do
|
||||||
|
if
|
||||||
|
attached response as l_response and then
|
||||||
|
attached deserializer as l_deserializer and then
|
||||||
|
attached l_response.body as l_body and then
|
||||||
|
attached l_response.header ("Content-Type") as l_content_type
|
||||||
|
then
|
||||||
|
Result := (create {API_DESERIALIZER}).deserializer (l_deserializer, l_content_type, l_body, a_type)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Error
|
||||||
|
|
||||||
|
error: detachable API_ERROR
|
||||||
|
-- Internal client error.
|
||||||
|
|
||||||
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
|
response: detachable HTTP_CLIENT_RESPONSE
|
||||||
|
-- Low level response returned by the API call.
|
||||||
|
|
||||||
|
deserializer: detachable FUNCTION [TUPLE [STRING, STRING, TYPE [detachable ANY]], detachable ANY]
|
||||||
|
-- function to map a response body with a given content type to the target
|
||||||
|
-- in the domain model.
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,23 @@
|
|||||||
|
{{>noteinfo}}
|
||||||
|
|
||||||
|
class
|
||||||
|
API_ERROR
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make (a_error: READABLE_STRING_GENERAL)
|
||||||
|
do
|
||||||
|
error := a_error
|
||||||
|
ensure
|
||||||
|
error_set: error = a_error
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
error: READABLE_STRING_GENERAL
|
||||||
|
-- Error generated by the API call.
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,99 @@
|
|||||||
|
{{>noteinfo}}
|
||||||
|
|
||||||
|
class API_I
|
||||||
|
|
||||||
|
inherit ANY redefine default_create end
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
default_create
|
||||||
|
-- Initialize USER_API with default api_client.
|
||||||
|
do
|
||||||
|
api_client := (create {CONFIGURATION}).default_api_client
|
||||||
|
end
|
||||||
|
|
||||||
|
make (a_client: API_CLIENT)
|
||||||
|
-- Initialize USER_API with `api_client' `a_client'.
|
||||||
|
do
|
||||||
|
api_client := a_client
|
||||||
|
end
|
||||||
|
|
||||||
|
api_client: API_CLIENT
|
||||||
|
-- Api client.
|
||||||
|
|
||||||
|
feature -- Status Report
|
||||||
|
|
||||||
|
last_error: detachable API_ERROR
|
||||||
|
-- last error if any from the API call.
|
||||||
|
|
||||||
|
feature -- Error
|
||||||
|
|
||||||
|
reset_error
|
||||||
|
-- reset `last_error' to void.
|
||||||
|
do
|
||||||
|
last_error := Void
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
feature -- Serializer
|
||||||
|
|
||||||
|
serializer (a_content_type: STRING; a_object: ANY): STRING
|
||||||
|
-- Serializer object `a_object' with content type `a_content_type'.
|
||||||
|
-- Return the serialized object or report an error if
|
||||||
|
-- the serialization failed (ie, not supported, etc).
|
||||||
|
local
|
||||||
|
err: DEVELOPER_EXCEPTION
|
||||||
|
do
|
||||||
|
-- Serialized to be coded by a user.
|
||||||
|
-- Add the support content types
|
||||||
|
create Result.make_empty
|
||||||
|
if a_content_type.is_case_insensitive_equal_general ("application/json") then
|
||||||
|
Result := json_serializer (a_object)
|
||||||
|
else
|
||||||
|
-- Add your new serializer here.
|
||||||
|
--! we have two options
|
||||||
|
--! raise a developer exception.
|
||||||
|
--! media type not supported!!!.
|
||||||
|
--! or we create an object instance of API_ERROR.
|
||||||
|
create err
|
||||||
|
err.set_description ("Content type [" + a_content_type + "] not supported.")
|
||||||
|
err.raise
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
json_serializer (a_object: ANY): STRING
|
||||||
|
-- Convert object `a_object' to JSON represented as STRING.
|
||||||
|
local
|
||||||
|
l_json: API_JSON_SERIALIZER
|
||||||
|
do
|
||||||
|
Result := l_json.to_json_string (a_object)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Deserializer
|
||||||
|
|
||||||
|
|
||||||
|
deserializer (a_content_type: STRING; a_body: STRING; a_type: TYPE [detachable ANY]): detachable ANY
|
||||||
|
-- Deserialize a representation `a_body' with content type `a_content_type'.
|
||||||
|
-- Return an object of type target if it's possible.
|
||||||
|
local
|
||||||
|
err: DEVELOPER_EXCEPTION
|
||||||
|
do
|
||||||
|
if a_content_type.is_case_insensitive_equal_general ("application/json") then
|
||||||
|
Result := json_deserializer (a_body, a_type)
|
||||||
|
else
|
||||||
|
create err
|
||||||
|
err.set_description ("Deserialization is not supported by default you will need to add it by hand.")
|
||||||
|
err.raise
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
json_deserializer (a_body: STRING; a_type: TYPE [detachable ANY]): detachable ANY
|
||||||
|
-- Deserialize body 'a_body' to json to the target type 'a_type'.
|
||||||
|
local
|
||||||
|
l_json: API_JSON_DESERIALIZER
|
||||||
|
do
|
||||||
|
Result := l_json.from_json (a_body, a_type)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,64 @@
|
|||||||
|
{{>noteinfo}}
|
||||||
|
class
|
||||||
|
API_KEY_AUTH
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
AUTHENTICATION
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make (a_location: STRING; a_param_name: STRING)
|
||||||
|
do
|
||||||
|
location := a_location
|
||||||
|
param_name := a_param_name
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
location: STRING
|
||||||
|
param_name: STRING
|
||||||
|
|
||||||
|
api_key: detachable STRING_32
|
||||||
|
api_key_prefix: detachable STRING_32
|
||||||
|
|
||||||
|
feature -- Change Element
|
||||||
|
|
||||||
|
set_api_key (a_api_key: STRING_32)
|
||||||
|
-- Set `api_key' with `a_api_key'.
|
||||||
|
do
|
||||||
|
api_key := a_api_key
|
||||||
|
ensure
|
||||||
|
api_key_set: api_key = a_api_key
|
||||||
|
end
|
||||||
|
|
||||||
|
set_api_key_prefix (a_api_key_prefix: STRING_32)
|
||||||
|
-- Set `api_key_prefix' with `a_api_key_prefix'.
|
||||||
|
do
|
||||||
|
api_key_prefix := a_api_key_prefix
|
||||||
|
ensure
|
||||||
|
api_key_prefix_set: api_key_prefix = a_api_key_prefix
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
apply_to_params(a_query_params: LIST [TUPLE [name:STRING; value:STRING]]; a_header_params: STRING_TABLE [STRING])
|
||||||
|
-- <Precursor>.
|
||||||
|
local
|
||||||
|
l_value: STRING_32
|
||||||
|
do
|
||||||
|
if attached api_key as l_api_key then
|
||||||
|
if attached api_key_prefix as l_api_key_prefix then
|
||||||
|
create l_value.make_from_string (l_api_key_prefix)
|
||||||
|
l_value.append_string (" ")
|
||||||
|
l_value.append_string (l_api_key)
|
||||||
|
else
|
||||||
|
create l_value.make_from_string (l_api_key)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,15 @@
|
|||||||
|
{{>noteInfo}}
|
||||||
|
|
||||||
|
deferred class
|
||||||
|
AUTHENTICATION
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
apply_to_params(a_query_params: LIST [TUPLE [name:STRING; value:STRING]]; a_header_params: STRING_TABLE [STRING])
|
||||||
|
-- Apply authentication settings to header and query params.
|
||||||
|
-- `a_query_params' List of query parameters.
|
||||||
|
-- `a_header_params' Map of header parameters.
|
||||||
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,49 @@
|
|||||||
|
{{>noteinfo}}
|
||||||
|
|
||||||
|
class
|
||||||
|
HTTP_BASIC_AUTH
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
AUTHENTICATION
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
user_name: detachable STRING_32
|
||||||
|
-- user name.
|
||||||
|
|
||||||
|
password: detachable STRING_32
|
||||||
|
-- password.
|
||||||
|
|
||||||
|
feature -- Element Change
|
||||||
|
|
||||||
|
set_user_name (a_name: STRING_32)
|
||||||
|
-- Set `user_name' with `a_name'.
|
||||||
|
do
|
||||||
|
user_name := a_name
|
||||||
|
ensure
|
||||||
|
user_name_set: user_name = a_name
|
||||||
|
end
|
||||||
|
|
||||||
|
set_password (a_password: STRING_32)
|
||||||
|
-- Set `password' with `a_password'.
|
||||||
|
do
|
||||||
|
password := a_password
|
||||||
|
ensure
|
||||||
|
password_set: password = a_password
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
apply_to_params(a_query_params: LIST [TUPLE [name:STRING; value:STRING]]; a_header_params: STRING_TABLE [STRING])
|
||||||
|
-- <Precursor>.
|
||||||
|
do
|
||||||
|
if
|
||||||
|
attached user_name as l_username and then
|
||||||
|
attached password as l_password
|
||||||
|
then
|
||||||
|
a_header_params.force ("Basic " + (create {BASE64}).encoded_string (l_username + ":" + l_password) , "Authorization")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,30 @@
|
|||||||
|
{{>noteinfo}}
|
||||||
|
class
|
||||||
|
OAUTH
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
AUTHENTICATION
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
access_token: detachable STRING_32
|
||||||
|
|
||||||
|
feature -- Change Element
|
||||||
|
|
||||||
|
set_access_token (a_token: STRING_32)
|
||||||
|
-- Set `access_token' with `a_token'.
|
||||||
|
do
|
||||||
|
access_token := a_token
|
||||||
|
ensure
|
||||||
|
access_token_set: access_token = a_token
|
||||||
|
end
|
||||||
|
|
||||||
|
apply_to_params(a_query_params: LIST [TUPLE [name:STRING; value:STRING]]; a_header_params: STRING_TABLE [STRING])
|
||||||
|
-- <Precursor>.
|
||||||
|
do
|
||||||
|
if attached access_token as l_access_token then
|
||||||
|
a_header_params.force ("Bearer " + l_access_token,"Authorization" )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,12 @@
|
|||||||
|
{{>noteinfo}}
|
||||||
|
|
||||||
|
class
|
||||||
|
CONFIGURATION
|
||||||
|
|
||||||
|
feature -- API client
|
||||||
|
|
||||||
|
default_api_client: API_CLIENT
|
||||||
|
do
|
||||||
|
create Result.make
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,13 @@
|
|||||||
|
{{>noteinfo}}
|
||||||
|
|
||||||
|
class
|
||||||
|
API_DESERIALIZER
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
deserializer (f: FUNCTION [TUPLE [content_type:STRING; body:STRING; type:TYPE [detachable ANY]], detachable ANY]; a_content_type: STRING; a_body: STRING; a_type:TYPE [detachable ANY]): detachable ANY
|
||||||
|
-- -- From a given response deserialize body `a_body' with conent_type `a_content_type' to a target object of type `a_type'.
|
||||||
|
do
|
||||||
|
Result := f.item ([a_content_type, a_body, a_type])
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,173 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
Object Helper to deserialize a string in JSON format to an object in the domain model
|
||||||
|
How to write a converter. Suppose we have the following class
|
||||||
|
|
||||||
|
PERSON
|
||||||
|
id: INTEGER_64
|
||||||
|
name: STRING
|
||||||
|
address: ADDRESS
|
||||||
|
hobbies: LIST [STRING]
|
||||||
|
photos: LIST [PHOTOS]
|
||||||
|
|
||||||
|
convertion:
|
||||||
|
First go to the feature from_json_to_`model' and then start to set
|
||||||
|
the object attibures as follow.
|
||||||
|
|
||||||
|
STRING, INTEGER, etc use the following pattern
|
||||||
|
|
||||||
|
Result.set_id (integer_64_value_from_json (a_json, "id"))
|
||||||
|
Result.set_name (string_value_from_json (a_json, "name"))
|
||||||
|
|
||||||
|
OBJECTS
|
||||||
|
When you have an attribute that's an object itself (part of the domain) you will need to first
|
||||||
|
get JSON_OBJECT to the corresponding attribute and then use the related feature
|
||||||
|
`from_json_to_model' in this case from_json_to_address (l_address)
|
||||||
|
|
||||||
|
if attached {JSON_OBJECT} json_value (a_json, "address") as l_address then
|
||||||
|
Result.set_address(from_json_to_address (l_address))
|
||||||
|
end
|
||||||
|
|
||||||
|
LIST [STRING] or other simple types.
|
||||||
|
|
||||||
|
In the case of a list of string we need to do something similar but we need to traverse the array
|
||||||
|
We will need a local variable to build the lists.
|
||||||
|
|
||||||
|
if attached {JSON_ARRAY} json_value (a_json, "hobbies") as l_array then
|
||||||
|
create {ARRAYED_LIST [STRING]} l_hobbies.make (l_array.count)
|
||||||
|
across l_array as ic loop
|
||||||
|
if attached {JSON_STRING} ic.item as l_value then
|
||||||
|
l_hobbies.force (l_value.unescaped_string_8)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Result.set_hobbies (l_hobbies)
|
||||||
|
end
|
||||||
|
|
||||||
|
LIST [PHOTOS]
|
||||||
|
This case is similar to the previous, but in this case the element is
|
||||||
|
an object, so we will need to use the feature `from_json_to_model', here
|
||||||
|
we again need a local variable to build a temporary list of photos.
|
||||||
|
|
||||||
|
if attached {JSON_ARRAY} json_value (a_json, "photos") as l_array then
|
||||||
|
create {ARRAYED_LIST [PHOTOS]} l_photos.make (l_array.count)
|
||||||
|
across
|
||||||
|
l_array as ic
|
||||||
|
loop
|
||||||
|
l_photos.force (from_json_to_photos (ic.item))
|
||||||
|
end
|
||||||
|
Result.set_photos (l_photos)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
]"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
API_JSON_DESERIALIZER
|
||||||
|
|
||||||
|
feature -- Factories
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
feature {NONE} -- Deserialization
|
||||||
|
|
||||||
|
|
||||||
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
|
parsed_json (a_json_text: STRING): detachable JSON_VALUE
|
||||||
|
local
|
||||||
|
j: JSON_PARSER
|
||||||
|
do
|
||||||
|
create j.make_with_string (a_json_text)
|
||||||
|
j.parse_content
|
||||||
|
Result := j.parsed_json_value
|
||||||
|
end
|
||||||
|
|
||||||
|
json_value (a_json_data: detachable JSON_VALUE; a_id: STRING): detachable JSON_VALUE
|
||||||
|
local
|
||||||
|
l_id: JSON_STRING
|
||||||
|
l_ids: LIST [STRING]
|
||||||
|
do
|
||||||
|
Result := a_json_data
|
||||||
|
if Result /= Void then
|
||||||
|
if a_id /= Void and then not a_id.is_empty then
|
||||||
|
from
|
||||||
|
l_ids := a_id.split ('.')
|
||||||
|
l_ids.start
|
||||||
|
until
|
||||||
|
l_ids.after or Result = Void
|
||||||
|
loop
|
||||||
|
create l_id.make_from_string (l_ids.item)
|
||||||
|
if attached {JSON_OBJECT} Result as v_data then
|
||||||
|
if v_data.has_key (l_id) then
|
||||||
|
Result := v_data.item (l_id)
|
||||||
|
else
|
||||||
|
Result := Void
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Result := Void
|
||||||
|
end
|
||||||
|
l_ids.forth
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
integer_value_from_json (a_json_data: detachable JSON_VALUE; a_id: STRING): INTEGER
|
||||||
|
do
|
||||||
|
if attached {JSON_NUMBER} json_value (a_json_data, a_id) as v and then v.numeric_type = v.integer_type then
|
||||||
|
Result := v.item.to_integer
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
integer_64_value_from_json (a_json_data: detachable JSON_VALUE; a_id: STRING): INTEGER_64
|
||||||
|
do
|
||||||
|
if attached {JSON_NUMBER} json_value (a_json_data, a_id) as v and then v.is_number then
|
||||||
|
Result := v.integer_64_item
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
real_value_from_json (a_json_data: detachable JSON_VALUE; a_id: STRING): REAL
|
||||||
|
do
|
||||||
|
if attached {JSON_NUMBER} json_value (a_json_data, a_id) as v and then v.numeric_type = v.real_type then
|
||||||
|
Result := v.item.to_real
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
boolean_value_from_json (a_json_data: detachable JSON_VALUE; a_id: STRING): BOOLEAN
|
||||||
|
do
|
||||||
|
if attached {JSON_BOOLEAN} json_value (a_json_data, a_id) as v then
|
||||||
|
Result := v.item
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
string_value_from_json (a_json_data: detachable JSON_VALUE; a_id: STRING): detachable STRING
|
||||||
|
do
|
||||||
|
if attached {JSON_STRING} json_value (a_json_data, a_id) as v then
|
||||||
|
Result := v.item
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
string32_value_from_json (a_json_data: detachable JSON_VALUE; a_id: STRING): detachable STRING_32
|
||||||
|
do
|
||||||
|
if attached {JSON_STRING} json_value (a_json_data, a_id) as v then
|
||||||
|
Result := v.unescaped_string_32
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
unescaped_string_8_value_from_json (a_json_data: detachable JSON_VALUE; a_id: STRING): detachable STRING_8
|
||||||
|
do
|
||||||
|
if attached {JSON_STRING} json_value (a_json_data, a_id) as v then
|
||||||
|
Result := v.unescaped_string_8
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
integer_tuple_value_from_json (a_json_data: detachable JSON_VALUE; a_id: STRING): detachable TUPLE [INTEGER, INTEGER]
|
||||||
|
do
|
||||||
|
if attached {JSON_ARRAY} json_value (a_json_data, a_id) as v and then v.count = 2 and then attached {JSON_NUMBER} v.i_th (1) as l_index_1 and then attached {JSON_NUMBER} v.i_th (2) as l_index_2 and then l_index_1.numeric_type = l_index_1.integer_type and then l_index_2.numeric_type = l_index_2.integer_type then
|
||||||
|
Result := [l_index_1.item.to_integer, l_index_2.item.to_integer]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,22 @@
|
|||||||
|
{{>noteinfo}}
|
||||||
|
|
||||||
|
expanded class
|
||||||
|
API_JSON_DESERIALIZER
|
||||||
|
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
from_json (a_val:STRING; a_type: TYPE [detachable ANY] ): detachable ANY
|
||||||
|
-- Deserialize a a json representation `a_val' to an object
|
||||||
|
-- of type `a_type'
|
||||||
|
local
|
||||||
|
conv_from: JSON_BASIC_REFLECTOR_DESERIALIZER
|
||||||
|
ctx_deser: detachable JSON_DESERIALIZER_CONTEXT
|
||||||
|
do
|
||||||
|
create conv_from
|
||||||
|
create ctx_deser
|
||||||
|
ctx_deser.set_default_deserializer (create {JSON_BASIC_REFLECTOR_DESERIALIZER})
|
||||||
|
Result := conv_from.from_json_string (a_val, ctx_deser, a_type)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,32 @@
|
|||||||
|
{{>noteinfo}}
|
||||||
|
|
||||||
|
expanded class
|
||||||
|
API_JSON_SERIALIZER
|
||||||
|
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
to_json_string (a_obj: ANY): STRING
|
||||||
|
-- Convert an object `a_obj' to String representation.
|
||||||
|
local
|
||||||
|
obj: ANY
|
||||||
|
conv_to: JSON_REFLECTOR_SERIALIZER
|
||||||
|
ctx: detachable JSON_SERIALIZER_CONTEXT
|
||||||
|
s: STRING
|
||||||
|
do
|
||||||
|
obj := a_obj
|
||||||
|
|
||||||
|
-- Auto serialization, handling table iterable as JSON Object, and iterable as ARRAY. Without typename.
|
||||||
|
create conv_to
|
||||||
|
create ctx
|
||||||
|
ctx.set_pretty_printing
|
||||||
|
ctx.set_is_type_name_included (False)
|
||||||
|
ctx.set_default_serializer (create {JSON_REFLECTOR_SERIALIZER})
|
||||||
|
ctx.register_serializer (create {TABLE_ITERABLE_JSON_SERIALIZER [detachable ANY, READABLE_STRING_GENERAL]}, {TABLE_ITERABLE [detachable ANY, READABLE_STRING_GENERAL]})
|
||||||
|
ctx.register_serializer (create {ITERABLE_JSON_SERIALIZER [detachable ANY]}, {ITERABLE [detachable ANY]})
|
||||||
|
|
||||||
|
s := conv_to.to_json_string (obj, ctx)
|
||||||
|
Result := s
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,14 @@
|
|||||||
|
{{>noteinfo}}
|
||||||
|
|
||||||
|
class
|
||||||
|
API_SERIALIZER
|
||||||
|
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
serializer (f: FUNCTION [TUPLE [content_type:STRING; type:ANY],STRING]; a_content_type: STRING; a_type: ANY): STRING
|
||||||
|
-- Serialize an object of type `a_type' using the content type `a_content_type'.
|
||||||
|
do
|
||||||
|
Result := f.item ([a_content_type, a_type])
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,534 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {JSON_BASIC_REFLECTOR_DESERIALIZER}."
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
JSON_BASIC_REFLECTOR_DESERIALIZER
|
||||||
|
|
||||||
|
inherit
|
||||||
|
JSON_DESERIALIZER
|
||||||
|
redefine
|
||||||
|
reset
|
||||||
|
end
|
||||||
|
|
||||||
|
JSON_TYPE_UTILITIES_EXT
|
||||||
|
|
||||||
|
feature -- Conversion
|
||||||
|
|
||||||
|
from_json (a_json: detachable JSON_VALUE; ctx: JSON_DESERIALIZER_CONTEXT; a_type: detachable TYPE [detachable ANY]): detachable ANY
|
||||||
|
do
|
||||||
|
if attached {JSON_STRING} a_json as s then
|
||||||
|
Result := string_from_json (s, a_type)
|
||||||
|
elseif attached {JSON_OBJECT} a_json as j_object then
|
||||||
|
if attached a_type as l_type and then l_type.conforms_to ({STRING_TABLE [detachable ANY]}) then
|
||||||
|
Result := string_table_from_json_object (j_object, ctx, a_type)
|
||||||
|
elseif attached a_type as l_type and then l_type.conforms_to ({detachable STRING_TABLE [detachable ANY]}) then
|
||||||
|
Result := string_table_from_json_object (j_object, ctx, a_type)
|
||||||
|
else
|
||||||
|
Result := reference_from_json_object (j_object, ctx, a_type)
|
||||||
|
end
|
||||||
|
elseif attached {JSON_ARRAY} a_json as j_array then
|
||||||
|
Result := reference_from_json_array (j_array, ctx, a_type)
|
||||||
|
elseif attached {JSON_BOOLEAN} a_json as b then
|
||||||
|
Result := boolean_from_json (b)
|
||||||
|
elseif attached {JSON_NULL} a_json then
|
||||||
|
Result := Void
|
||||||
|
elseif attached {JSON_NUMBER} a_json as n then
|
||||||
|
Result := number_from_json (n, a_type)
|
||||||
|
end
|
||||||
|
if ctx.has_error then
|
||||||
|
Result := Void
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Cleaning
|
||||||
|
|
||||||
|
reset
|
||||||
|
-- <Precursor>
|
||||||
|
do
|
||||||
|
fields_infos_by_type_id := Void
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Helpers : Array
|
||||||
|
|
||||||
|
reference_from_json_array (a_json: JSON_ARRAY; ctx: JSON_DESERIALIZER_CONTEXT; a_type: detachable TYPE [detachable ANY]): detachable ANY
|
||||||
|
do
|
||||||
|
if a_type = Void then
|
||||||
|
ctx.on_value_skipped (a_json, a_type, "Unable to deserialize array without type information!")
|
||||||
|
elseif attached ctx.deserializer (a_type) as d and then d /= Current then
|
||||||
|
Result := d.from_json (a_json, ctx, a_type)
|
||||||
|
else
|
||||||
|
if a_type.conforms_to ({detachable SPECIAL [detachable ANY]}) then
|
||||||
|
Result := special_from_json_array (a_json, ctx, a_type)
|
||||||
|
elseif a_type.conforms_to ({ARRAY [detachable ANY]}) then
|
||||||
|
Result := array_from_json_array (a_json, ctx, a_type)
|
||||||
|
elseIf a_type.conforms_to ({detachable ARRAY [detachable ANY]}) then
|
||||||
|
Result := array_from_json_array (a_json, ctx, a_type)
|
||||||
|
elseif a_type.conforms_to ({LIST [detachable ANY]}) and then a_type.generic_parameter_count = 1 then
|
||||||
|
Result := list_from_json_array (a_json, ctx, a_type)
|
||||||
|
elseif a_type.conforms_to ({detachable LIST [detachable ANY]}) and then a_type.generic_parameter_count = 1 then
|
||||||
|
Result := list_from_json_array (a_json, ctx, a_type)
|
||||||
|
else
|
||||||
|
ctx.on_value_skipped (a_json, a_type, "Unable to deserialize array {" + a_type.name + "}!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if ctx.has_error then
|
||||||
|
Result := Void
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
special_from_json_array (a_json: JSON_ARRAY; ctx: JSON_DESERIALIZER_CONTEXT; a_type: TYPE [detachable ANY]): detachable SPECIAL [detachable ANY]
|
||||||
|
require
|
||||||
|
a_type.conforms_to ({detachable SPECIAL [detachable ANY]})
|
||||||
|
local
|
||||||
|
l_item_type: TYPE [detachable ANY]
|
||||||
|
i: INTEGER
|
||||||
|
fn: STRING
|
||||||
|
do
|
||||||
|
-- FIXME: it should be safe to instantiate SPECIAL object here.
|
||||||
|
Result := new_special_any_instance (a_type, a_json.count)
|
||||||
|
if Result /= Void and then a_type.generic_parameter_count = 1 then
|
||||||
|
l_item_type := a_type.generic_parameter_type (1)
|
||||||
|
i := 1
|
||||||
|
across
|
||||||
|
a_json as ic
|
||||||
|
until
|
||||||
|
ctx.has_error
|
||||||
|
loop
|
||||||
|
fn := i.out
|
||||||
|
ctx.on_deserialization_field_start (Result, fn)
|
||||||
|
process_array_item_value (ic.item, ctx, l_item_type, agent (spe: SPECIAL [detachable ANY]; ith: INTEGER; v: detachable ANY)
|
||||||
|
do
|
||||||
|
spe.force (v, ith)
|
||||||
|
end(Result,Result.lower + i - 1, ?)
|
||||||
|
)
|
||||||
|
ctx.on_deserialization_field_end (Result, fn)
|
||||||
|
i := i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
array_from_json_array (a_json: JSON_ARRAY; ctx: JSON_DESERIALIZER_CONTEXT; a_type: TYPE [detachable ANY]): detachable ARRAY [detachable ANY]
|
||||||
|
require
|
||||||
|
a_type.conforms_to ({ARRAY [detachable ANY]}) and then a_type.generic_parameter_count = 1 or else
|
||||||
|
a_type.conforms_to ({detachable ARRAY [detachable ANY]}) and then a_type.generic_parameter_count = 1
|
||||||
|
local
|
||||||
|
l_item_type: TYPE [detachable ANY]
|
||||||
|
i: INTEGER
|
||||||
|
fn: STRING
|
||||||
|
do
|
||||||
|
-- Added to Deserialize by LIST [ANY] to ARRAYED_LIST [ANY]
|
||||||
|
if
|
||||||
|
attached {SPECIAL [detachable ANY]} new_special_for_name ("SPECIAL [" +a_type.generic_parameter_type (1).name_32 + " ]", a_json.count ) as l_result
|
||||||
|
then
|
||||||
|
Result := l_result.to_array
|
||||||
|
if Result /= Void and then a_type.generic_parameter_count = 1 then
|
||||||
|
l_item_type := a_type.generic_parameter_type (1)
|
||||||
|
i := 1
|
||||||
|
across
|
||||||
|
a_json as ic
|
||||||
|
until
|
||||||
|
ctx.has_error
|
||||||
|
loop
|
||||||
|
fn := i.out
|
||||||
|
ctx.on_deserialization_field_start (Result, fn)
|
||||||
|
process_array_item_value (ic.item, ctx, l_item_type, agent (spe: ARRAY [detachable ANY]; ith: INTEGER; v: detachable ANY)
|
||||||
|
do
|
||||||
|
spe.force (v, ith)
|
||||||
|
end(Result,Result.lower + i - 1, ?)
|
||||||
|
)
|
||||||
|
ctx.on_deserialization_field_end (Result, fn)
|
||||||
|
i := i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
string_table_from_json_object (a_json: JSON_OBJECT; ctx: JSON_DESERIALIZER_CONTEXT; a_type: TYPE [detachable ANY]): detachable STRING_TABLE [detachable ANY]
|
||||||
|
require
|
||||||
|
conforms_to: a_type.conforms_to ({STRING_TABLE [detachable ANY]}) and then a_type.generic_parameter_count = 1 or else
|
||||||
|
a_type.conforms_to ({detachable STRING_TABLE [detachable ANY]}) and then a_type.generic_parameter_count = 1
|
||||||
|
local
|
||||||
|
l_item_type: TYPE [detachable ANY]
|
||||||
|
i: INTEGER
|
||||||
|
fn: STRING
|
||||||
|
l_object: REFLECTED_REFERENCE_OBJECT
|
||||||
|
do
|
||||||
|
-- Added to Deserialize by LIST [ANY] to ARRAYED_LIST [ANY]
|
||||||
|
if
|
||||||
|
attached {JSON_OBJECT} a_json as j_object and then
|
||||||
|
attached {STRING_TABLE [detachable ANY]} new_instance_for_type_name ("STRING_TABLE ["+ a_type.generic_parameter_type (1).name_32 + "]") as lst
|
||||||
|
then
|
||||||
|
create l_object.make (lst)
|
||||||
|
if attached {STRING_TABLE [detachable ANY]} l_object.object as l_obj then
|
||||||
|
l_obj.make (j_object.count)
|
||||||
|
Result := l_obj
|
||||||
|
l_item_type := a_type.generic_parameter_type (1)
|
||||||
|
i := 1
|
||||||
|
across
|
||||||
|
a_json as ic
|
||||||
|
loop
|
||||||
|
fn := i.out
|
||||||
|
ctx.on_deserialization_field_start (l_obj, fn)
|
||||||
|
process_string_table_item_value (ic.key, ic.item, ctx, l_item_type, agent l_obj.force)
|
||||||
|
ctx.on_deserialization_field_end (l_obj, fn)
|
||||||
|
i := i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
list_from_json_array (a_json: JSON_ARRAY; ctx: JSON_DESERIALIZER_CONTEXT; a_type: TYPE [detachable ANY]): detachable LIST [detachable ANY]
|
||||||
|
require
|
||||||
|
conforms_to: a_type.conforms_to ({LIST [detachable ANY]}) and then a_type.generic_parameter_count = 1 or else
|
||||||
|
a_type.conforms_to ({detachable LIST [detachable ANY]}) and then a_type.generic_parameter_count = 1
|
||||||
|
local
|
||||||
|
l_item_type: TYPE [detachable ANY]
|
||||||
|
i: INTEGER
|
||||||
|
fn: STRING
|
||||||
|
l_object: REFLECTED_REFERENCE_OBJECT
|
||||||
|
do
|
||||||
|
-- Added to Deserialize by LIST [ANY] to ARRAYED_LIST [ANY]
|
||||||
|
if
|
||||||
|
attached {JSON_ARRAY} a_json as l_array and then
|
||||||
|
attached {ARRAYED_LIST [detachable ANY]} new_instance_for_type_name ("ARRAYED_LIST ["+ a_type.generic_parameter_type (1).name_32 + "]") as lst
|
||||||
|
then
|
||||||
|
create l_object.make (lst)
|
||||||
|
if attached {ARRAYED_LIST [detachable ANY]} l_object.object as l_obj then
|
||||||
|
l_obj.make (l_array.count)
|
||||||
|
Result := l_obj
|
||||||
|
l_item_type := a_type.generic_parameter_type (1)
|
||||||
|
i := 1
|
||||||
|
across
|
||||||
|
a_json as ic
|
||||||
|
loop
|
||||||
|
fn := i.out
|
||||||
|
ctx.on_deserialization_field_start (l_obj, fn)
|
||||||
|
process_array_item_value (ic.item, ctx, l_item_type, agent l_obj.extend)
|
||||||
|
ctx.on_deserialization_field_end (l_obj, fn)
|
||||||
|
i := i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
process_string_table_item_value (a_key: JSON_STRING; a_json: JSON_VALUE; ctx: JSON_DESERIALIZER_CONTEXT; a_item_type: TYPE [detachable ANY]; a_extend_action: PROCEDURE [detachable ANY])
|
||||||
|
local
|
||||||
|
key: STRING
|
||||||
|
obj: detachable ANY
|
||||||
|
do
|
||||||
|
key := a_key.item
|
||||||
|
obj := array_item_value (a_json, ctx, a_item_type)
|
||||||
|
if obj = Void then
|
||||||
|
if a_item_type.is_attached then
|
||||||
|
ctx.on_value_skipped (a_json, a_item_type, "Issue when deserializing string_table item {" + a_item_type.name + "}.")
|
||||||
|
else
|
||||||
|
a_extend_action.call ([Void])
|
||||||
|
end
|
||||||
|
elseif attached a_item_type.attempted (obj) as o then
|
||||||
|
a_extend_action.call ([o, key])
|
||||||
|
else
|
||||||
|
ctx.on_value_skipped (a_json, a_item_type, "Deserialized STRING_TABLE item {" + obj.generating_type.name + "} mismatch with {" + a_item_type.name + "}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
process_array_item_value (a_json: JSON_VALUE; ctx: JSON_DESERIALIZER_CONTEXT; a_item_type: TYPE [detachable ANY]; a_extend_action: PROCEDURE [detachable ANY])
|
||||||
|
local
|
||||||
|
obj: detachable ANY
|
||||||
|
do
|
||||||
|
obj := array_item_value (a_json, ctx, a_item_type)
|
||||||
|
if obj = Void then
|
||||||
|
if a_item_type.is_attached then
|
||||||
|
ctx.on_value_skipped (a_json, a_item_type, "Issue when deserializing array item {" + a_item_type.name + "}.")
|
||||||
|
else
|
||||||
|
a_extend_action.call ([Void])
|
||||||
|
end
|
||||||
|
elseif attached a_item_type.attempted (obj) as o then
|
||||||
|
a_extend_action.call ([o])
|
||||||
|
else
|
||||||
|
ctx.on_value_skipped (a_json, a_item_type, "Deserialized Array item {" + obj.generating_type.name + "} mismatch with {" + a_item_type.name + "}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
array_item_value (a_json: JSON_VALUE; ctx: JSON_DESERIALIZER_CONTEXT; a_item_type: TYPE [detachable ANY]): detachable ANY
|
||||||
|
local
|
||||||
|
inf: JSON_DESERIALIZER_CREATION_INFORMATION
|
||||||
|
do
|
||||||
|
Result := ctx.value_from_json (a_json, a_item_type)
|
||||||
|
if Result = Void and a_item_type.is_attached then
|
||||||
|
create inf.make (a_item_type, a_json)
|
||||||
|
ctx.on_value_creation (inf)
|
||||||
|
Result := inf.object
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Helpers: Object
|
||||||
|
|
||||||
|
type_name_from_json_object (a_json_object: JSON_OBJECT): detachable READABLE_STRING_32
|
||||||
|
do
|
||||||
|
if attached {JSON_STRING} a_json_object.item ({JSON_REFLECTOR_SERIALIZER}.type_field_name) as s_type_name then
|
||||||
|
Result := s_type_name.item
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
reference_from_json_object (a_json_object: JSON_OBJECT; ctx: JSON_DESERIALIZER_CONTEXT; a_type: detachable TYPE [detachable ANY]): detachable ANY
|
||||||
|
local
|
||||||
|
l_type_name: detachable READABLE_STRING_32
|
||||||
|
ref: REFLECTED_REFERENCE_OBJECT
|
||||||
|
i: INTEGER
|
||||||
|
fn: READABLE_STRING_GENERAL
|
||||||
|
l_json_item: detachable JSON_VALUE
|
||||||
|
l_field_static_types: like fields_infos
|
||||||
|
do
|
||||||
|
if Result = Void then
|
||||||
|
-- Updated to use the Type info insted of the type_field in JSON.
|
||||||
|
-- fn.same_string ({JSON_REFLECTOR_SERIALIZER}.type_field_name
|
||||||
|
if attached a_type then
|
||||||
|
l_type_name := a_type.name.as_string_32
|
||||||
|
end
|
||||||
|
Result := new_instance_of (l_type_name, a_type)
|
||||||
|
if Result = Void then
|
||||||
|
if l_type_name /= Void then
|
||||||
|
ctx.on_value_skipped (a_json_object, a_type, "Unable to instantiate type %"" + l_type_name + "%".")
|
||||||
|
elseif a_type /= Void then
|
||||||
|
ctx.on_value_skipped (a_json_object, a_type, "Unable to instantiate type {" + a_type.name + "}")
|
||||||
|
else
|
||||||
|
ctx.on_value_skipped (a_json_object, a_type, "Unable to instantiate expected object without type information!")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
ctx.on_object (Result, a_json_object)
|
||||||
|
create ref.make (Result)
|
||||||
|
l_field_static_types := fields_infos (ref)
|
||||||
|
across
|
||||||
|
-- Follow the order from JSON, in case of reference usage.
|
||||||
|
a_json_object as ic
|
||||||
|
until
|
||||||
|
ctx.has_error
|
||||||
|
loop
|
||||||
|
fn := ic.key.unescaped_string_32
|
||||||
|
if attached l_field_static_types.item (fn) as l_field_info then
|
||||||
|
i := l_field_info.field_index
|
||||||
|
l_json_item := ic.item
|
||||||
|
ctx.on_deserialization_field_start (Result, fn)
|
||||||
|
inspect
|
||||||
|
l_field_info.field_type_id
|
||||||
|
when reference_type, expanded_type then
|
||||||
|
if attached {JSON_STRING} l_json_item as j_string then
|
||||||
|
ref.set_reference_field (i, string_from_json (j_string, l_field_info.static_type))
|
||||||
|
elseif attached ctx.value_from_json (l_json_item, l_field_info.static_type) as l_obj then
|
||||||
|
ref.set_reference_field (i, l_obj)
|
||||||
|
end
|
||||||
|
when character_8_type then
|
||||||
|
ref.set_character_8_field (i, '%U')
|
||||||
|
when character_32_type then
|
||||||
|
ref.set_character_32_field (i, '%U')
|
||||||
|
when integer_8_type then
|
||||||
|
ref.set_integer_8_field (i, integer_from_json (l_json_item).to_integer_8)
|
||||||
|
when integer_16_type then
|
||||||
|
ref.set_integer_16_field (i, integer_from_json (l_json_item).to_integer_16)
|
||||||
|
when integer_32_type then
|
||||||
|
ref.set_integer_32_field (i, integer_from_json (l_json_item).to_integer_32)
|
||||||
|
when integer_64_type then
|
||||||
|
ref.set_integer_64_field (i, integer_from_json (l_json_item))
|
||||||
|
when natural_8_type then
|
||||||
|
ref.set_natural_8_field (i, natural_from_json (l_json_item).to_natural_8)
|
||||||
|
when natural_16_type then
|
||||||
|
ref.set_natural_16_field (i, natural_from_json (l_json_item).to_natural_16)
|
||||||
|
when natural_32_type then
|
||||||
|
ref.set_natural_32_field (i, natural_from_json (l_json_item).to_natural_32)
|
||||||
|
when natural_64_type then
|
||||||
|
ref.set_natural_64_field (i, natural_from_json (l_json_item))
|
||||||
|
when real_32_type then
|
||||||
|
ref.set_real_32_field (i, real_from_json (l_json_item).truncated_to_real)
|
||||||
|
when real_64_type then
|
||||||
|
ref.set_real_64_field (i, real_from_json (l_json_item))
|
||||||
|
when pointer_type then
|
||||||
|
when boolean_type then
|
||||||
|
ref.set_boolean_field (i, boolean_from_json (l_json_item))
|
||||||
|
else
|
||||||
|
end
|
||||||
|
ctx.on_deserialization_field_end (Result, fn)
|
||||||
|
elseif fn.same_string ({JSON_REFLECTOR_SERIALIZER}.type_field_name) then
|
||||||
|
-- Ignore
|
||||||
|
else
|
||||||
|
-- No such field ! Ignore for now
|
||||||
|
-- FIXME: see what would be best here.
|
||||||
|
-- ctx.report_warning (create {JSON_DESERIALIZER_ERROR}.make ({STRING_32} "No field %"" + fn.as_string_32 + "%" on " + ref.type_name + "!"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if ctx.has_error then
|
||||||
|
Result := Void
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Helpers: Basic values
|
||||||
|
|
||||||
|
boolean_from_json (v: JSON_VALUE): BOOLEAN
|
||||||
|
do
|
||||||
|
if attached {JSON_BOOLEAN} v as b then
|
||||||
|
Result := b.item
|
||||||
|
elseif attached {JSON_STRING} v as s then
|
||||||
|
Result := s.item.is_case_insensitive_equal_general ("true")
|
||||||
|
else
|
||||||
|
check is_boolean: False end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
number_from_json (v: JSON_VALUE; a_type: detachable TYPE [detachable ANY]): detachable ANY
|
||||||
|
do
|
||||||
|
if attached {JSON_NUMBER} v as l_number then
|
||||||
|
if a_type = Void then
|
||||||
|
Result := l_number.integer_64_item
|
||||||
|
elseif a_type = {INTEGER_8} then
|
||||||
|
Result := l_number.integer_64_item.to_integer_8
|
||||||
|
elseif a_type = {INTEGER_16} then
|
||||||
|
Result := l_number.integer_64_item.to_integer_16
|
||||||
|
elseif a_type = {INTEGER_32} then
|
||||||
|
Result := l_number.integer_64_item.to_integer_32
|
||||||
|
elseif a_type = {INTEGER_64} then
|
||||||
|
Result := l_number.integer_64_item
|
||||||
|
elseif a_type = {NATURAL_8} then
|
||||||
|
Result := l_number.natural_64_item.to_natural_8
|
||||||
|
elseif a_type = {NATURAL_16} then
|
||||||
|
Result := l_number.natural_64_item.to_natural_16
|
||||||
|
elseif a_type = {NATURAL_32} then
|
||||||
|
Result := l_number.natural_64_item.to_natural_32
|
||||||
|
elseif a_type = {NATURAL_64} then
|
||||||
|
Result := l_number.natural_64_item
|
||||||
|
elseif a_type = {REAL_32} then
|
||||||
|
Result := l_number.natural_64_item.to_real_32
|
||||||
|
elseif a_type = {REAL_64} then
|
||||||
|
Result := l_number.natural_64_item
|
||||||
|
else
|
||||||
|
Result := l_number.integer_64_item
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
integer_from_json (v: JSON_VALUE): INTEGER_64
|
||||||
|
do
|
||||||
|
if attached {JSON_NUMBER} v as n then
|
||||||
|
Result := n.integer_64_item
|
||||||
|
elseif attached {JSON_STRING} v as s then
|
||||||
|
if s.item.is_integer_64 then
|
||||||
|
Result := s.item.to_integer_64
|
||||||
|
end
|
||||||
|
else
|
||||||
|
check is_integer: False end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
natural_from_json (v: JSON_VALUE): NATURAL_64
|
||||||
|
do
|
||||||
|
if attached {JSON_NUMBER} v as n then
|
||||||
|
Result := n.natural_64_item
|
||||||
|
elseif attached {JSON_STRING} v as s then
|
||||||
|
if s.item.is_natural_64 then
|
||||||
|
Result := s.item.to_natural_64
|
||||||
|
end
|
||||||
|
else
|
||||||
|
check is_natural: False end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
real_from_json (v: JSON_VALUE): REAL_64
|
||||||
|
do
|
||||||
|
if attached {JSON_NUMBER} v as n then
|
||||||
|
Result := n.real_64_item
|
||||||
|
else
|
||||||
|
check is_real: False end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
string_from_json (v: JSON_VALUE; a_static_type: detachable TYPE [detachable ANY]): detachable READABLE_STRING_GENERAL
|
||||||
|
do
|
||||||
|
if attached {JSON_STRING} v as s then
|
||||||
|
if a_static_type /= Void then
|
||||||
|
Result := string_converted_to_type (s.unescaped_string_32, a_static_type)
|
||||||
|
else
|
||||||
|
Result := s.unescaped_string_32
|
||||||
|
end
|
||||||
|
else
|
||||||
|
check is_string: False end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
|
fields_infos (ref: REFLECTED_OBJECT): STRING_TABLE [TUPLE [field_index: INTEGER; field_type_id: INTEGER; static_type: detachable TYPE [detachable ANY]]]
|
||||||
|
-- Table indexed by field name of field_type (abstract type, basic types , ref type)
|
||||||
|
-- and `static_type' for reference fields.
|
||||||
|
local
|
||||||
|
fn: READABLE_STRING_GENERAL
|
||||||
|
i,n: INTEGER
|
||||||
|
tid,stid: INTEGER
|
||||||
|
t: detachable TYPE [detachable ANY]
|
||||||
|
tb: like fields_infos_by_type_id
|
||||||
|
do
|
||||||
|
tb := fields_infos_by_type_id
|
||||||
|
if tb = Void then
|
||||||
|
create tb.make (0)
|
||||||
|
fields_infos_by_type_id := tb
|
||||||
|
end
|
||||||
|
if attached tb.item (ref.type_name) as res then
|
||||||
|
Result := res
|
||||||
|
else
|
||||||
|
n := ref.field_count
|
||||||
|
create Result.make_caseless (n)
|
||||||
|
from
|
||||||
|
i := 1
|
||||||
|
until
|
||||||
|
i > n
|
||||||
|
loop
|
||||||
|
fn := ref.field_name (i)
|
||||||
|
stid := ref.field_static_type (i)
|
||||||
|
tid := ref.field_type (i)
|
||||||
|
if stid >= 0 and (tid = reference_type or tid = expanded_type) then
|
||||||
|
t := type_of_type (stid)
|
||||||
|
else
|
||||||
|
t := Void
|
||||||
|
end
|
||||||
|
Result.force ([i, tid, t], fn)
|
||||||
|
i := i + 1
|
||||||
|
end
|
||||||
|
tb.put (Result, ref.type_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
fields_infos_by_type_id: detachable STRING_TABLE [like fields_infos]
|
||||||
|
|
||||||
|
string_converted_to_type (str: READABLE_STRING_GENERAL; a_static_type: TYPE [detachable ANY]): detachable READABLE_STRING_GENERAL
|
||||||
|
local
|
||||||
|
utf_conv: UTF_CONVERTER
|
||||||
|
do
|
||||||
|
if a_static_type.conforms_to (str.generating_type) then
|
||||||
|
Result := str
|
||||||
|
elseif
|
||||||
|
a_static_type = {STRING_32} or a_static_type = {detachable STRING_32}
|
||||||
|
or a_static_type = {READABLE_STRING_32} or a_static_type = {detachable READABLE_STRING_32}
|
||||||
|
then
|
||||||
|
create {STRING_32} Result.make_from_string_general (str)
|
||||||
|
elseif
|
||||||
|
a_static_type = {STRING_8} or a_static_type = {detachable STRING_8}
|
||||||
|
or a_static_type = {READABLE_STRING_8} or a_static_type = {detachable READABLE_STRING_8}
|
||||||
|
then
|
||||||
|
create {STRING_8} Result.make_from_string (utf_conv.utf_32_string_to_utf_8_string_8 (str))
|
||||||
|
|
||||||
|
elseif a_static_type = {IMMUTABLE_STRING_32} or a_static_type = {detachable IMMUTABLE_STRING_32} then
|
||||||
|
create {IMMUTABLE_STRING_32} Result.make_from_string_general (str)
|
||||||
|
elseif a_static_type = {IMMUTABLE_STRING_8} or a_static_type = {detachable IMMUTABLE_STRING_8} then
|
||||||
|
create {IMMUTABLE_STRING_8} Result.make_from_string (utf_conv.utf_32_string_to_utf_8_string_8 (str))
|
||||||
|
|
||||||
|
else
|
||||||
|
check known_type: False end
|
||||||
|
Result := str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2010-2017, Javier Velilla and others https://github.com/eiffelhub/json."
|
||||||
|
license: "https://github.com/eiffelhub/json/blob/master/License.txt"
|
||||||
|
end
|
@ -0,0 +1,28 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {JSON_TYPE_UTILITIES_EXT}."
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
JSON_TYPE_UTILITIES_EXT
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
JSON_TYPE_UTILITIES
|
||||||
|
|
||||||
|
|
||||||
|
feature -- Factory
|
||||||
|
|
||||||
|
new_special_for_name (a_type_name: READABLE_STRING_GENERAL; count: INTEGER): detachable SPECIAL [detachable ANY]
|
||||||
|
do
|
||||||
|
if
|
||||||
|
attached reflector.dynamic_type_from_string (a_type_name) as l_type_id and then
|
||||||
|
l_type_id >= 0 and then attached type_of_type (l_type_id) as l_type and then
|
||||||
|
reflector.is_special_type (l_type_id)
|
||||||
|
then
|
||||||
|
Result := new_special_any_instance (l_type, count)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
107
modules/swagger-codegen/src/main/resources/Eiffel/model.mustache
Normal file
107
modules/swagger-codegen/src/main/resources/Eiffel/model.mustache
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
{{>noteinfo}}
|
||||||
|
{{#models}}
|
||||||
|
{{#model}}
|
||||||
|
|
||||||
|
class {{classname}}
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
ANY
|
||||||
|
redefine
|
||||||
|
out
|
||||||
|
{{#parent}}
|
||||||
|
select
|
||||||
|
out
|
||||||
|
{{/parent}}
|
||||||
|
end
|
||||||
|
|
||||||
|
{{#parent}}
|
||||||
|
{{{parent}}}
|
||||||
|
rename
|
||||||
|
out as out_{{{parentSchema}}}
|
||||||
|
end
|
||||||
|
{{/parent}}
|
||||||
|
|
||||||
|
feature --Access
|
||||||
|
|
||||||
|
{{#vars}}
|
||||||
|
{{^isInherited}}
|
||||||
|
{{#isPrimitiveType}}
|
||||||
|
{{name}}: {{{datatype}}}
|
||||||
|
{{#description}}-- {{{description}}}{{/description}}
|
||||||
|
{{/isPrimitiveType}}
|
||||||
|
{{^isPrimitiveType}}
|
||||||
|
{{#isContainer}}
|
||||||
|
{{name}}: detachable {{{datatypeWithEnum}}}
|
||||||
|
{{#description}}-- {{{description}}}{{/description}}
|
||||||
|
{{/isContainer}}
|
||||||
|
{{^isContainer}}
|
||||||
|
{{name}}: detachable {{{datatype}}}
|
||||||
|
{{#description}}-- {{{description}}}{{/description}}
|
||||||
|
{{/isContainer}}
|
||||||
|
{{/isPrimitiveType}}
|
||||||
|
{{/isInherited}}
|
||||||
|
{{/vars}}
|
||||||
|
|
||||||
|
feature -- Change Element
|
||||||
|
|
||||||
|
{{#vars}}
|
||||||
|
{{^isInherited}}
|
||||||
|
set_{{name}} (a_name: like {{name}})
|
||||||
|
-- Set '{{name}}' with 'a_name'.
|
||||||
|
do
|
||||||
|
{{name}} := a_name
|
||||||
|
ensure
|
||||||
|
{{name}}_set: {{name}} = a_name
|
||||||
|
end
|
||||||
|
|
||||||
|
{{/isInherited}}
|
||||||
|
{{/vars}}
|
||||||
|
|
||||||
|
feature -- Status Report
|
||||||
|
|
||||||
|
out: STRING
|
||||||
|
-- <Precursor>
|
||||||
|
do
|
||||||
|
create Result.make_empty
|
||||||
|
{{#parent}}
|
||||||
|
Result.append(out_{{{parentSchema}}})
|
||||||
|
{{/parent}}
|
||||||
|
Result.append("%Nclass {{classname}}%N")
|
||||||
|
{{#vars}}
|
||||||
|
{{^isInherited}}
|
||||||
|
{{#isListContainer}}
|
||||||
|
if attached {{name}} as l_{{name}} then
|
||||||
|
across l_{{name}} as ic loop
|
||||||
|
Result.append ("%N")
|
||||||
|
Result.append (ic.item.out)
|
||||||
|
Result.append ("%N")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
{{/isListContainer}}
|
||||||
|
{{#isMapContainer}}
|
||||||
|
if attached {{name}} as l_{{name}} then
|
||||||
|
across l_{{name}} as ic loop
|
||||||
|
Result.append ("%N")
|
||||||
|
Result.append ("key:")
|
||||||
|
Result.append (ic.key.out)
|
||||||
|
Result.append (" - ")
|
||||||
|
Result.append ("val:")
|
||||||
|
Result.append (ic.item.out)
|
||||||
|
Result.append ("%N")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
{{/isMapContainer}}
|
||||||
|
{{^isContainer}}
|
||||||
|
if attached {{name}} as l_{{name}} then
|
||||||
|
Result.append ("%N")
|
||||||
|
Result.append (l_{{name}}.out)
|
||||||
|
Result.append ("%N")
|
||||||
|
end
|
||||||
|
{{/isContainer}}
|
||||||
|
{{/isInherited}}
|
||||||
|
{{/vars}}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
{{/model}}
|
||||||
|
{{/models}}
|
@ -0,0 +1,11 @@
|
|||||||
|
{{#models}}{{#model}}# {{classname}}
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
|
||||||
|
{{/vars}}
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
{{/model}}{{/models}}
|
@ -0,0 +1,14 @@
|
|||||||
|
note
|
||||||
|
description:"[
|
||||||
|
{{{appName}}}
|
||||||
|
{{{appDescription}}}
|
||||||
|
{{#version}}OpenAPI spec version: {{{version}}}{{/version}}
|
||||||
|
{{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
|
||||||
|
|
||||||
|
NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
]"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
EIS:"Eiffel swagger codegen", "src=https://github.com/swagger-api/swagger-codegen.git", "protocol=uri"
|
@ -0,0 +1,63 @@
|
|||||||
|
note
|
||||||
|
description: "API tests for {{classname}}"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
|
||||||
|
class {{classname}}_TEST
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
EQA_TEST_SET
|
||||||
|
|
||||||
|
feature -- Test routines
|
||||||
|
|
||||||
|
{{#operations}}
|
||||||
|
{{#operation}}
|
||||||
|
|
||||||
|
test_{{operationId}}
|
||||||
|
-- {{summary}}
|
||||||
|
--
|
||||||
|
-- {{notes}}
|
||||||
|
local
|
||||||
|
{{#returnType}}
|
||||||
|
l_response: {{{returnType}}}
|
||||||
|
{{/returnType}}
|
||||||
|
{{#allParams}}
|
||||||
|
l_{{paramName}}: {{{dataType}}}
|
||||||
|
{{/allParams}}
|
||||||
|
do
|
||||||
|
-- TODO: Initialize required params.
|
||||||
|
{{#allParams}}
|
||||||
|
{{#required}}
|
||||||
|
{{#isContainer}}
|
||||||
|
{{#isListContainer}}
|
||||||
|
-- create {ARRAYED_{{dataType}}} l_{{paramName}}.make (2)
|
||||||
|
{{/isListContainer}}
|
||||||
|
{{/isContainer}}
|
||||||
|
{{^isContainer}}
|
||||||
|
-- l_{{paramName}}
|
||||||
|
{{/isContainer}}
|
||||||
|
{{/required}}
|
||||||
|
{{/allParams}}
|
||||||
|
|
||||||
|
{{#returnType}}
|
||||||
|
-- l_response := api.{{operationId}}{{#hasParams}}({{#allParams}}l_{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{/hasParams}}
|
||||||
|
{{/returnType}}
|
||||||
|
{{^returnType}}
|
||||||
|
-- api.{{operationId}}{{#hasParams}}({{#allParams}}l_{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{/hasParams}}
|
||||||
|
{{/returnType}}
|
||||||
|
assert ("not_implemented", False)
|
||||||
|
end
|
||||||
|
{{/operation}}
|
||||||
|
{{/operations}}
|
||||||
|
|
||||||
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
|
api: {{classname}}
|
||||||
|
-- Create an object instance of `{{classname}}'.
|
||||||
|
once
|
||||||
|
create { {{classname}} } Result
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,22 @@
|
|||||||
|
note
|
||||||
|
description: "test application root class"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
APPLICATION
|
||||||
|
|
||||||
|
inherit
|
||||||
|
ARGUMENTS
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make
|
||||||
|
-- Run application.
|
||||||
|
do
|
||||||
|
-- add your code here.
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-16-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-16-0 http://www.eiffel.com/developers/xml/configuration-1-16-0.xsd" name="test" uuid="{{uuidTest}}">
|
||||||
|
<target name="test">
|
||||||
|
<root feature="make" class="APPLICATION"/>
|
||||||
|
<file_rule>
|
||||||
|
<exclude>/\.git$</exclude>
|
||||||
|
<exclude>/\.svn$</exclude>
|
||||||
|
<exclude>/CVS$</exclude>
|
||||||
|
<exclude>/EIFGENs$</exclude>
|
||||||
|
</file_rule>
|
||||||
|
<option warning="true">
|
||||||
|
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||||
|
</option>
|
||||||
|
<setting name="console_application" value="true"/>
|
||||||
|
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
|
||||||
|
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||||
|
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
||||||
|
<library name="api_client" location="..\api_client.ecf" readonly="false"/>
|
||||||
|
<cluster name="test" location=".\" recursive="true"/>
|
||||||
|
</target>
|
||||||
|
</system>
|
@ -31,6 +31,30 @@ Then install it via:
|
|||||||
npm install {{{projectName}}} --save
|
npm install {{{projectName}}} --save
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Local development
|
||||||
|
|
||||||
|
To use the library locally without publishing to a remote npm registry, first install the dependencies by changing
|
||||||
|
into the directory containing `package.json` (and this README). Let's call this `JAVASCRIPT_CLIENT_DIR`. Then run:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the following, also from `JAVASCRIPT_CLIENT_DIR`:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
npm link
|
||||||
|
```
|
||||||
|
|
||||||
|
Finally, switch to the directory you want to use your {{{projectName}}} from, and run:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
npm link /path/to/<JAVASCRIPT_CLIENT_DIR>
|
||||||
|
```
|
||||||
|
|
||||||
|
You should now be able to `require('{{{projectName}}}')` in javascript files from the directory you ran the last
|
||||||
|
command above from.
|
||||||
|
|
||||||
#### git
|
#### git
|
||||||
#
|
#
|
||||||
If the library is hosted at a git repository, e.g.
|
If the library is hosted at a git repository, e.g.
|
||||||
@ -45,7 +69,8 @@ then install it via:
|
|||||||
|
|
||||||
The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following
|
The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following
|
||||||
the above steps with Node.js and installing browserify with `npm install -g browserify`,
|
the above steps with Node.js and installing browserify with `npm install -g browserify`,
|
||||||
perform the following (assuming *main.js* is your entry file):
|
perform the following (assuming *main.js* is your entry file, that's to say your javascript file where you actually
|
||||||
|
use this library):
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
browserify main.js > bundle.js
|
browserify main.js > bundle.js
|
||||||
|
@ -12,6 +12,7 @@ io.swagger.codegen.languages.CppRestClientCodegen
|
|||||||
io.swagger.codegen.languages.CsharpDotNet2ClientCodegen
|
io.swagger.codegen.languages.CsharpDotNet2ClientCodegen
|
||||||
io.swagger.codegen.languages.DartClientCodegen
|
io.swagger.codegen.languages.DartClientCodegen
|
||||||
io.swagger.codegen.languages.ElixirClientCodegen
|
io.swagger.codegen.languages.ElixirClientCodegen
|
||||||
|
io.swagger.codegen.languages.EiffelClientCodegen
|
||||||
io.swagger.codegen.languages.ErlangServerCodegen
|
io.swagger.codegen.languages.ErlangServerCodegen
|
||||||
io.swagger.codegen.languages.FinchServerCodegen
|
io.swagger.codegen.languages.FinchServerCodegen
|
||||||
io.swagger.codegen.languages.FlashClientCodegen
|
io.swagger.codegen.languages.FlashClientCodegen
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
|
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
|
||||||
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
|
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator {{{generatorVersion}}}.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -9,7 +9,7 @@ netfx=${frameworkVersion#net}
|
|||||||
echo "[INFO] Target framework: ${frameworkVersion}"
|
echo "[INFO] Target framework: ${frameworkVersion}"
|
||||||
|
|
||||||
echo "[INFO] Download nuget and packages"
|
echo "[INFO] Download nuget and packages"
|
||||||
wget -nc https://nuget.org/nuget.exe;
|
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe;
|
||||||
mozroots --import --sync
|
mozroots --import --sync
|
||||||
mono nuget.exe install src/{{packageName}}/packages.config -o packages;
|
mono nuget.exe install src/{{packageName}}/packages.config -o packages;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319
|
|||||||
SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v3.5
|
SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v3.5
|
||||||
{{/supportsAsync}}
|
{{/supportsAsync}}
|
||||||
|
|
||||||
if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://nuget.org/nuget.exe', '.\nuget.exe')"
|
if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '.\nuget.exe')"
|
||||||
.\nuget.exe install src\{{packageName}}\packages.config -o packages
|
.\nuget.exe install src\{{packageName}}\packages.config -o packages
|
||||||
|
|
||||||
if not exist ".\bin" mkdir bin
|
if not exist ".\bin" mkdir bin
|
||||||
|
@ -241,13 +241,15 @@ this.{{name}} = {{name}};
|
|||||||
|
|
||||||
{{/minimum}}
|
{{/minimum}}
|
||||||
{{#pattern}}
|
{{#pattern}}
|
||||||
|
{{^isByteArray}}
|
||||||
// {{{name}}} ({{{datatype}}}) pattern
|
// {{{name}}} ({{{datatype}}}) pattern
|
||||||
Regex regex{{{name}}} = new Regex(@"{{{vendorExtensions.x-regex}}}"{{#vendorExtensions.x-modifiers}}{{#-first}}, {{/-first}}RegexOptions.{{{.}}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}});
|
Regex regex{{{name}}} = new Regex(@"{{{vendorExtensions.x-regex}}}"{{#vendorExtensions.x-modifiers}}{{#-first}}, {{/-first}}RegexOptions.{{{.}}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}});
|
||||||
if (false == regex{{{name}}}.Match(this.{{{name}}}).Success)
|
if (false == regex{{{name}}}.Match(this.{{{name}}}).Success)
|
||||||
{
|
{
|
||||||
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must match a pattern of {{{pattern}}}.", new [] { "{{{name}}}" });
|
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for {{{name}}}, must match a pattern of " + regex{{{name}}}, new [] { "{{{name}}}" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{{/isByteArray}}
|
||||||
{{/pattern}}
|
{{/pattern}}
|
||||||
{{/hasValidation}}
|
{{/hasValidation}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
# Generated by: https://github.com/swagger-api/swagger-codegen.git
|
# Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
#
|
#
|
||||||
|
|
||||||
wget -nc https://nuget.org/nuget.exe
|
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
|
||||||
mozroots --import --sync
|
mozroots --import --sync
|
||||||
|
|
||||||
echo "[INFO] remove bin/Debug/SwaggerClientTest.dll"
|
echo "[INFO] remove bin/Debug/SwaggerClientTest.dll"
|
||||||
rm src/{{{packageName}}}.Test/bin/Debug/{{{packageName}}}.Test.dll 2> /dev/null
|
rm src/{{{packageName}}}.Test/bin/Debug/{{{packageName}}}.Test.dll 2> /dev/null
|
||||||
|
|
||||||
echo "[INFO] install NUnit runners via NuGet"
|
echo "[INFO] install NUnit runners via NuGet"
|
||||||
wget -nc https://nuget.org/nuget.exe
|
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
|
||||||
mozroots --import --sync
|
mozroots --import --sync
|
||||||
mono nuget.exe install src/{{{packageName}}}.Test/packages.config -o packages
|
mono nuget.exe install src/{{{packageName}}}.Test/packages.config -o packages
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
|
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
|
||||||
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
|
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator {{{generatorVersion}}}.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -79,8 +79,10 @@ export class {{classname}} {
|
|||||||
|
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
/**
|
/**
|
||||||
* {{summary}}
|
|
||||||
* {{notes}}
|
* {{notes}}
|
||||||
|
{{#summary}}
|
||||||
|
* @summary {{&summary}}
|
||||||
|
{{/summary}}
|
||||||
{{#allParams}}* @param {{paramName}} {{description}}
|
{{#allParams}}* @param {{paramName}} {{description}}
|
||||||
{{/allParams}}*/
|
{{/allParams}}*/
|
||||||
{{^isResponseFile}}
|
{{^isResponseFile}}
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
package io.swagger.codegen.eiffel;
|
||||||
|
|
||||||
|
import io.swagger.codegen.AbstractOptionsTest;
|
||||||
|
import io.swagger.codegen.CodegenConfig;
|
||||||
|
import io.swagger.codegen.languages.EiffelClientCodegen;
|
||||||
|
import io.swagger.codegen.options.EiffelClientOptionsProvider;
|
||||||
|
import mockit.Expectations;
|
||||||
|
import mockit.Tested;
|
||||||
|
|
||||||
|
public class EiffelClientOptionsTest extends AbstractOptionsTest {
|
||||||
|
|
||||||
|
@Tested
|
||||||
|
private EiffelClientCodegen clientCodegen;
|
||||||
|
|
||||||
|
public EiffelClientOptionsTest() {
|
||||||
|
super(new EiffelClientOptionsProvider());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CodegenConfig getCodegenConfig() {
|
||||||
|
return clientCodegen;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Override
|
||||||
|
protected void setExpectations() {
|
||||||
|
new Expectations(clientCodegen) {{
|
||||||
|
clientCodegen.setPackageName(EiffelClientOptionsProvider.PACKAGE_NAME_VALUE);
|
||||||
|
times = 1;
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,144 @@
|
|||||||
|
package io.swagger.codegen.eiffel;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import io.swagger.codegen.CodegenModel;
|
||||||
|
import io.swagger.codegen.CodegenProperty;
|
||||||
|
import io.swagger.codegen.DefaultCodegen;
|
||||||
|
import io.swagger.codegen.languages.EiffelClientCodegen;
|
||||||
|
import io.swagger.codegen.languages.KotlinClientCodegen;
|
||||||
|
import io.swagger.models.Model;
|
||||||
|
import io.swagger.models.ModelImpl;
|
||||||
|
import io.swagger.models.properties.ArrayProperty;
|
||||||
|
import io.swagger.models.properties.DateTimeProperty;
|
||||||
|
import io.swagger.models.properties.LongProperty;
|
||||||
|
import io.swagger.models.properties.MapProperty;
|
||||||
|
import io.swagger.models.properties.StringProperty;
|
||||||
|
|
||||||
|
@SuppressWarnings("static-method")
|
||||||
|
public class EiffelModelTest {
|
||||||
|
|
||||||
|
@Test(description = "convert a simple Eiffel model")
|
||||||
|
public void simpleModelTest() {
|
||||||
|
final Model model = new ModelImpl()
|
||||||
|
.description("a sample model")
|
||||||
|
.property("id", new LongProperty())
|
||||||
|
.property("name", new StringProperty())
|
||||||
|
.property("createdAt", new DateTimeProperty())
|
||||||
|
.required("id")
|
||||||
|
.required("name");
|
||||||
|
final DefaultCodegen codegen = new EiffelClientCodegen();
|
||||||
|
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||||
|
|
||||||
|
Assert.assertEquals(cm.name, "sample");
|
||||||
|
Assert.assertEquals(cm.classname, "SAMPLE");
|
||||||
|
Assert.assertEquals(cm.description, "a sample model");
|
||||||
|
Assert.assertEquals(cm.vars.size(), 3);
|
||||||
|
Assert.assertEquals(cm.imports.size(), 2);
|
||||||
|
|
||||||
|
final CodegenProperty property1 = cm.vars.get(0);
|
||||||
|
Assert.assertEquals(property1.baseName, "id");
|
||||||
|
Assert.assertEquals(property1.datatype, "INTEGER_64");
|
||||||
|
Assert.assertEquals(property1.name, "id");
|
||||||
|
Assert.assertEquals(property1.defaultValue, "null");
|
||||||
|
Assert.assertEquals(property1.baseType, "INTEGER_64");
|
||||||
|
Assert.assertTrue(property1.hasMore);
|
||||||
|
Assert.assertTrue(property1.required);
|
||||||
|
Assert.assertTrue(property1.isPrimitiveType);
|
||||||
|
Assert.assertTrue(property1.isNotContainer);
|
||||||
|
|
||||||
|
final CodegenProperty property2 = cm.vars.get(1);
|
||||||
|
Assert.assertEquals(property2.baseName, "name");
|
||||||
|
Assert.assertEquals(property2.datatype, "STRING_32");
|
||||||
|
Assert.assertEquals(property2.name, "name");
|
||||||
|
Assert.assertEquals(property1.defaultValue, "null");
|
||||||
|
Assert.assertEquals(property2.baseType, "STRING_32");
|
||||||
|
Assert.assertTrue(property2.hasMore);
|
||||||
|
Assert.assertTrue(property2.required);
|
||||||
|
Assert.assertFalse(property2.isPrimitiveType);
|
||||||
|
Assert.assertTrue(property2.isNotContainer);
|
||||||
|
|
||||||
|
final CodegenProperty property3 = cm.vars.get(2);
|
||||||
|
Assert.assertEquals(property3.baseName, "createdAt");
|
||||||
|
Assert.assertEquals(property3.complexType, "DATE_TIME");
|
||||||
|
Assert.assertEquals(property3.datatype, "DATE_TIME");
|
||||||
|
Assert.assertEquals(property3.name, "created_at");
|
||||||
|
Assert.assertEquals(property1.defaultValue, "null");
|
||||||
|
Assert.assertEquals(property3.baseType, "DATE_TIME");
|
||||||
|
Assert.assertFalse(property3.hasMore);
|
||||||
|
Assert.assertFalse(property3.required);
|
||||||
|
Assert.assertTrue(property3.isNotContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(description = "convert a model with list property")
|
||||||
|
public void listPropertyTest() {
|
||||||
|
final Model model = new ModelImpl()
|
||||||
|
.description("a sample model")
|
||||||
|
.property("id", new LongProperty())
|
||||||
|
.property("urls", new ArrayProperty()
|
||||||
|
.items(new StringProperty()))
|
||||||
|
.required("id");
|
||||||
|
final DefaultCodegen codegen = new EiffelClientCodegen();
|
||||||
|
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||||
|
|
||||||
|
Assert.assertEquals(cm.name, "sample");
|
||||||
|
Assert.assertEquals(cm.classname, "SAMPLE");
|
||||||
|
Assert.assertEquals(cm.description, "a sample model");
|
||||||
|
Assert.assertEquals(cm.vars.size(), 2);
|
||||||
|
|
||||||
|
final CodegenProperty property1 = cm.vars.get(0);
|
||||||
|
Assert.assertEquals(property1.baseName, "id");
|
||||||
|
Assert.assertEquals(property1.datatype, "INTEGER_64");
|
||||||
|
Assert.assertEquals(property1.name, "id");
|
||||||
|
Assert.assertEquals(property1.defaultValue, "null");
|
||||||
|
Assert.assertEquals(property1.baseType, "INTEGER_64");
|
||||||
|
Assert.assertTrue(property1.hasMore);
|
||||||
|
Assert.assertTrue(property1.required);
|
||||||
|
Assert.assertTrue(property1.isPrimitiveType);
|
||||||
|
Assert.assertTrue(property1.isNotContainer);
|
||||||
|
|
||||||
|
final CodegenProperty property2 = cm.vars.get(1);
|
||||||
|
Assert.assertEquals(property2.baseName, "urls");
|
||||||
|
Assert.assertEquals(property2.datatype, "LIST [STRING_32]");
|
||||||
|
Assert.assertEquals(property2.name, "urls");
|
||||||
|
Assert.assertEquals(property2.baseType, "LIST");
|
||||||
|
Assert.assertFalse(property2.hasMore);
|
||||||
|
Assert.assertEquals(property2.containerType, "array");
|
||||||
|
Assert.assertFalse(property2.required);
|
||||||
|
Assert.assertFalse(property2.isPrimitiveType);
|
||||||
|
Assert.assertTrue(property2.isContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test(description = "convert a model with a map property")
|
||||||
|
public void mapPropertyTest() {
|
||||||
|
final Model model = getMapModel();
|
||||||
|
final DefaultCodegen codegen = new EiffelClientCodegen();
|
||||||
|
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||||
|
|
||||||
|
Assert.assertEquals(cm.name, "sample");
|
||||||
|
Assert.assertEquals(cm.classname, "SAMPLE");
|
||||||
|
Assert.assertEquals(cm.description, "a sample model");
|
||||||
|
Assert.assertEquals(cm.vars.size(), 1);
|
||||||
|
|
||||||
|
final CodegenProperty property1 = cm.vars.get(0);
|
||||||
|
Assert.assertEquals(property1.baseName, "mapping");
|
||||||
|
Assert.assertEquals(property1.datatype, "STRING_TABLE[STRING_32]");
|
||||||
|
Assert.assertEquals(property1.name, "mapping");
|
||||||
|
Assert.assertEquals(property1.baseType, "STRING_TABLE");
|
||||||
|
Assert.assertEquals(property1.containerType, "map");
|
||||||
|
Assert.assertFalse(property1.required);
|
||||||
|
Assert.assertTrue(property1.isContainer);
|
||||||
|
Assert.assertFalse(property1.isPrimitiveType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Model getMapModel() {
|
||||||
|
return new ModelImpl()
|
||||||
|
.description("a sample model")
|
||||||
|
.property("mapping", new MapProperty()
|
||||||
|
.additionalProperties(new StringProperty()))
|
||||||
|
.required("id");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package io.swagger.codegen.options;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
import io.swagger.codegen.CodegenConstants;
|
||||||
|
|
||||||
|
public class EiffelClientOptionsProvider implements OptionsProvider {
|
||||||
|
|
||||||
|
public static final String PACKAGE_VERSION_VALUE = "1.0.0";
|
||||||
|
public static final String PACKAGE_NAME_VALUE = "Eiffel";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLanguage() {
|
||||||
|
return "eiffel";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> createOptions() {
|
||||||
|
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
|
||||||
|
return builder
|
||||||
|
.put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
|
||||||
|
.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
|
||||||
|
.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "true")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isServer() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
2.2.3-SNAPSHOT
|
@ -67,7 +67,7 @@ namespace Example
|
|||||||
{
|
{
|
||||||
public void main()
|
public void main()
|
||||||
{
|
{
|
||||||
|
|
||||||
var apiInstance = new FakeApi();
|
var apiInstance = new FakeApi();
|
||||||
var testCodeInjectEndRnNR = testCodeInjectEndRnNR_example; // string | To test code injection *_/ ' \" =end - - \\r\\n \\n \\r (optional)
|
var testCodeInjectEndRnNR = testCodeInjectEndRnNR_example; // string | To test code injection *_/ ' \" =end - - \\r\\n \\n \\r (optional)
|
||||||
|
|
||||||
@ -80,6 +80,7 @@ namespace Example
|
|||||||
{
|
{
|
||||||
Debug.Print("Exception when calling FakeApi.TestCodeInjectEndRnNR: " + e.Message );
|
Debug.Print("Exception when calling FakeApi.TestCodeInjectEndRnNR: " + e.Message );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
|
|
||||||
SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319
|
SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319
|
||||||
|
|
||||||
if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://nuget.org/nuget.exe', '.\nuget.exe')"
|
if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '.\nuget.exe')"
|
||||||
.\nuget.exe install src\IO.Swagger\packages.config -o packages
|
.\nuget.exe install src\IO.Swagger\packages.config -o packages
|
||||||
|
|
||||||
if not exist ".\bin" mkdir bin
|
if not exist ".\bin" mkdir bin
|
||||||
|
|
||||||
copy packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll
|
copy packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll bin\Newtonsoft.Json.dll
|
||||||
copy packages\RestSharp.105.1.0\lib\net45\RestSharp.dll bin\RestSharp.dll
|
copy packages\RestSharp.105.1.0\lib\net45\RestSharp.dll bin\RestSharp.dll
|
||||||
%CSCPATH%\csc /reference:bin\Newtonsoft.Json.dll;bin\RestSharp.dll;System.ComponentModel.DataAnnotations.dll /target:library /out:bin\IO.Swagger.dll /recurse:src\IO.Swagger\*.cs /doc:bin\IO.Swagger.xml
|
%CSCPATH%\csc /reference:bin\Newtonsoft.Json.dll;bin\RestSharp.dll;System.ComponentModel.DataAnnotations.dll /target:library /out:bin\IO.Swagger.dll /recurse:src\IO.Swagger\*.cs /doc:bin\IO.Swagger.xml
|
||||||
|
|
||||||
|
@ -9,13 +9,13 @@ netfx=${frameworkVersion#net}
|
|||||||
echo "[INFO] Target framework: ${frameworkVersion}"
|
echo "[INFO] Target framework: ${frameworkVersion}"
|
||||||
|
|
||||||
echo "[INFO] Download nuget and packages"
|
echo "[INFO] Download nuget and packages"
|
||||||
wget -nc https://nuget.org/nuget.exe;
|
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe;
|
||||||
mozroots --import --sync
|
mozroots --import --sync
|
||||||
mono nuget.exe install src/IO.Swagger/packages.config -o packages;
|
mono nuget.exe install src/IO.Swagger/packages.config -o packages;
|
||||||
|
|
||||||
echo "[INFO] Copy DLLs to the 'bin' folder"
|
echo "[INFO] Copy DLLs to the 'bin' folder"
|
||||||
mkdir -p bin;
|
mkdir -p bin;
|
||||||
cp packages/Newtonsoft.Json.8.0.3/lib/net45/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll;
|
cp packages/Newtonsoft.Json.10.0.3/lib/net45/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll;
|
||||||
cp packages/RestSharp.105.1.0/lib/net45/RestSharp.dll bin/RestSharp.dll;
|
cp packages/RestSharp.105.1.0/lib/net45/RestSharp.dll bin/RestSharp.dll;
|
||||||
|
|
||||||
echo "[INFO] Run 'mcs' to build bin/IO.Swagger.dll"
|
echo "[INFO] Run 'mcs' to build bin/IO.Swagger.dll"
|
||||||
|
@ -27,7 +27,6 @@ namespace Example
|
|||||||
{
|
{
|
||||||
public void main()
|
public void main()
|
||||||
{
|
{
|
||||||
|
|
||||||
var apiInstance = new FakeApi();
|
var apiInstance = new FakeApi();
|
||||||
var testCodeInjectEndRnNR = testCodeInjectEndRnNR_example; // string | To test code injection *_/ ' \" =end - - \\r\\n \\n \\r (optional)
|
var testCodeInjectEndRnNR = testCodeInjectEndRnNR_example; // string | To test code injection *_/ ' \" =end - - \\r\\n \\n \\r (optional)
|
||||||
|
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
# Generated by: https://github.com/swagger-api/swagger-codegen.git
|
# Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
#
|
#
|
||||||
|
|
||||||
wget -nc https://nuget.org/nuget.exe
|
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
|
||||||
mozroots --import --sync
|
mozroots --import --sync
|
||||||
|
|
||||||
echo "[INFO] remove bin/Debug/SwaggerClientTest.dll"
|
echo "[INFO] remove bin/Debug/SwaggerClientTest.dll"
|
||||||
rm src/IO.Swagger.Test/bin/Debug/IO.Swagger.Test.dll 2> /dev/null
|
rm src/IO.Swagger.Test/bin/Debug/IO.Swagger.Test.dll 2> /dev/null
|
||||||
|
|
||||||
echo "[INFO] install NUnit runners via NuGet"
|
echo "[INFO] install NUnit runners via NuGet"
|
||||||
wget -nc https://nuget.org/nuget.exe
|
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
|
||||||
mozroots --import --sync
|
mozroots --import --sync
|
||||||
mono nuget.exe install src/IO.Swagger.Test/packages.config -o packages
|
mono nuget.exe install src/IO.Swagger.Test/packages.config -o packages
|
||||||
|
|
||||||
|
@ -47,10 +47,10 @@ Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r
|
|||||||
<Reference Include="System.Runtime.Serialization" />
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="Newtonsoft.Json">
|
<Reference Include="Newtonsoft.Json">
|
||||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="RestSharp">
|
<Reference Include="RestSharp">
|
||||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||||
@ -66,7 +66,8 @@ Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="**\*.cs"/>
|
<Compile Include="**\*.cs"
|
||||||
|
Exclude="obj\**"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
<packages>
|
<packages>
|
||||||
<package id="NUnit" version="2.6.4" targetFramework="net45" />
|
<package id="NUnit" version="2.6.4" targetFramework="net45" />
|
||||||
<package id="RestSharp" version="105.1.0" targetFramework="net45" developmentDependency="true" />
|
<package id="RestSharp" version="105.1.0" targetFramework="net45" developmentDependency="true" />
|
||||||
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" developmentDependency="true" />
|
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" developmentDependency="true" />
|
||||||
</packages>
|
</packages>
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Swagger Petstore *_/ ' \" =end - - \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end - -
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end - - \\r\\n \\n \\r
|
||||||
|
* Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r
|
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
*/
|
||||||
|
|
||||||
|
using Newtonsoft.Json.Converters;
|
||||||
|
|
||||||
|
namespace IO.Swagger.Client
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Formatter for 'date' swagger formats ss defined by full-date - RFC3339
|
||||||
|
/// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types
|
||||||
|
/// </summary>
|
||||||
|
public class SwaggerDateConverter : IsoDateTimeConverter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="SwaggerDateConverter" /> class.
|
||||||
|
/// </summary>
|
||||||
|
public SwaggerDateConverter()
|
||||||
|
{
|
||||||
|
// full-date = date-fullyear "-" date-month "-" date-mday
|
||||||
|
DateTimeFormat = "yyyy-MM-dd";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -48,10 +48,10 @@ Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r
|
|||||||
<Reference Include="System.Runtime.Serialization" />
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="Newtonsoft.Json">
|
<Reference Include="Newtonsoft.Json">
|
||||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="RestSharp">
|
<Reference Include="RestSharp">
|
||||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||||
@ -59,17 +59,14 @@ Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r
|
|||||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
<HintPath Condition="Exists('..\..\packages')">..\..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Api\**\*.cs"/>
|
<Compile Include="**\*.cs"
|
||||||
<Compile Include="Client\**\*.cs"/>
|
Exclude="obj\**" />
|
||||||
<Compile Include="Model\**\*.cs"/>
|
|
||||||
<Compile Include="Properties\**\*.cs"/>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets" /></Project>
|
<Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
<!-- Dependencies are automatically installed when the package is installed -->
|
<!-- Dependencies are automatically installed when the package is installed -->
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency id="NewtonSoft.Json" version="8.0.3" />
|
<dependency id="NewtonSoft.Json" version="10.0.3" />
|
||||||
<dependency id="RestSharp" version="105.1.0" />
|
<dependency id="RestSharp" version="105.1.0" />
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -36,5 +36,6 @@
|
|||||||
<!-- A readme.txt will be displayed when the package is installed -->
|
<!-- A readme.txt will be displayed when the package is installed -->
|
||||||
<file src="..\..\README.md" target="" />
|
<file src="..\..\README.md" target="" />
|
||||||
<file src="..\..\docs\**\*.*" target="docs" />
|
<file src="..\..\docs\**\*.*" target="docs" />
|
||||||
|
|
||||||
</files>
|
</files>
|
||||||
</package>
|
</package>
|
||||||
|
@ -20,6 +20,7 @@ using System.Runtime.Serialization;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
|
||||||
|
|
||||||
namespace IO.Swagger.Model
|
namespace IO.Swagger.Model
|
||||||
{
|
{
|
||||||
@ -44,6 +45,7 @@ namespace IO.Swagger.Model
|
|||||||
/// <value>property description *_/ ' \" =end - - \\r\\n \\n \\r</value>
|
/// <value>property description *_/ ' \" =end - - \\r\\n \\n \\r</value>
|
||||||
[DataMember(Name="return", EmitDefaultValue=false)]
|
[DataMember(Name="return", EmitDefaultValue=false)]
|
||||||
public int? _Return { get; set; }
|
public int? _Return { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the string presentation of the object
|
/// Returns the string presentation of the object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="RestSharp" version="105.1.0" targetFramework="net45" developmentDependency="true" />
|
<package id="RestSharp" version="105.1.0" targetFramework="net45" developmentDependency="true" />
|
||||||
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" developmentDependency="true" />
|
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" developmentDependency="true" />
|
||||||
</packages>
|
</packages>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* OpenAPI spec version: 1.0.0
|
* OpenAPI spec version: 1.0.0
|
||||||
* Contact: apiteam@swagger.io
|
* Contact: apiteam@swagger.io
|
||||||
*
|
*
|
||||||
* NOTE: This class is auto generated by the swagger code generator program.
|
* NOTE: This class is auto generated by the swagger code generator 2.2.3-SNAPSHOT.
|
||||||
* https://github.com/swagger-api/swagger-codegen.git
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
* Do not edit the class manually.
|
* Do not edit the class manually.
|
||||||
*/
|
*/
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
wget -nc https://nuget.org/nuget.exe;
|
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe;
|
||||||
mozroots --import --sync
|
mozroots --import --sync
|
||||||
mono nuget.exe install vendor/packages.config -o vendor;
|
mono nuget.exe install vendor/packages.config -o vendor;
|
||||||
mkdir -p bin;
|
mkdir -p bin;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319
|
SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319
|
||||||
|
|
||||||
if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://nuget.org/nuget.exe', '.\nuget.exe')"
|
if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '.\nuget.exe')"
|
||||||
.\nuget.exe install src\IO.Swagger\packages.config -o packages
|
.\nuget.exe install src\IO.Swagger\packages.config -o packages
|
||||||
|
|
||||||
if not exist ".\bin" mkdir bin
|
if not exist ".\bin" mkdir bin
|
||||||
|
@ -9,7 +9,7 @@ netfx=${frameworkVersion#net}
|
|||||||
echo "[INFO] Target framework: ${frameworkVersion}"
|
echo "[INFO] Target framework: ${frameworkVersion}"
|
||||||
|
|
||||||
echo "[INFO] Download nuget and packages"
|
echo "[INFO] Download nuget and packages"
|
||||||
wget -nc https://nuget.org/nuget.exe;
|
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe;
|
||||||
mozroots --import --sync
|
mozroots --import --sync
|
||||||
mono nuget.exe install src/IO.Swagger/packages.config -o packages;
|
mono nuget.exe install src/IO.Swagger/packages.config -o packages;
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ namespace Example
|
|||||||
var number = 3.4; // decimal? | None
|
var number = 3.4; // decimal? | None
|
||||||
var _double = 1.2; // double? | None
|
var _double = 1.2; // double? | None
|
||||||
var patternWithoutDelimiter = patternWithoutDelimiter_example; // string | None
|
var patternWithoutDelimiter = patternWithoutDelimiter_example; // string | None
|
||||||
var _byte = B; // byte[] | None
|
var _byte = _byte_example; // byte[] | None
|
||||||
var integer = 56; // int? | None (optional)
|
var integer = 56; // int? | None (optional)
|
||||||
var int32 = 56; // int? | None (optional)
|
var int32 = 56; // int? | None (optional)
|
||||||
var int64 = 789; // long? | None (optional)
|
var int64 = 789; // long? | None (optional)
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
# Generated by: https://github.com/swagger-api/swagger-codegen.git
|
# Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
#
|
#
|
||||||
|
|
||||||
wget -nc https://nuget.org/nuget.exe
|
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
|
||||||
mozroots --import --sync
|
mozroots --import --sync
|
||||||
|
|
||||||
echo "[INFO] remove bin/Debug/SwaggerClientTest.dll"
|
echo "[INFO] remove bin/Debug/SwaggerClientTest.dll"
|
||||||
rm src/IO.Swagger.Test/bin/Debug/IO.Swagger.Test.dll 2> /dev/null
|
rm src/IO.Swagger.Test/bin/Debug/IO.Swagger.Test.dll 2> /dev/null
|
||||||
|
|
||||||
echo "[INFO] install NUnit runners via NuGet"
|
echo "[INFO] install NUnit runners via NuGet"
|
||||||
wget -nc https://nuget.org/nuget.exe
|
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
|
||||||
mozroots --import --sync
|
mozroots --import --sync
|
||||||
mono nuget.exe install src/IO.Swagger.Test/packages.config -o packages
|
mono nuget.exe install src/IO.Swagger.Test/packages.config -o packages
|
||||||
|
|
||||||
|
@ -415,7 +415,14 @@ namespace IO.Swagger.Model
|
|||||||
Regex regex_String = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
|
Regex regex_String = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
|
||||||
if (false == regex_String.Match(this._String).Success)
|
if (false == regex_String.Match(this._String).Success)
|
||||||
{
|
{
|
||||||
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for _String, must match a pattern of /[a-z]/i.", new [] { "_String" });
|
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for _String, must match a pattern of " + regex_String, new [] { "_String" });
|
||||||
|
}
|
||||||
|
|
||||||
|
// _Byte (byte[]) pattern
|
||||||
|
Regex regex_Byte = new Regex(@"^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$", RegexOptions.CultureInvariant);
|
||||||
|
if (false == regex_Byte.Match(this._Byte).Success)
|
||||||
|
{
|
||||||
|
yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for _Byte, must match a pattern of /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.", new [] { "_Byte" });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Password (string) maxLength
|
// Password (string) maxLength
|
||||||
|
@ -344,7 +344,7 @@ namespace Example
|
|||||||
var number = 3.4; // decimal? | None
|
var number = 3.4; // decimal? | None
|
||||||
var _double = 1.2; // double? | None
|
var _double = 1.2; // double? | None
|
||||||
var patternWithoutDelimiter = patternWithoutDelimiter_example; // string | None
|
var patternWithoutDelimiter = patternWithoutDelimiter_example; // string | None
|
||||||
var _byte = B; // byte[] | None
|
var _byte = _byte_example; // byte[] | None
|
||||||
var integer = 56; // int? | None (optional)
|
var integer = 56; // int? | None (optional)
|
||||||
var int32 = 56; // int? | None (optional)
|
var int32 = 56; // int? | None (optional)
|
||||||
var int64 = 789; // long? | None (optional)
|
var int64 = 789; // long? | None (optional)
|
||||||
|
@ -345,7 +345,7 @@ namespace Example
|
|||||||
var number = 3.4; // decimal? | None
|
var number = 3.4; // decimal? | None
|
||||||
var _double = 1.2; // double? | None
|
var _double = 1.2; // double? | None
|
||||||
var patternWithoutDelimiter = patternWithoutDelimiter_example; // string | None
|
var patternWithoutDelimiter = patternWithoutDelimiter_example; // string | None
|
||||||
var _byte = B; // byte[] | None
|
var _byte = _byte_example; // byte[] | None
|
||||||
var integer = 56; // int? | None (optional)
|
var integer = 56; // int? | None (optional)
|
||||||
var int32 = 56; // int? | None (optional)
|
var int32 = 56; // int? | None (optional)
|
||||||
var int64 = 789; // long? | None (optional)
|
var int64 = 789; // long? | None (optional)
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319
|
SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319
|
||||||
|
|
||||||
if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://nuget.org/nuget.exe', '.\nuget.exe')"
|
if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '.\nuget.exe')"
|
||||||
.\nuget.exe install src\IO.Swagger\packages.config -o packages
|
.\nuget.exe install src\IO.Swagger\packages.config -o packages
|
||||||
|
|
||||||
if not exist ".\bin" mkdir bin
|
if not exist ".\bin" mkdir bin
|
||||||
|
@ -9,7 +9,7 @@ netfx=${frameworkVersion#net}
|
|||||||
echo "[INFO] Target framework: ${frameworkVersion}"
|
echo "[INFO] Target framework: ${frameworkVersion}"
|
||||||
|
|
||||||
echo "[INFO] Download nuget and packages"
|
echo "[INFO] Download nuget and packages"
|
||||||
wget -nc https://nuget.org/nuget.exe;
|
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe;
|
||||||
mozroots --import --sync
|
mozroots --import --sync
|
||||||
mono nuget.exe install src/IO.Swagger/packages.config -o packages;
|
mono nuget.exe install src/IO.Swagger/packages.config -o packages;
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user