Skip to content

Commit 0809d8f

Browse files
authored
[C++][Restbed/Pistache] Added fix for byte array (#752)
* Added fix for byte array * Fix spacing * Adapted default value for ByteArray * Adapted default value for ByteArray in Pistache Server
1 parent baf16cf commit 0809d8f

21 files changed

Lines changed: 25 additions & 20 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public String toDefaultValue(Schema p) {
341341
return "0";
342342
}
343343
else if (ModelUtils.isByteArraySchema(p)) {
344-
return "";
344+
return "\"\"";
345345
} else if (ModelUtils.isMapSchema(p)) {
346346
String inner = getSchemaType((Schema) p.getAdditionalProperties());
347347
return "std::map<std::string, " + inner + ">()";

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestbedServerCodegen.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public CppRestbedServerCodegen() {
9090
typeMapping.put("binary", "restbed::Bytes");
9191
typeMapping.put("number", "double");
9292
typeMapping.put("UUID", "std::string");
93+
typeMapping.put("ByteArray", "std::string");
9394

9495
super.importMapping = new HashMap<String, String>();
9596
importMapping.put("std::vector", "#include <vector>");
@@ -271,6 +272,8 @@ public String getTypeDeclaration(Schema p) {
271272
} else if (ModelUtils.isMapSchema(p)) {
272273
Schema inner = (Schema) p.getAdditionalProperties();
273274
return getSchemaType(p) + "<std::string, " + getTypeDeclaration(inner) + ">";
275+
} else if (ModelUtils.isByteArraySchema(p)) {
276+
return "std::string";
274277
} else if (ModelUtils.isStringSchema(p)
275278
|| ModelUtils.isDateSchema(p)
276279
|| ModelUtils.isDateTimeSchema(p) || ModelUtils.isFileSchema(p)
@@ -301,6 +304,8 @@ public String toDefaultValue(Schema p) {
301304
return "0L";
302305
}
303306
return "0";
307+
} else if (ModelUtils.isByteArraySchema(p)) {
308+
return "\"\"";
304309
} else if (ModelUtils.isMapSchema(p)) {
305310
String inner = getSchemaType((Schema) p.getAdditionalProperties());
306311
return "std::map<std::string, " + inner + ">()";
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0-SNAPSHOT
1+
3.2.1-SNAPSHOT

samples/server/petstore/cpp-restbed/api/PetApi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* OpenAPI spec version: 1.0.0
66
*
77
*
8-
* NOTE: This class is auto generated by OpenAPI-Generator 3.0.0-SNAPSHOT.
8+
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
99
* https://openapi-generator.tech
1010
* Do not edit the class manually.
1111
*/

samples/server/petstore/cpp-restbed/api/PetApi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* OpenAPI spec version: 1.0.0
66
*
77
*
8-
* NOTE: This class is auto generated by OpenAPI-Generator 3.0.0-SNAPSHOT.
8+
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
99
* https://openapi-generator.tech
1010
* Do not edit the class manually.
1111
*/

samples/server/petstore/cpp-restbed/api/StoreApi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* OpenAPI spec version: 1.0.0
66
*
77
*
8-
* NOTE: This class is auto generated by OpenAPI-Generator 3.0.0-SNAPSHOT.
8+
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
99
* https://openapi-generator.tech
1010
* Do not edit the class manually.
1111
*/

samples/server/petstore/cpp-restbed/api/StoreApi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* OpenAPI spec version: 1.0.0
66
*
77
*
8-
* NOTE: This class is auto generated by OpenAPI-Generator 3.0.0-SNAPSHOT.
8+
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
99
* https://openapi-generator.tech
1010
* Do not edit the class manually.
1111
*/

samples/server/petstore/cpp-restbed/api/UserApi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* OpenAPI spec version: 1.0.0
66
*
77
*
8-
* NOTE: This class is auto generated by OpenAPI-Generator 3.0.0-SNAPSHOT.
8+
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
99
* https://openapi-generator.tech
1010
* Do not edit the class manually.
1111
*/

samples/server/petstore/cpp-restbed/api/UserApi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* OpenAPI spec version: 1.0.0
66
*
77
*
8-
* NOTE: This class is auto generated by OpenAPI-Generator 3.0.0-SNAPSHOT.
8+
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
99
* https://openapi-generator.tech
1010
* Do not edit the class manually.
1111
*/

samples/server/petstore/cpp-restbed/model/ApiResponse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* OpenAPI spec version: 1.0.0
66
*
77
*
8-
* NOTE: This class is auto generated by OpenAPI-Generator 3.0.0-SNAPSHOT.
8+
* NOTE: This class is auto generated by OpenAPI-Generator 3.2.1-SNAPSHOT.
99
* https://openapi-generator.tech
1010
* Do not edit the class manually.
1111
*/

0 commit comments

Comments
 (0)