mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 22:50:53 +00:00
Merge branch 'master' of https://github.com/swagger-api/swagger-codegen
This commit is contained in:
commit
2ef65d1488
@ -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**, **Ada**, **Apex**, **Bash**, **C#** (.net 2.0, 4.0 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Eiffel**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust**, **Scala** (akka, http4s, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (Angular1.x, Angular2.x, Fetch, jQuery, Node)
|
- **API clients**: **ActionScript**, **Ada**, **Apex**, **Bash**, **C#** (.net 2.0, 4.0 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java), **Kotlin**, **Lua**, **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust**, **Scala** (akka, http4s, swagger-async-httpclient), **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** (Servant), **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), **Rust**, **Scala** ([Finch](https://github.com/finagle/finch), Scalatra)
|
- **Server stubs**: **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell** (Servant), **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), **Rust**, **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/)
|
||||||
@ -976,6 +976,7 @@ Here is a list of template creators:
|
|||||||
* Dart: @yissachar
|
* Dart: @yissachar
|
||||||
* Elixir: @niku
|
* Elixir: @niku
|
||||||
* Eiffel: @jvelilla
|
* Eiffel: @jvelilla
|
||||||
|
* Erlang: @tsloughter
|
||||||
* Groovy: @victorgit
|
* Groovy: @victorgit
|
||||||
* Go: @wing328
|
* Go: @wing328
|
||||||
* Go (rewritten in 2.3.0): @antihax
|
* Go (rewritten in 2.3.0): @antihax
|
||||||
|
@ -58,11 +58,27 @@ void
|
|||||||
void
|
void
|
||||||
{{classname}}::fromJsonObject(QJsonObject &pJson) {
|
{{classname}}::fromJsonObject(QJsonObject &pJson) {
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{^isContainer}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}");{{/isContainer}}
|
{{^isContainer}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}");{{/isContainer}}
|
||||||
{{#isContainer}}
|
{{#isListContainer}}
|
||||||
{{#complexType}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}");{{/complexType}}
|
{{#complexType}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}");{{/complexType}}
|
||||||
{{^complexType}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{items.baseType}}");{{/complexType}}
|
{{^complexType}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{items.baseType}}");{{/complexType}}
|
||||||
{{/isContainer}}
|
{{/isListContainer}}
|
||||||
|
{{#isMapContainer}}
|
||||||
|
if( pJson["{{baseName}}"].isObject()){
|
||||||
|
auto varmap = pJson["{{baseName}}"].toObject().toVariantMap();
|
||||||
|
if(varmap.count() > 0){
|
||||||
|
for(auto val : varmap.keys() ){
|
||||||
|
{
|
||||||
|
{{items.baseType}} *{{name}}_item = new {{items.baseType}}();
|
||||||
|
auto jsonval = QJsonValue::fromVariant(varmap[val]);
|
||||||
|
::{{cppNamespace}}::setValue(&{{name}}_item, jsonval, "{{items.baseType}}", "{{items.baseType}}");
|
||||||
|
{{name}}->insert({{name}}->end(), val, {{name}}_item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isMapContainer}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,14 +99,28 @@ QJsonObject*
|
|||||||
toJsonValue(QString("{{baseName}}"), {{name}}, obj, QString("{{complexType}}"));{{/complexType}}{{^complexType}}
|
toJsonValue(QString("{{baseName}}"), {{name}}, obj, QString("{{complexType}}"));{{/complexType}}{{^complexType}}
|
||||||
if({{name}} != nullptr && *{{name}} != nullptr) {
|
if({{name}} != nullptr && *{{name}} != nullptr) {
|
||||||
obj->insert("{{name}}", QJsonValue(*{{name}}));
|
obj->insert("{{name}}", QJsonValue(*{{name}}));
|
||||||
}{{/complexType}}{{/isContainer}}{{#isContainer}}
|
}{{/complexType}}{{/isContainer}}{{#isListContainer}}
|
||||||
QJsonArray {{name}}JsonArray;
|
QJsonArray {{name}}JsonArray;
|
||||||
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{complexType}}");
|
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{complexType}}");
|
||||||
obj->insert("{{baseName}}", {{name}}JsonArray);{{/isContainer}}{{/complexType}}{{^complexType}}{{^isContainer}}
|
obj->insert("{{baseName}}", {{name}}JsonArray);{{/isListContainer}}{{#isMapContainer}}
|
||||||
obj->insert("{{baseName}}", QJsonValue({{name}}));{{/isContainer}}{{#isContainer}}
|
QJsonArray {{name}}JsonArray;
|
||||||
|
for(auto keyval : {{name}}->keys()){
|
||||||
|
QJsonObject {{name}}_jobj;
|
||||||
|
toJsonValue(keyval, ((*{{name}})[keyval]), &{{name}}_jobj, "{{complexType}}");
|
||||||
|
{{name}}JsonArray.append({{name}}_jobj);
|
||||||
|
}
|
||||||
|
obj->insert("{{baseName}}", {{name}}JsonArray);{{/isMapContainer}}{{/complexType}}{{^complexType}}{{^isContainer}}
|
||||||
|
obj->insert("{{baseName}}", QJsonValue({{name}}));{{/isContainer}}{{#isListContainer}}
|
||||||
QJsonArray {{name}}JsonArray;
|
QJsonArray {{name}}JsonArray;
|
||||||
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{items.baseType}}");
|
toJsonArray((QList<void*>*){{name}}, &{{name}}JsonArray, "{{name}}", "{{items.baseType}}");
|
||||||
obj->insert("{{baseName}}", {{name}}JsonArray);{{/isContainer}}{{/complexType}}
|
obj->insert("{{baseName}}", {{name}}JsonArray);{{/isListContainer}}{{#isMapContainer}}
|
||||||
|
QJsonArray {{name}}JsonArray;
|
||||||
|
for(auto keyval : {{name}}->keys()){
|
||||||
|
QJsonObject {{name}}_jobj;
|
||||||
|
toJsonValue(keyval, ((*{{name}})[keyval]), &{{name}}_jobj, "{{items.baseType}}");
|
||||||
|
{{name}}JsonArray.append(portsobj);
|
||||||
|
}
|
||||||
|
obj->insert("{{baseName}}", {{name}}JsonArray);{{/isMapContainer}}{{/complexType}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user