From 8a1b030ed16ff4e81ee4558a411c8224eb4b6d2e Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 13 Jul 2017 17:02:45 +0800 Subject: [PATCH 01/10] add zooplus --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 76855c8c0a0..71be1740139 100644 --- a/README.md +++ b/README.md @@ -839,6 +839,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you - [Yelp](http://www.yelp.com/) - [Zalando](https://tech.zalando.com) - [ZEEF.com](https://zeef.com/) +- [zooplus](https://www.zooplus.com/) Presentations/Videos/Tutorials/Books ---------------------------------------- From 9d4ebf6998236bc6887927e8acbea4677a40f61d Mon Sep 17 00:00:00 2001 From: stkrwork Date: Thu, 13 Jul 2017 11:31:23 +0200 Subject: [PATCH 02/10] Swagger version info (#6038) --- .../src/main/resources/restbed/licenseInfo.mustache | 2 +- samples/server/petstore/restbed/api/PetApi.cpp | 2 +- samples/server/petstore/restbed/api/PetApi.h | 2 +- samples/server/petstore/restbed/api/StoreApi.cpp | 2 +- samples/server/petstore/restbed/api/StoreApi.h | 2 +- samples/server/petstore/restbed/api/UserApi.cpp | 2 +- samples/server/petstore/restbed/api/UserApi.h | 2 +- samples/server/petstore/restbed/model/ApiResponse.cpp | 2 +- samples/server/petstore/restbed/model/ApiResponse.h | 2 +- samples/server/petstore/restbed/model/Category.cpp | 2 +- samples/server/petstore/restbed/model/Category.h | 2 +- samples/server/petstore/restbed/model/Order.cpp | 2 +- samples/server/petstore/restbed/model/Order.h | 2 +- samples/server/petstore/restbed/model/Pet.cpp | 2 +- samples/server/petstore/restbed/model/Pet.h | 2 +- samples/server/petstore/restbed/model/Tag.cpp | 2 +- samples/server/petstore/restbed/model/Tag.h | 2 +- samples/server/petstore/restbed/model/User.cpp | 2 +- samples/server/petstore/restbed/model/User.h | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/restbed/licenseInfo.mustache b/modules/swagger-codegen/src/main/resources/restbed/licenseInfo.mustache index bbd8742e52a..2931118038b 100644 --- a/modules/swagger-codegen/src/main/resources/restbed/licenseInfo.mustache +++ b/modules/swagger-codegen/src/main/resources/restbed/licenseInfo.mustache @@ -5,7 +5,7 @@ * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} * {{#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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/api/PetApi.cpp b/samples/server/petstore/restbed/api/PetApi.cpp index 06214eee575..3dc61c1d66b 100644 --- a/samples/server/petstore/restbed/api/PetApi.cpp +++ b/samples/server/petstore/restbed/api/PetApi.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/api/PetApi.h b/samples/server/petstore/restbed/api/PetApi.h index 85c8e53ae75..c818ca6d2a4 100644 --- a/samples/server/petstore/restbed/api/PetApi.h +++ b/samples/server/petstore/restbed/api/PetApi.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/api/StoreApi.cpp b/samples/server/petstore/restbed/api/StoreApi.cpp index 38bb1b836d7..4e44f96bb1a 100644 --- a/samples/server/petstore/restbed/api/StoreApi.cpp +++ b/samples/server/petstore/restbed/api/StoreApi.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/api/StoreApi.h b/samples/server/petstore/restbed/api/StoreApi.h index 9000e500faf..4fbed3ffb3a 100644 --- a/samples/server/petstore/restbed/api/StoreApi.h +++ b/samples/server/petstore/restbed/api/StoreApi.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/api/UserApi.cpp b/samples/server/petstore/restbed/api/UserApi.cpp index adaba834175..558519746a6 100644 --- a/samples/server/petstore/restbed/api/UserApi.cpp +++ b/samples/server/petstore/restbed/api/UserApi.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/api/UserApi.h b/samples/server/petstore/restbed/api/UserApi.h index 0b8da3504ac..95ab6c5a7a0 100644 --- a/samples/server/petstore/restbed/api/UserApi.h +++ b/samples/server/petstore/restbed/api/UserApi.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/model/ApiResponse.cpp b/samples/server/petstore/restbed/model/ApiResponse.cpp index eafab8702bc..63b89a4b932 100644 --- a/samples/server/petstore/restbed/model/ApiResponse.cpp +++ b/samples/server/petstore/restbed/model/ApiResponse.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/model/ApiResponse.h b/samples/server/petstore/restbed/model/ApiResponse.h index acfe2f0b36f..122621cfb31 100644 --- a/samples/server/petstore/restbed/model/ApiResponse.h +++ b/samples/server/petstore/restbed/model/ApiResponse.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/model/Category.cpp b/samples/server/petstore/restbed/model/Category.cpp index 34f0bf8af0b..ff89a04951a 100644 --- a/samples/server/petstore/restbed/model/Category.cpp +++ b/samples/server/petstore/restbed/model/Category.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/model/Category.h b/samples/server/petstore/restbed/model/Category.h index 862294647c8..b72d5980184 100644 --- a/samples/server/petstore/restbed/model/Category.h +++ b/samples/server/petstore/restbed/model/Category.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/model/Order.cpp b/samples/server/petstore/restbed/model/Order.cpp index 4c14639d10f..47944f96852 100644 --- a/samples/server/petstore/restbed/model/Order.cpp +++ b/samples/server/petstore/restbed/model/Order.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/model/Order.h b/samples/server/petstore/restbed/model/Order.h index e84f11e37c2..e7de9e60b55 100644 --- a/samples/server/petstore/restbed/model/Order.h +++ b/samples/server/petstore/restbed/model/Order.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/model/Pet.cpp b/samples/server/petstore/restbed/model/Pet.cpp index 9f4ce7d6146..76d84be4244 100644 --- a/samples/server/petstore/restbed/model/Pet.cpp +++ b/samples/server/petstore/restbed/model/Pet.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/model/Pet.h b/samples/server/petstore/restbed/model/Pet.h index 88d223a4c3f..6e55fa78749 100644 --- a/samples/server/petstore/restbed/model/Pet.h +++ b/samples/server/petstore/restbed/model/Pet.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/model/Tag.cpp b/samples/server/petstore/restbed/model/Tag.cpp index ac2fb1f3f4b..18c712ddd55 100644 --- a/samples/server/petstore/restbed/model/Tag.cpp +++ b/samples/server/petstore/restbed/model/Tag.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/model/Tag.h b/samples/server/petstore/restbed/model/Tag.h index 94967dda755..34900de06a1 100644 --- a/samples/server/petstore/restbed/model/Tag.h +++ b/samples/server/petstore/restbed/model/Tag.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/model/User.cpp b/samples/server/petstore/restbed/model/User.cpp index d80b59b38e3..bf14eea0a8d 100644 --- a/samples/server/petstore/restbed/model/User.cpp +++ b/samples/server/petstore/restbed/model/User.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/server/petstore/restbed/model/User.h b/samples/server/petstore/restbed/model/User.h index 0ec05539732..33764f060bb 100644 --- a/samples/server/petstore/restbed/model/User.h +++ b/samples/server/petstore/restbed/model/User.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ From 4f33a028685c955b2653003ca41e7174c2f75105 Mon Sep 17 00:00:00 2001 From: stkrwork Date: Thu, 13 Jul 2017 11:32:24 +0200 Subject: [PATCH 03/10] Swagger version info (#6039) --- .../src/main/resources/cpprest/licenseInfo.mustache | 2 +- samples/client/petstore/cpprest/ApiClient.cpp | 2 +- samples/client/petstore/cpprest/ApiClient.h | 2 +- samples/client/petstore/cpprest/ApiConfiguration.cpp | 2 +- samples/client/petstore/cpprest/ApiConfiguration.h | 2 +- samples/client/petstore/cpprest/ApiException.cpp | 2 +- samples/client/petstore/cpprest/ApiException.h | 2 +- samples/client/petstore/cpprest/HttpContent.cpp | 2 +- samples/client/petstore/cpprest/HttpContent.h | 2 +- samples/client/petstore/cpprest/IHttpBody.h | 2 +- samples/client/petstore/cpprest/JsonBody.cpp | 2 +- samples/client/petstore/cpprest/JsonBody.h | 2 +- samples/client/petstore/cpprest/ModelBase.cpp | 2 +- samples/client/petstore/cpprest/ModelBase.h | 2 +- samples/client/petstore/cpprest/MultipartFormData.cpp | 2 +- samples/client/petstore/cpprest/MultipartFormData.h | 2 +- samples/client/petstore/cpprest/api/PetApi.cpp | 2 +- samples/client/petstore/cpprest/api/PetApi.h | 2 +- samples/client/petstore/cpprest/api/StoreApi.cpp | 2 +- samples/client/petstore/cpprest/api/StoreApi.h | 2 +- samples/client/petstore/cpprest/api/UserApi.cpp | 2 +- samples/client/petstore/cpprest/api/UserApi.h | 2 +- samples/client/petstore/cpprest/model/ApiResponse.cpp | 2 +- samples/client/petstore/cpprest/model/ApiResponse.h | 2 +- samples/client/petstore/cpprest/model/Category.cpp | 2 +- samples/client/petstore/cpprest/model/Category.h | 2 +- samples/client/petstore/cpprest/model/Order.cpp | 2 +- samples/client/petstore/cpprest/model/Order.h | 2 +- samples/client/petstore/cpprest/model/Pet.cpp | 2 +- samples/client/petstore/cpprest/model/Pet.h | 2 +- samples/client/petstore/cpprest/model/Tag.cpp | 2 +- samples/client/petstore/cpprest/model/Tag.h | 2 +- samples/client/petstore/cpprest/model/User.cpp | 2 +- samples/client/petstore/cpprest/model/User.h | 2 +- 34 files changed, 34 insertions(+), 34 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/cpprest/licenseInfo.mustache b/modules/swagger-codegen/src/main/resources/cpprest/licenseInfo.mustache index bbd8742e52a..2931118038b 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/licenseInfo.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/licenseInfo.mustache @@ -5,7 +5,7 @@ * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} * {{#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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/ApiClient.cpp b/samples/client/petstore/cpprest/ApiClient.cpp index 69de9e34f95..365e56c7860 100644 --- a/samples/client/petstore/cpprest/ApiClient.cpp +++ b/samples/client/petstore/cpprest/ApiClient.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/ApiClient.h b/samples/client/petstore/cpprest/ApiClient.h index 1f38c864f0e..f6ad8e2d76e 100644 --- a/samples/client/petstore/cpprest/ApiClient.h +++ b/samples/client/petstore/cpprest/ApiClient.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/ApiConfiguration.cpp b/samples/client/petstore/cpprest/ApiConfiguration.cpp index 1520a56d347..5e49ae49aac 100644 --- a/samples/client/petstore/cpprest/ApiConfiguration.cpp +++ b/samples/client/petstore/cpprest/ApiConfiguration.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/ApiConfiguration.h b/samples/client/petstore/cpprest/ApiConfiguration.h index 0574783f690..76d485a7224 100644 --- a/samples/client/petstore/cpprest/ApiConfiguration.h +++ b/samples/client/petstore/cpprest/ApiConfiguration.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/ApiException.cpp b/samples/client/petstore/cpprest/ApiException.cpp index 5ddf808f9f0..f679ef8f3f7 100644 --- a/samples/client/petstore/cpprest/ApiException.cpp +++ b/samples/client/petstore/cpprest/ApiException.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/ApiException.h b/samples/client/petstore/cpprest/ApiException.h index 835752ea75b..ba75120a06b 100644 --- a/samples/client/petstore/cpprest/ApiException.h +++ b/samples/client/petstore/cpprest/ApiException.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/HttpContent.cpp b/samples/client/petstore/cpprest/HttpContent.cpp index e9a619d7753..df37e526df8 100644 --- a/samples/client/petstore/cpprest/HttpContent.cpp +++ b/samples/client/petstore/cpprest/HttpContent.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/HttpContent.h b/samples/client/petstore/cpprest/HttpContent.h index 6b7bae0a5f7..b2ccea73103 100644 --- a/samples/client/petstore/cpprest/HttpContent.h +++ b/samples/client/petstore/cpprest/HttpContent.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/IHttpBody.h b/samples/client/petstore/cpprest/IHttpBody.h index 0ccf80876e9..fede57e11a6 100644 --- a/samples/client/petstore/cpprest/IHttpBody.h +++ b/samples/client/petstore/cpprest/IHttpBody.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/JsonBody.cpp b/samples/client/petstore/cpprest/JsonBody.cpp index 41ce32702c3..67ea71af047 100644 --- a/samples/client/petstore/cpprest/JsonBody.cpp +++ b/samples/client/petstore/cpprest/JsonBody.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/JsonBody.h b/samples/client/petstore/cpprest/JsonBody.h index 335be0a72b6..b75a69699ad 100644 --- a/samples/client/petstore/cpprest/JsonBody.h +++ b/samples/client/petstore/cpprest/JsonBody.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/ModelBase.cpp b/samples/client/petstore/cpprest/ModelBase.cpp index a311d7d1707..bb53546f26e 100644 --- a/samples/client/petstore/cpprest/ModelBase.cpp +++ b/samples/client/petstore/cpprest/ModelBase.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/ModelBase.h b/samples/client/petstore/cpprest/ModelBase.h index 558d403b15d..b2f190c87c3 100644 --- a/samples/client/petstore/cpprest/ModelBase.h +++ b/samples/client/petstore/cpprest/ModelBase.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/MultipartFormData.cpp b/samples/client/petstore/cpprest/MultipartFormData.cpp index a7e5f56c9f9..76078484f6a 100644 --- a/samples/client/petstore/cpprest/MultipartFormData.cpp +++ b/samples/client/petstore/cpprest/MultipartFormData.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/MultipartFormData.h b/samples/client/petstore/cpprest/MultipartFormData.h index 63b84dcb3a9..e7af513fa4b 100644 --- a/samples/client/petstore/cpprest/MultipartFormData.h +++ b/samples/client/petstore/cpprest/MultipartFormData.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/api/PetApi.cpp b/samples/client/petstore/cpprest/api/PetApi.cpp index a5e3d57c70b..1b655e62250 100644 --- a/samples/client/petstore/cpprest/api/PetApi.cpp +++ b/samples/client/petstore/cpprest/api/PetApi.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/api/PetApi.h b/samples/client/petstore/cpprest/api/PetApi.h index d60c3c80fca..617a05f40ee 100644 --- a/samples/client/petstore/cpprest/api/PetApi.h +++ b/samples/client/petstore/cpprest/api/PetApi.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/api/StoreApi.cpp b/samples/client/petstore/cpprest/api/StoreApi.cpp index d418af4fa4c..286755e9da4 100644 --- a/samples/client/petstore/cpprest/api/StoreApi.cpp +++ b/samples/client/petstore/cpprest/api/StoreApi.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/api/StoreApi.h b/samples/client/petstore/cpprest/api/StoreApi.h index 60ec088b326..e43ab4c4e77 100644 --- a/samples/client/petstore/cpprest/api/StoreApi.h +++ b/samples/client/petstore/cpprest/api/StoreApi.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/api/UserApi.cpp b/samples/client/petstore/cpprest/api/UserApi.cpp index 3e0318000f9..504df50ff3f 100644 --- a/samples/client/petstore/cpprest/api/UserApi.cpp +++ b/samples/client/petstore/cpprest/api/UserApi.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/api/UserApi.h b/samples/client/petstore/cpprest/api/UserApi.h index e94de1a1241..09415c0f2e5 100644 --- a/samples/client/petstore/cpprest/api/UserApi.h +++ b/samples/client/petstore/cpprest/api/UserApi.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/model/ApiResponse.cpp b/samples/client/petstore/cpprest/model/ApiResponse.cpp index d2f4238deeb..cb66ff06996 100644 --- a/samples/client/petstore/cpprest/model/ApiResponse.cpp +++ b/samples/client/petstore/cpprest/model/ApiResponse.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/model/ApiResponse.h b/samples/client/petstore/cpprest/model/ApiResponse.h index ec0a3a1b012..b9e339aaf68 100644 --- a/samples/client/petstore/cpprest/model/ApiResponse.h +++ b/samples/client/petstore/cpprest/model/ApiResponse.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/model/Category.cpp b/samples/client/petstore/cpprest/model/Category.cpp index 24bdc66c132..8701f5122d3 100644 --- a/samples/client/petstore/cpprest/model/Category.cpp +++ b/samples/client/petstore/cpprest/model/Category.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/model/Category.h b/samples/client/petstore/cpprest/model/Category.h index 860918c0822..8fe6e5452b3 100644 --- a/samples/client/petstore/cpprest/model/Category.h +++ b/samples/client/petstore/cpprest/model/Category.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/model/Order.cpp b/samples/client/petstore/cpprest/model/Order.cpp index 24f3b7e46cc..73a89f510dd 100644 --- a/samples/client/petstore/cpprest/model/Order.cpp +++ b/samples/client/petstore/cpprest/model/Order.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/model/Order.h b/samples/client/petstore/cpprest/model/Order.h index da065593b84..15d6cd200f1 100644 --- a/samples/client/petstore/cpprest/model/Order.h +++ b/samples/client/petstore/cpprest/model/Order.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/model/Pet.cpp b/samples/client/petstore/cpprest/model/Pet.cpp index a89406497f6..2558475b349 100644 --- a/samples/client/petstore/cpprest/model/Pet.cpp +++ b/samples/client/petstore/cpprest/model/Pet.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/model/Pet.h b/samples/client/petstore/cpprest/model/Pet.h index 61ae8b92f17..cfd594e78f0 100644 --- a/samples/client/petstore/cpprest/model/Pet.h +++ b/samples/client/petstore/cpprest/model/Pet.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/model/Tag.cpp b/samples/client/petstore/cpprest/model/Tag.cpp index 050bcc2d488..e7b3400e8b5 100644 --- a/samples/client/petstore/cpprest/model/Tag.cpp +++ b/samples/client/petstore/cpprest/model/Tag.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/model/Tag.h b/samples/client/petstore/cpprest/model/Tag.h index 30159052950..eda00393e95 100644 --- a/samples/client/petstore/cpprest/model/Tag.h +++ b/samples/client/petstore/cpprest/model/Tag.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/model/User.cpp b/samples/client/petstore/cpprest/model/User.cpp index 9ec72d1ac98..2faaf5b7ce5 100644 --- a/samples/client/petstore/cpprest/model/User.cpp +++ b/samples/client/petstore/cpprest/model/User.cpp @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpprest/model/User.h b/samples/client/petstore/cpprest/model/User.h index 3ecd51ce96d..30fa8e74f14 100644 --- a/samples/client/petstore/cpprest/model/User.h +++ b/samples/client/petstore/cpprest/model/User.h @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 * 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 * Do not edit the class manually. */ From ef076c34b4e8eea3b512109149077edc22079a78 Mon Sep 17 00:00:00 2001 From: beatcracker Date: Thu, 13 Jul 2017 17:49:56 +0300 Subject: [PATCH 04/10] [csharp] Update nuget.exe URL for latest version (#6031) * Set nuget.exe URL to latest version Fix #6022 * Update samples --- .../CsharpDotNet2/compile-mono.sh.mustache | 2 +- .../resources/csharp/compile-mono.sh.mustache | 2 +- .../main/resources/csharp/compile.mustache | 2 +- .../resources/csharp/mono_nunit_test.mustache | 4 +-- .../SwaggerClient/.swagger-codegen/VERSION | 1 + .../csharp/SwaggerClient/README.md | 3 +- .../csharp/SwaggerClient/build.bat | 4 +-- .../csharp/SwaggerClient/build.sh | 4 +-- .../csharp/SwaggerClient/docs/FakeApi.md | 1 - .../csharp/SwaggerClient/mono_nunit_test.sh | 4 +-- .../IO.Swagger.Test/IO.Swagger.Test.csproj | 11 +++---- .../src/IO.Swagger.Test/packages.config | 2 +- .../IO.Swagger/Client/SwaggerDateConverter.cs | 30 +++++++++++++++++++ .../src/IO.Swagger/IO.Swagger.csproj | 19 +++++------- .../src/IO.Swagger/IO.Swagger.nuspec | 5 ++-- .../src/IO.Swagger/Model/ModelReturn.cs | 2 ++ .../src/IO.Swagger/packages.config | 2 +- .../Lib/SwaggerClient/compile-mono.sh | 2 +- .../petstore/csharp/SwaggerClient/build.bat | 2 +- .../petstore/csharp/SwaggerClient/build.sh | 2 +- .../csharp/SwaggerClient/docs/FakeApi.md | 2 +- .../csharp/SwaggerClient/mono_nunit_test.sh | 4 +-- .../src/IO.Swagger/Model/FormatTest.cs | 7 +++++ .../docs/FakeApi.md | 2 +- .../SwaggerClientNetStandard/docs/FakeApi.md | 2 +- .../build.bat | 2 +- .../SwaggerClientWithPropertyChanged/build.sh | 2 +- .../docs/FakeApi.md | 2 +- .../mono_nunit_test.sh | 4 +-- .../src/IO.Swagger/Model/FormatTest.cs | 7 +++++ 30 files changed, 92 insertions(+), 46 deletions(-) create mode 100644 samples/client/petstore-security-test/csharp/SwaggerClient/.swagger-codegen/VERSION create mode 100644 samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/Client/SwaggerDateConverter.cs diff --git a/modules/swagger-codegen/src/main/resources/CsharpDotNet2/compile-mono.sh.mustache b/modules/swagger-codegen/src/main/resources/CsharpDotNet2/compile-mono.sh.mustache index 1e4e12b4aee..2287344892a 100644 --- a/modules/swagger-codegen/src/main/resources/CsharpDotNet2/compile-mono.sh.mustache +++ b/modules/swagger-codegen/src/main/resources/CsharpDotNet2/compile-mono.sh.mustache @@ -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 mono nuget.exe install vendor/packages.config -o vendor; mkdir -p bin; diff --git a/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache b/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache index cd807b78d0c..bc5905954eb 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache @@ -9,7 +9,7 @@ netfx=${frameworkVersion#net} echo "[INFO] Target framework: ${frameworkVersion}" 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 mono nuget.exe install src/{{packageName}}/packages.config -o packages; diff --git a/modules/swagger-codegen/src/main/resources/csharp/compile.mustache b/modules/swagger-codegen/src/main/resources/csharp/compile.mustache index 76d9f2b0bb3..2ef0e06e902 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/compile.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/compile.mustache @@ -10,7 +10,7 @@ SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319 SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v3.5 {{/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 if not exist ".\bin" mkdir bin diff --git a/modules/swagger-codegen/src/main/resources/csharp/mono_nunit_test.mustache b/modules/swagger-codegen/src/main/resources/csharp/mono_nunit_test.mustache index 4a2fa5f58a3..f9d2d63018a 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/mono_nunit_test.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/mono_nunit_test.mustache @@ -3,14 +3,14 @@ # 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 echo "[INFO] remove bin/Debug/SwaggerClientTest.dll" rm src/{{{packageName}}}.Test/bin/Debug/{{{packageName}}}.Test.dll 2> /dev/null 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 mono nuget.exe install src/{{{packageName}}}.Test/packages.config -o packages diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/.swagger-codegen/VERSION b/samples/client/petstore-security-test/csharp/SwaggerClient/.swagger-codegen/VERSION new file mode 100644 index 00000000000..7fea99011a6 --- /dev/null +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/.swagger-codegen/VERSION @@ -0,0 +1 @@ +2.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/README.md b/samples/client/petstore-security-test/csharp/SwaggerClient/README.md index 53adb00b7d9..15f71dc40fb 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/README.md +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/README.md @@ -67,7 +67,7 @@ namespace Example { public void main() { - + var apiInstance = new FakeApi(); 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 ); } + } } } diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/build.bat b/samples/client/petstore-security-test/csharp/SwaggerClient/build.bat index 1da4812b36b..c9f4b1adf4f 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/build.bat +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/build.bat @@ -5,12 +5,12 @@ 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 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 %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 diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/build.sh b/samples/client/petstore-security-test/csharp/SwaggerClient/build.sh index 6cfe5890b5e..ce37b66b21c 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/build.sh +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/build.sh @@ -9,13 +9,13 @@ netfx=${frameworkVersion#net} echo "[INFO] Target framework: ${frameworkVersion}" 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 mono nuget.exe install src/IO.Swagger/packages.config -o packages; echo "[INFO] Copy DLLs to the 'bin' folder" 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; echo "[INFO] Run 'mcs' to build bin/IO.Swagger.dll" diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/docs/FakeApi.md b/samples/client/petstore-security-test/csharp/SwaggerClient/docs/FakeApi.md index 39a951cbede..207bfdfdf08 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/docs/FakeApi.md +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/docs/FakeApi.md @@ -27,7 +27,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var testCodeInjectEndRnNR = testCodeInjectEndRnNR_example; // string | To test code injection *_/ ' \" =end - - \\r\\n \\n \\r (optional) diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/mono_nunit_test.sh b/samples/client/petstore-security-test/csharp/SwaggerClient/mono_nunit_test.sh index 6e094f7c0d1..1276032d81b 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/mono_nunit_test.sh +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/mono_nunit_test.sh @@ -3,14 +3,14 @@ # 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 echo "[INFO] remove bin/Debug/SwaggerClientTest.dll" rm src/IO.Swagger.Test/bin/Debug/IO.Swagger.Test.dll 2> /dev/null 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 mono nuget.exe install src/IO.Swagger.Test/packages.config -o packages diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj index a411e76e751..d8744c98f6a 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger.Test/IO.Swagger.Test.csproj @@ -47,10 +47,10 @@ Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r - $(SolutionDir)\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll - ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll - ..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll - ..\..\vendor\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll + $(SolutionDir)\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + ..\..\vendor\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll $(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll @@ -66,7 +66,8 @@ Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r - + diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger.Test/packages.config b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger.Test/packages.config index 9bb00f0fc4f..105b8298a45 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger.Test/packages.config +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger.Test/packages.config @@ -2,5 +2,5 @@ - + diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/Client/SwaggerDateConverter.cs b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/Client/SwaggerDateConverter.cs new file mode 100644 index 00000000000..efaaafed91d --- /dev/null +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/Client/SwaggerDateConverter.cs @@ -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 +{ + /// + /// 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 + /// + public class SwaggerDateConverter : IsoDateTimeConverter + { + /// + /// Initializes a new instance of the class. + /// + public SwaggerDateConverter() + { + // full-date = date-fullyear "-" date-month "-" date-mday + DateTimeFormat = "yyyy-MM-dd"; + } + } +} diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.csproj b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.csproj index 191ac9a560e..738c7595776 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.csproj +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.csproj @@ -48,10 +48,10 @@ Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r - $(SolutionDir)\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll - ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll - ..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll - ..\..\vendor\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll + $(SolutionDir)\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + ..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + ..\..\vendor\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll $(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll @@ -59,17 +59,14 @@ Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r ..\..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll ..\..\vendor\RestSharp.105.1.0\lib\net45\RestSharp.dll - - - - - + - - + + diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.nuspec b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.nuspec index 26e30c91e78..5d0ad337e04 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.nuspec +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.nuspec @@ -26,7 +26,7 @@ - + @@ -36,5 +36,6 @@ + - \ No newline at end of file + diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/Model/ModelReturn.cs b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/Model/ModelReturn.cs index e75bd5c3156..13d7c9052e5 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/Model/ModelReturn.cs +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/Model/ModelReturn.cs @@ -20,6 +20,7 @@ using System.Runtime.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using System.ComponentModel.DataAnnotations; +using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter; namespace IO.Swagger.Model { @@ -44,6 +45,7 @@ namespace IO.Swagger.Model /// property description *_/ ' \" =end - - \\r\\n \\n \\r [DataMember(Name="return", EmitDefaultValue=false)] public int? _Return { get; set; } + /// /// Returns the string presentation of the object /// diff --git a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/packages.config b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/packages.config index 80f617d6d9f..351ef133ee8 100644 --- a/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/packages.config +++ b/samples/client/petstore-security-test/csharp/SwaggerClient/src/IO.Swagger/packages.config @@ -1,5 +1,5 @@ - + diff --git a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/compile-mono.sh b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/compile-mono.sh index 352274186d2..35e830ac9ca 100644 --- a/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/compile-mono.sh +++ b/samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient/compile-mono.sh @@ -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 mono nuget.exe install vendor/packages.config -o vendor; mkdir -p bin; diff --git a/samples/client/petstore/csharp/SwaggerClient/build.bat b/samples/client/petstore/csharp/SwaggerClient/build.bat index 9460347d457..c9f4b1adf4f 100644 --- a/samples/client/petstore/csharp/SwaggerClient/build.bat +++ b/samples/client/petstore/csharp/SwaggerClient/build.bat @@ -5,7 +5,7 @@ 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 if not exist ".\bin" mkdir bin diff --git a/samples/client/petstore/csharp/SwaggerClient/build.sh b/samples/client/petstore/csharp/SwaggerClient/build.sh index 0d2b4460073..ce37b66b21c 100644 --- a/samples/client/petstore/csharp/SwaggerClient/build.sh +++ b/samples/client/petstore/csharp/SwaggerClient/build.sh @@ -9,7 +9,7 @@ netfx=${frameworkVersion#net} echo "[INFO] Target framework: ${frameworkVersion}" 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 mono nuget.exe install src/IO.Swagger/packages.config -o packages; diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md b/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md index 41bddd87b49..3afd0a685ba 100644 --- a/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md +++ b/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md @@ -344,7 +344,7 @@ namespace Example var number = 3.4; // decimal? | None var _double = 1.2; // double? | 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 int32 = 56; // int? | None (optional) var int64 = 789; // long? | None (optional) diff --git a/samples/client/petstore/csharp/SwaggerClient/mono_nunit_test.sh b/samples/client/petstore/csharp/SwaggerClient/mono_nunit_test.sh index 6e094f7c0d1..1276032d81b 100644 --- a/samples/client/petstore/csharp/SwaggerClient/mono_nunit_test.sh +++ b/samples/client/petstore/csharp/SwaggerClient/mono_nunit_test.sh @@ -3,14 +3,14 @@ # 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 echo "[INFO] remove bin/Debug/SwaggerClientTest.dll" rm src/IO.Swagger.Test/bin/Debug/IO.Swagger.Test.dll 2> /dev/null 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 mono nuget.exe install src/IO.Swagger.Test/packages.config -o packages diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/FormatTest.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/FormatTest.cs index c91ee20661d..2bf7d5997d2 100644 --- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/FormatTest.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/FormatTest.cs @@ -418,6 +418,13 @@ namespace IO.Swagger.Model yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for _String, must match a pattern of /[a-z]/i.", 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 if(this.Password != null && this.Password.Length > 64) { diff --git a/samples/client/petstore/csharp/SwaggerClientNetCoreProject/docs/FakeApi.md b/samples/client/petstore/csharp/SwaggerClientNetCoreProject/docs/FakeApi.md index 41bddd87b49..3afd0a685ba 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetCoreProject/docs/FakeApi.md +++ b/samples/client/petstore/csharp/SwaggerClientNetCoreProject/docs/FakeApi.md @@ -344,7 +344,7 @@ namespace Example var number = 3.4; // decimal? | None var _double = 1.2; // double? | 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 int32 = 56; // int? | None (optional) var int64 = 789; // long? | None (optional) diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/FakeApi.md b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/FakeApi.md index 41bddd87b49..3afd0a685ba 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/FakeApi.md +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/FakeApi.md @@ -344,7 +344,7 @@ namespace Example var number = 3.4; // decimal? | None var _double = 1.2; // double? | 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 int32 = 56; // int? | None (optional) var int64 = 789; // long? | None (optional) diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/build.bat b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/build.bat index 53ea79a6092..492b659186c 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/build.bat +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/build.bat @@ -5,7 +5,7 @@ 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 if not exist ".\bin" mkdir bin diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/build.sh b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/build.sh index 037c4dd9f64..f24c4f9dee7 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/build.sh +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/build.sh @@ -9,7 +9,7 @@ netfx=${frameworkVersion#net} echo "[INFO] Target framework: ${frameworkVersion}" 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 mono nuget.exe install src/IO.Swagger/packages.config -o packages; diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/FakeApi.md b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/FakeApi.md index 41bddd87b49..3afd0a685ba 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/FakeApi.md +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/FakeApi.md @@ -344,7 +344,7 @@ namespace Example var number = 3.4; // decimal? | None var _double = 1.2; // double? | 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 int32 = 56; // int? | None (optional) var int64 = 789; // long? | None (optional) diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/mono_nunit_test.sh b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/mono_nunit_test.sh index 6e094f7c0d1..1276032d81b 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/mono_nunit_test.sh +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/mono_nunit_test.sh @@ -3,14 +3,14 @@ # 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 echo "[INFO] remove bin/Debug/SwaggerClientTest.dll" rm src/IO.Swagger.Test/bin/Debug/IO.Swagger.Test.dll 2> /dev/null 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 mono nuget.exe install src/IO.Swagger.Test/packages.config -o packages diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/FormatTest.cs b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/FormatTest.cs index 3f7e31a0d39..8762cbe9751 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/FormatTest.cs +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/FormatTest.cs @@ -441,6 +441,13 @@ namespace IO.Swagger.Model yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for _String, must match a pattern of /[a-z]/i.", 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 if(this.Password != null && this.Password.Length > 64) { From 9f711ae7e8578cef3170406e8011b0575900b108 Mon Sep 17 00:00:00 2001 From: Javier Velilla Date: Thu, 13 Jul 2017 11:51:24 -0300 Subject: [PATCH 05/10] [Eiffel] Add Eiffel API client generator (#6036) * Initial Eiffel Client code generator TODO API and Domain model * Updated EiffelClientCodegen to support Eiffel code style. Added mustaches templates for models and apis. The last one still under development. * Updated templates, initial API generation. Added client request template. * Updated api.mustache style * Updated code generation with a new directory layout. Added test case generation, clean code. * Updated Code generator, added apidoc and modeldoc Updated readme file * Added a Basic JSON Deserializer Updated API client to support by default a basic json (de)serializer and let the user customize then if needed. * Updated Eiffel code generator to use Eiffel feature name style. Updated templates to follow Eiffel style. Improved feature descriptions. * Added model inheritance support. Removed unused code. * Updated Eiffel code templates, refactor remove obsolte feature calls. Added Eiffel sample in samples/client/petstore/eiffel. * Updated Java code style. * Fixed formating, using spaces instead of tabs. * Updated EiffelCodeGenarator typeMapping. Added TestCases for EfiffelClientOption and ModelTest cases. Updated sample code to use the lastest changes. * Restore keyword `nil' in Go Language. --- .../languages/EiffelClientCodegen.java | 623 ++++++++++++++++++ .../codegen/languages/GoClientCodegen.java | 3 +- .../src/main/resources/Eiffel/README.mustache | 65 ++ .../src/main/resources/Eiffel/api.mustache | 75 +++ .../main/resources/Eiffel/api_client.mustache | 491 ++++++++++++++ .../main/resources/Eiffel/api_doc.mustache | 45 ++ .../src/main/resources/Eiffel/ecf.mustache | 24 + .../framework/api_client_request.mustache | 79 +++ .../framework/api_client_response.mustache | 61 ++ .../Eiffel/framework/api_error.mustache | 23 + .../resources/Eiffel/framework/api_i.mustache | 99 +++ .../framework/auth/api_key_auth.mustache | 64 ++ .../framework/auth/authentication.mustache | 15 + .../framework/auth/http_basic_auth.mustache | 49 ++ .../Eiffel/framework/auth/oauth.mustache | 30 + .../Eiffel/framework/configuration.mustache | 12 + .../serialization/api_deserializer.mustache | 13 + .../api_json_custom_deserializer.mustache | 173 +++++ .../api_json_deserializer.mustache | 22 + .../api_json_serializer.mustache | 32 + .../serialization/api_serializer.mustache | 14 + ...json_basic_reflector_deserializer.mustache | 534 +++++++++++++++ .../json_type_utilities_ext.mustache | 28 + .../src/main/resources/Eiffel/model.mustache | 107 +++ .../main/resources/Eiffel/model_doc.mustache | 11 + .../main/resources/Eiffel/noteinfo.mustache | 14 + .../resources/Eiffel/test/api_test.mustache | 63 ++ .../Eiffel/test/application.mustache | 22 + .../resources/Eiffel/test/ecf_test.mustache | 21 + .../services/io.swagger.codegen.CodegenConfig | 1 + .../eiffel/EiffelClientOptionsTest.java | 32 + .../codegen/eiffel/EiffelModelTest.java | 144 ++++ .../options/EiffelClientOptionsProvider.java | 34 + .../petstore/eiffel/.swagger-codegen-ignore | 23 + .../petstore/eiffel/.swagger-codegen/VERSION | 1 + samples/client/petstore/eiffel/README.md | 78 +++ samples/client/petstore/eiffel/api_client.ecf | 24 + .../petstore/eiffel/docs/API_RESPONSE.md | 12 + .../client/petstore/eiffel/docs/CATEGORY.md | 11 + samples/client/petstore/eiffel/docs/ORDER.md | 15 + samples/client/petstore/eiffel/docs/PET.md | 15 + .../client/petstore/eiffel/docs/PET_API.md | 261 ++++++++ .../client/petstore/eiffel/docs/STORE_API.md | 129 ++++ samples/client/petstore/eiffel/docs/TAG.md | 11 + samples/client/petstore/eiffel/docs/USER.md | 17 + .../client/petstore/eiffel/docs/USER_API.md | 255 +++++++ samples/client/petstore/eiffel/gitpush.sh | 52 ++ .../client/petstore/eiffel/src/api/pet_api.e | 303 +++++++++ .../petstore/eiffel/src/api/store_api.e | 155 +++++ .../client/petstore/eiffel/src/api/user_api.e | 269 ++++++++ .../client/petstore/eiffel/src/api_client.e | 502 ++++++++++++++ .../petstore/eiffel/src/domain/api_response.e | 85 +++ .../petstore/eiffel/src/domain/category.e | 70 ++ .../client/petstore/eiffel/src/domain/order.e | 130 ++++ .../client/petstore/eiffel/src/domain/pet.e | 134 ++++ .../client/petstore/eiffel/src/domain/tag.e | 70 ++ .../client/petstore/eiffel/src/domain/user.e | 160 +++++ .../eiffel/src/framework/api_client_request.e | 92 +++ .../src/framework/api_client_response.e | 74 +++ .../petstore/eiffel/src/framework/api_error.e | 36 + .../petstore/eiffel/src/framework/api_i.e | 112 ++++ .../eiffel/src/framework/auth/api_key_auth.e | 77 +++ .../src/framework/auth/authentication.e | 28 + .../src/framework/auth/http_basic_auth.e | 62 ++ .../eiffel/src/framework/auth/oauth.e | 43 ++ .../eiffel/src/framework/configuration.e | 25 + .../serialization/api_deserializer.e | 26 + .../serialization/api_json_deserializer.e | 35 + .../serialization/api_json_serializer.e | 45 ++ .../framework/serialization/api_serializer.e | 27 + .../json_basic_reflector_deserializer.e | 534 +++++++++++++++ .../serialization/json_type_utilities_ext.e | 28 + .../client/petstore/eiffel/test/api_test.ecf | 21 + .../petstore/eiffel/test/apis/pet_api_test.e | 145 ++++ .../eiffel/test/apis/store_api_test.e | 81 +++ .../petstore/eiffel/test/apis/user_api_test.e | 140 ++++ .../client/petstore/eiffel/test/application.e | 22 + 77 files changed, 7456 insertions(+), 2 deletions(-) create mode 100644 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/EiffelClientCodegen.java create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/README.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/api.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/api_client.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/api_doc.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/ecf.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/api_client_request.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/api_client_response.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/api_error.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/api_i.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/api_key_auth.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/authentication.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/http_basic_auth.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/oauth.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/configuration.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_deserializer.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_json_custom_deserializer.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_json_deserializer.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_json_serializer.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_serializer.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/json_basic_reflector_deserializer.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/json_type_utilities_ext.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/model.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/model_doc.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/noteinfo.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/test/api_test.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/test/application.mustache create mode 100644 modules/swagger-codegen/src/main/resources/Eiffel/test/ecf_test.mustache create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/EiffelClientOptionsTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/EiffelModelTest.java create mode 100644 modules/swagger-codegen/src/test/java/io/swagger/codegen/options/EiffelClientOptionsProvider.java create mode 100644 samples/client/petstore/eiffel/.swagger-codegen-ignore create mode 100644 samples/client/petstore/eiffel/.swagger-codegen/VERSION create mode 100644 samples/client/petstore/eiffel/README.md create mode 100644 samples/client/petstore/eiffel/api_client.ecf create mode 100644 samples/client/petstore/eiffel/docs/API_RESPONSE.md create mode 100644 samples/client/petstore/eiffel/docs/CATEGORY.md create mode 100644 samples/client/petstore/eiffel/docs/ORDER.md create mode 100644 samples/client/petstore/eiffel/docs/PET.md create mode 100644 samples/client/petstore/eiffel/docs/PET_API.md create mode 100644 samples/client/petstore/eiffel/docs/STORE_API.md create mode 100644 samples/client/petstore/eiffel/docs/TAG.md create mode 100644 samples/client/petstore/eiffel/docs/USER.md create mode 100644 samples/client/petstore/eiffel/docs/USER_API.md create mode 100644 samples/client/petstore/eiffel/gitpush.sh create mode 100644 samples/client/petstore/eiffel/src/api/pet_api.e create mode 100644 samples/client/petstore/eiffel/src/api/store_api.e create mode 100644 samples/client/petstore/eiffel/src/api/user_api.e create mode 100644 samples/client/petstore/eiffel/src/api_client.e create mode 100644 samples/client/petstore/eiffel/src/domain/api_response.e create mode 100644 samples/client/petstore/eiffel/src/domain/category.e create mode 100644 samples/client/petstore/eiffel/src/domain/order.e create mode 100644 samples/client/petstore/eiffel/src/domain/pet.e create mode 100644 samples/client/petstore/eiffel/src/domain/tag.e create mode 100644 samples/client/petstore/eiffel/src/domain/user.e create mode 100644 samples/client/petstore/eiffel/src/framework/api_client_request.e create mode 100644 samples/client/petstore/eiffel/src/framework/api_client_response.e create mode 100644 samples/client/petstore/eiffel/src/framework/api_error.e create mode 100644 samples/client/petstore/eiffel/src/framework/api_i.e create mode 100644 samples/client/petstore/eiffel/src/framework/auth/api_key_auth.e create mode 100644 samples/client/petstore/eiffel/src/framework/auth/authentication.e create mode 100644 samples/client/petstore/eiffel/src/framework/auth/http_basic_auth.e create mode 100644 samples/client/petstore/eiffel/src/framework/auth/oauth.e create mode 100644 samples/client/petstore/eiffel/src/framework/configuration.e create mode 100644 samples/client/petstore/eiffel/src/framework/serialization/api_deserializer.e create mode 100644 samples/client/petstore/eiffel/src/framework/serialization/api_json_deserializer.e create mode 100644 samples/client/petstore/eiffel/src/framework/serialization/api_json_serializer.e create mode 100644 samples/client/petstore/eiffel/src/framework/serialization/api_serializer.e create mode 100644 samples/client/petstore/eiffel/src/framework/serialization/json_basic_reflector_deserializer.e create mode 100644 samples/client/petstore/eiffel/src/framework/serialization/json_type_utilities_ext.e create mode 100644 samples/client/petstore/eiffel/test/api_test.ecf create mode 100644 samples/client/petstore/eiffel/test/apis/pet_api_test.e create mode 100644 samples/client/petstore/eiffel/test/apis/store_api_test.e create mode 100644 samples/client/petstore/eiffel/test/apis/user_api_test.e create mode 100644 samples/client/petstore/eiffel/test/application.e diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/EiffelClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/EiffelClientCodegen.java new file mode 100644 index 00000000000..ba697be3c2c --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/EiffelClientCodegen.java @@ -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 parentModels = new HashSet<>(); + private final Multimap 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(Arrays.asList("map", "array")); + + languageSpecificPrimitives = new HashSet( + 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 postProcessOperations(Map objs) { + @SuppressWarnings("unchecked") + Map objectMap = (Map) objs.get("operations"); + @SuppressWarnings("unchecked") + List operations = (List) 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> imports = (List>) objs.get("imports"); + if (imports == null) + return objs; + + Iterator> 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> recursiveImports = (List>) objs.get("imports"); + if (recursiveImports == null) + return objs; + + ListIterator> 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 postProcessModels(Map objs) { + // remove model imports to avoid error + List> imports = (List>) objs.get("imports"); + final String prefix = modelPackage(); + Iterator> 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> recursiveImports = (List>) objs.get("imports"); + if (recursiveImports == null) + return objs; + + ListIterator> 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 postProcessAllModels(final Map models) { + + final Map processed = super.postProcessAllModels(models); + postProcessParentModels(models); + return processed; + } + + private void postProcessParentModels(final Map models) { + for (final String parent : parentModels) { + final CodegenModel parentModel = ModelUtils.getModelByName(parent, models); + final Collection 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 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 createMapping(String key, String value) { + Map customImport = new HashMap(); + 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; + } + + } +} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java index 837e2e20c24..456d49ee3b9 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java @@ -56,8 +56,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig { "case", "defer", "go", "map", "struct", "chan", "else", "goto", "package", "switch", "const", "fallthrough", "if", "range", "type", - "continue", "for", "import", "return", "var", "error", "ApiResponse", - "nil") + "continue", "for", "import", "return", "var", "error", "ApiResponse", "nil") // Added "error" as it's used so frequently that it may as well be a keyword ); diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/README.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/README.mustache new file mode 100644 index 00000000000..b0e787e8fd9 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/README.mustache @@ -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. +``` + "" +``` + +## 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}} diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/api.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/api.mustache new file mode 100644 index 00000000000..3cae5b2c6e5 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/api.mustache @@ -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}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/api_client.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/api_client.mustache new file mode 100644 index 00000000000..1e8845b6f51 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/api_client.mustache @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/api_doc.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/api_doc.mustache new file mode 100644 index 00000000000..a5f4dbeef00 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/api_doc.mustache @@ -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}} diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/ecf.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/ecf.mustache new file mode 100644 index 00000000000..53926e66537 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/ecf.mustache @@ -0,0 +1,24 @@ + + + + + + /\.git$ + /\.svn$ + /CVS$ + /EIFGENs$ + + + + + + + + + + + + + diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/api_client_request.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/api_client_request.mustache new file mode 100644 index 00000000000..53aa9a63eed --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/api_client_request.mustache @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/api_client_response.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/api_client_response.mustache new file mode 100644 index 00000000000..989780fa6a6 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/api_client_response.mustache @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/api_error.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/api_error.mustache new file mode 100644 index 00000000000..405e36fcb77 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/api_error.mustache @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/api_i.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/api_i.mustache new file mode 100644 index 00000000000..74670f65b4d --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/api_i.mustache @@ -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 \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/api_key_auth.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/api_key_auth.mustache new file mode 100644 index 00000000000..3bbff19691a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/api_key_auth.mustache @@ -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]) + -- . + 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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/authentication.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/authentication.mustache new file mode 100644 index 00000000000..19c0b046779 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/authentication.mustache @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/http_basic_auth.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/http_basic_auth.mustache new file mode 100644 index 00000000000..77f97354969 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/http_basic_auth.mustache @@ -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]) + -- . + 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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/oauth.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/oauth.mustache new file mode 100644 index 00000000000..e3298fcc588 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/auth/oauth.mustache @@ -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]) + -- . + do + if attached access_token as l_access_token then + a_header_params.force ("Bearer " + l_access_token,"Authorization" ) + end + end +end diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/configuration.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/configuration.mustache new file mode 100644 index 00000000000..d651d414ec5 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/configuration.mustache @@ -0,0 +1,12 @@ +{{>noteinfo}} + +class + CONFIGURATION + +feature -- API client + + default_api_client: API_CLIENT + do + create Result.make + end +end diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_deserializer.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_deserializer.mustache new file mode 100644 index 00000000000..4792a416162 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_deserializer.mustache @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_json_custom_deserializer.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_json_custom_deserializer.mustache new file mode 100644 index 00000000000..dc0027a2488 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_json_custom_deserializer.mustache @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_json_deserializer.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_json_deserializer.mustache new file mode 100644 index 00000000000..3423a142cb2 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_json_deserializer.mustache @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_json_serializer.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_json_serializer.mustache new file mode 100644 index 00000000000..44642db3a66 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_json_serializer.mustache @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_serializer.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_serializer.mustache new file mode 100644 index 00000000000..2d14650da95 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/api_serializer.mustache @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/json_basic_reflector_deserializer.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/json_basic_reflector_deserializer.mustache new file mode 100644 index 00000000000..91dc90ed929 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/json_basic_reflector_deserializer.mustache @@ -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 + -- + 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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/json_type_utilities_ext.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/json_type_utilities_ext.mustache new file mode 100644 index 00000000000..bcc1c27d28f --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/framework/serialization/json_type_utilities_ext.mustache @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/model.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/model.mustache new file mode 100644 index 00000000000..388fc7c9cc2 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/model.mustache @@ -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 + -- + 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}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/model_doc.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/model_doc.mustache new file mode 100644 index 00000000000..569550df372 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/model_doc.mustache @@ -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}} diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/noteinfo.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/noteinfo.mustache new file mode 100644 index 00000000000..5f321db5dec --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/noteinfo.mustache @@ -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" \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/test/api_test.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/test/api_test.mustache new file mode 100644 index 00000000000..27fc2027c06 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/test/api_test.mustache @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/test/application.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/test/application.mustache new file mode 100644 index 00000000000..b60cb204a86 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/test/application.mustache @@ -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 \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/Eiffel/test/ecf_test.mustache b/modules/swagger-codegen/src/main/resources/Eiffel/test/ecf_test.mustache new file mode 100644 index 00000000000..b5f9b4a8240 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Eiffel/test/ecf_test.mustache @@ -0,0 +1,21 @@ + + + + + + /\.git$ + /\.svn$ + /CVS$ + /EIFGENs$ + + + + + + + + + + diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig index 6e8c165f871..d0feabe6507 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig @@ -13,6 +13,7 @@ io.swagger.codegen.languages.CppRestClientCodegen io.swagger.codegen.languages.CsharpDotNet2ClientCodegen io.swagger.codegen.languages.DartClientCodegen io.swagger.codegen.languages.ElixirClientCodegen +io.swagger.codegen.languages.EiffelClientCodegen io.swagger.codegen.languages.ErlangServerCodegen io.swagger.codegen.languages.FinchServerCodegen io.swagger.codegen.languages.FlashClientCodegen diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/EiffelClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/EiffelClientOptionsTest.java new file mode 100644 index 00000000000..5c8fe9678db --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/EiffelClientOptionsTest.java @@ -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; + }}; + } +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/EiffelModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/EiffelModelTest.java new file mode 100644 index 00000000000..6c6cd0e46cf --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/eiffel/EiffelModelTest.java @@ -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"); + } + +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/EiffelClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/EiffelClientOptionsProvider.java new file mode 100644 index 00000000000..ad99a3ba3ce --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/EiffelClientOptionsProvider.java @@ -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 createOptions() { + ImmutableMap.Builder builder = new ImmutableMap.Builder(); + 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; + } + +} diff --git a/samples/client/petstore/eiffel/.swagger-codegen-ignore b/samples/client/petstore/eiffel/.swagger-codegen-ignore new file mode 100644 index 00000000000..c5fa491b4c5 --- /dev/null +++ b/samples/client/petstore/eiffel/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/eiffel/.swagger-codegen/VERSION b/samples/client/petstore/eiffel/.swagger-codegen/VERSION new file mode 100644 index 00000000000..717311e32e3 --- /dev/null +++ b/samples/client/petstore/eiffel/.swagger-codegen/VERSION @@ -0,0 +1 @@ +unset \ No newline at end of file diff --git a/samples/client/petstore/eiffel/README.md b/samples/client/petstore/eiffel/README.md new file mode 100644 index 00000000000..e93db071d65 --- /dev/null +++ b/samples/client/petstore/eiffel/README.md @@ -0,0 +1,78 @@ +# Eiffel API client for swagger + +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + +## 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: 1.0.0 +- Package version: 1.0.0 +- Build package: io.swagger.codegen.languages.EiffelClientCodegen + +## Installation +Add the library into your Eiffel configuration file. +``` + "" +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PET_API* | [**add_pet**](docsPET_API.md#add_pet) | **Post** /pet | Add a new pet to the store +*PET_API* | [**delete_pet**](docsPET_API.md#delete_pet) | **Delete** /pet/{petId} | Deletes a pet +*PET_API* | [**find_pets_by_status**](docsPET_API.md#find_pets_by_status) | **Get** /pet/findByStatus | Finds Pets by status +*PET_API* | [**find_pets_by_tags**](docsPET_API.md#find_pets_by_tags) | **Get** /pet/findByTags | Finds Pets by tags +*PET_API* | [**pet_by_id**](docsPET_API.md#pet_by_id) | **Get** /pet/{petId} | Find pet by ID +*PET_API* | [**update_pet**](docsPET_API.md#update_pet) | **Put** /pet | Update an existing pet +*PET_API* | [**update_pet_with_form**](docsPET_API.md#update_pet_with_form) | **Post** /pet/{petId} | Updates a pet in the store with form data +*PET_API* | [**upload_file**](docsPET_API.md#upload_file) | **Post** /pet/{petId}/uploadImage | uploads an image +*STORE_API* | [**delete_order**](docsSTORE_API.md#delete_order) | **Delete** /store/order/{orderId} | Delete purchase order by ID +*STORE_API* | [**inventory**](docsSTORE_API.md#inventory) | **Get** /store/inventory | Returns pet inventories by status +*STORE_API* | [**order_by_id**](docsSTORE_API.md#order_by_id) | **Get** /store/order/{orderId} | Find purchase order by ID +*STORE_API* | [**place_order**](docsSTORE_API.md#place_order) | **Post** /store/order | Place an order for a pet +*USER_API* | [**create_user**](docsUSER_API.md#create_user) | **Post** /user | Create user +*USER_API* | [**create_users_with_array_input**](docsUSER_API.md#create_users_with_array_input) | **Post** /user/createWithArray | Creates list of users with given input array +*USER_API* | [**create_users_with_list_input**](docsUSER_API.md#create_users_with_list_input) | **Post** /user/createWithList | Creates list of users with given input array +*USER_API* | [**delete_user**](docsUSER_API.md#delete_user) | **Delete** /user/{username} | Delete user +*USER_API* | [**login_user**](docsUSER_API.md#login_user) | **Get** /user/login | Logs user into the system +*USER_API* | [**logout_user**](docsUSER_API.md#logout_user) | **Get** /user/logout | Logs out current logged in user session +*USER_API* | [**update_user**](docsUSER_API.md#update_user) | **Put** /user/{username} | Updated user +*USER_API* | [**user_by_name**](docsUSER_API.md#user_by_name) | **Get** /user/{username} | Get user by user name + + +## Documentation For Models + + - [API_RESPONSE](docsAPI_RESPONSE.md) + - [CATEGORY](docsCATEGORY.md) + - [ORDER](docsORDER.md) + - [PET](docsPET.md) + - [TAG](docsTAG.md) + - [USER](docsUSER.md) + + +## Documentation For Authorization + + +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +## petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + + +## Author + +apiteam@swagger.io + diff --git a/samples/client/petstore/eiffel/api_client.ecf b/samples/client/petstore/eiffel/api_client.ecf new file mode 100644 index 00000000000..7f7842b5d73 --- /dev/null +++ b/samples/client/petstore/eiffel/api_client.ecf @@ -0,0 +1,24 @@ + + + + + + /\.git$ + /\.svn$ + /CVS$ + /EIFGENs$ + + + + + + + + + + + + + diff --git a/samples/client/petstore/eiffel/docs/API_RESPONSE.md b/samples/client/petstore/eiffel/docs/API_RESPONSE.md new file mode 100644 index 00000000000..e33f7caef48 --- /dev/null +++ b/samples/client/petstore/eiffel/docs/API_RESPONSE.md @@ -0,0 +1,12 @@ +# API_RESPONSE + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **INTEGER_32** | | [optional] [default to null] +**type** | [**STRING_32**](STRING_32.md) | | [optional] [default to null] +**message** | [**STRING_32**](STRING_32.md) | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/eiffel/docs/CATEGORY.md b/samples/client/petstore/eiffel/docs/CATEGORY.md new file mode 100644 index 00000000000..de2ce34e627 --- /dev/null +++ b/samples/client/petstore/eiffel/docs/CATEGORY.md @@ -0,0 +1,11 @@ +# CATEGORY + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **INTEGER_64** | | [optional] [default to null] +**name** | [**STRING_32**](STRING_32.md) | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/eiffel/docs/ORDER.md b/samples/client/petstore/eiffel/docs/ORDER.md new file mode 100644 index 00000000000..627e6ef8536 --- /dev/null +++ b/samples/client/petstore/eiffel/docs/ORDER.md @@ -0,0 +1,15 @@ +# ORDER + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **INTEGER_64** | | [optional] [default to null] +**pet_id** | **INTEGER_64** | | [optional] [default to null] +**quantity** | **INTEGER_32** | | [optional] [default to null] +**ship_date** | [**DATE_TIME**](DATE_TIME.md) | | [optional] [default to null] +**status** | [**STRING_32**](STRING_32.md) | Order Status | [optional] [default to null] +**complete** | **BOOLEAN** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/eiffel/docs/PET.md b/samples/client/petstore/eiffel/docs/PET.md new file mode 100644 index 00000000000..885d3781654 --- /dev/null +++ b/samples/client/petstore/eiffel/docs/PET.md @@ -0,0 +1,15 @@ +# PET + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **INTEGER_64** | | [optional] [default to null] +**category** | [**CATEGORY**](Category.md) | | [optional] [default to null] +**name** | [**STRING_32**](STRING_32.md) | | [default to null] +**photo_urls** | [**LIST [STRING_32]**](STRING_32.md) | | [default to null] +**tags** | [**LIST [TAG]**](Tag.md) | | [optional] [default to null] +**status** | [**STRING_32**](STRING_32.md) | pet status in the store | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/eiffel/docs/PET_API.md b/samples/client/petstore/eiffel/docs/PET_API.md new file mode 100644 index 00000000000..a8e6ae012e4 --- /dev/null +++ b/samples/client/petstore/eiffel/docs/PET_API.md @@ -0,0 +1,261 @@ +# PET_API + +All URIs are relative to *http://petstore.swagger.io/v2* + +Feature | HTTP request | Description +------------- | ------------- | ------------- +[**add_pet**](PET_API.md#add_pet) | **Post** /pet | Add a new pet to the store +[**delete_pet**](PET_API.md#delete_pet) | **Delete** /pet/{petId} | Deletes a pet +[**find_pets_by_status**](PET_API.md#find_pets_by_status) | **Get** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PET_API.md#find_pets_by_tags) | **Get** /pet/findByTags | Finds Pets by tags +[**pet_by_id**](PET_API.md#pet_by_id) | **Get** /pet/{petId} | Find pet by ID +[**update_pet**](PET_API.md#update_pet) | **Put** /pet | Update an existing pet +[**update_pet_with_form**](PET_API.md#update_pet_with_form) | **Post** /pet/{petId} | Updates a pet in the store with form data +[**upload_file**](PET_API.md#upload_file) | **Post** /pet/{petId}/uploadImage | uploads an image + + +# **add_pet** +> add_pet (body: PET ) + + +Add a new pet to the store + + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**PET**](PET.md)| Pet object that needs to be added to the store | + +### Return type + +{empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **delete_pet** +> delete_pet (pet_id: INTEGER_64 ; api_key: detachable STRING_32 ) + + +Deletes a pet + + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **INTEGER_64**| Pet id to delete | + **api_key** | **STRING_32**| | [optional] + +### Return type + +{empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **find_pets_by_status** +> find_pets_by_status (status: LIST [STRING_32] ): detachable LIST [PET] + + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**LIST [STRING_32]**](STRING_32.md)| Status values that need to be considered for filter | + +### Return type + +[**LIST [PET]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **find_pets_by_tags** +> find_pets_by_tags (tags: LIST [STRING_32] ): detachable LIST [PET] + + +Finds Pets by tags + +Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**LIST [STRING_32]**](STRING_32.md)| Tags to filter by | + +### Return type + +[**LIST [PET]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **pet_by_id** +> pet_by_id (pet_id: INTEGER_64 ): detachable PET + + +Find pet by ID + +Returns a single pet + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **INTEGER_64**| ID of pet to return | + +### Return type + +[**PET**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_pet** +> update_pet (body: PET ) + + +Update an existing pet + + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**PET**](PET.md)| Pet object that needs to be added to the store | + +### Return type + +{empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_pet_with_form** +> update_pet_with_form (pet_id: INTEGER_64 ; name: detachable STRING_32 ; status: detachable STRING_32 ) + + +Updates a pet in the store with form data + + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **INTEGER_64**| ID of pet that needs to be updated | + **name** | **STRING_32**| Updated name of the pet | [optional] + **status** | **STRING_32**| Updated status of the pet | [optional] + +### Return type + +{empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **upload_file** +> upload_file (pet_id: INTEGER_64 ; additional_metadata: detachable STRING_32 ; file: detachable FILE ): detachable API_RESPONSE + + +uploads an image + + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **INTEGER_64**| ID of pet to update | + **additional_metadata** | **STRING_32**| Additional data to pass to server | [optional] + **file** | **FILE**| file to upload | [optional] + +### Return type + +[**API_RESPONSE**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/eiffel/docs/STORE_API.md b/samples/client/petstore/eiffel/docs/STORE_API.md new file mode 100644 index 00000000000..4d24069f21a --- /dev/null +++ b/samples/client/petstore/eiffel/docs/STORE_API.md @@ -0,0 +1,129 @@ +# STORE_API + +All URIs are relative to *http://petstore.swagger.io/v2* + +Feature | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](STORE_API.md#delete_order) | **Delete** /store/order/{orderId} | Delete purchase order by ID +[**inventory**](STORE_API.md#inventory) | **Get** /store/inventory | Returns pet inventories by status +[**order_by_id**](STORE_API.md#order_by_id) | **Get** /store/order/{orderId} | Find purchase order by ID +[**place_order**](STORE_API.md#place_order) | **Post** /store/order | Place an order for a pet + + +# **delete_order** +> delete_order (order_id: INTEGER_64 ) + + +Delete purchase order by ID + +For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **INTEGER_64**| ID of the order that needs to be deleted | + +### Return type + +{empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **inventory** +> inventory : detachable STRING_TABLE[INTEGER_32] + + +Returns pet inventories by status + +Returns a map of status codes to quantities + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**STRING_TABLE[INTEGER_32]**](STRING_TABLE.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **order_by_id** +> order_by_id (order_id: INTEGER_64 ): detachable ORDER + + +Find purchase order by ID + +For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **INTEGER_64**| ID of pet that needs to be fetched | + +### Return type + +[**ORDER**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **place_order** +> place_order (body: ORDER ): detachable ORDER + + +Place an order for a pet + + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**ORDER**](ORDER.md)| order placed for purchasing the pet | + +### Return type + +[**ORDER**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/eiffel/docs/TAG.md b/samples/client/petstore/eiffel/docs/TAG.md new file mode 100644 index 00000000000..aba185403bb --- /dev/null +++ b/samples/client/petstore/eiffel/docs/TAG.md @@ -0,0 +1,11 @@ +# TAG + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **INTEGER_64** | | [optional] [default to null] +**name** | [**STRING_32**](STRING_32.md) | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/eiffel/docs/USER.md b/samples/client/petstore/eiffel/docs/USER.md new file mode 100644 index 00000000000..7853f376590 --- /dev/null +++ b/samples/client/petstore/eiffel/docs/USER.md @@ -0,0 +1,17 @@ +# USER + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **INTEGER_64** | | [optional] [default to null] +**username** | [**STRING_32**](STRING_32.md) | | [optional] [default to null] +**first_name** | [**STRING_32**](STRING_32.md) | | [optional] [default to null] +**last_name** | [**STRING_32**](STRING_32.md) | | [optional] [default to null] +**email** | [**STRING_32**](STRING_32.md) | | [optional] [default to null] +**password** | [**STRING_32**](STRING_32.md) | | [optional] [default to null] +**phone** | [**STRING_32**](STRING_32.md) | | [optional] [default to null] +**user_status** | **INTEGER_32** | User Status | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/eiffel/docs/USER_API.md b/samples/client/petstore/eiffel/docs/USER_API.md new file mode 100644 index 00000000000..62dece7dd50 --- /dev/null +++ b/samples/client/petstore/eiffel/docs/USER_API.md @@ -0,0 +1,255 @@ +# USER_API + +All URIs are relative to *http://petstore.swagger.io/v2* + +Feature | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](USER_API.md#create_user) | **Post** /user | Create user +[**create_users_with_array_input**](USER_API.md#create_users_with_array_input) | **Post** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](USER_API.md#create_users_with_list_input) | **Post** /user/createWithList | Creates list of users with given input array +[**delete_user**](USER_API.md#delete_user) | **Delete** /user/{username} | Delete user +[**login_user**](USER_API.md#login_user) | **Get** /user/login | Logs user into the system +[**logout_user**](USER_API.md#logout_user) | **Get** /user/logout | Logs out current logged in user session +[**update_user**](USER_API.md#update_user) | **Put** /user/{username} | Updated user +[**user_by_name**](USER_API.md#user_by_name) | **Get** /user/{username} | Get user by user name + + +# **create_user** +> create_user (body: USER ) + + +Create user + +This can only be done by the logged in user. + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**USER**](USER.md)| Created user object | + +### Return type + +{empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **create_users_with_array_input** +> create_users_with_array_input (body: LIST [USER] ) + + +Creates list of users with given input array + + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**LIST [USER]**](User.md)| List of user object | + +### Return type + +{empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **create_users_with_list_input** +> create_users_with_list_input (body: LIST [USER] ) + + +Creates list of users with given input array + + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**LIST [USER]**](User.md)| List of user object | + +### Return type + +{empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **delete_user** +> delete_user (username: STRING_32 ) + + +Delete user + +This can only be done by the logged in user. + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **STRING_32**| The name that needs to be deleted | + +### Return type + +{empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **login_user** +> login_user (username: STRING_32 ; password: STRING_32 ): detachable STRING_32 + + +Logs user into the system + + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **STRING_32**| The user name for login | + **password** | **STRING_32**| The password for login in clear text | + +### Return type + +[**STRING_32**](STRING_32.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **logout_user** +> logout_user + + +Logs out current logged in user session + + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +{empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_user** +> update_user (username: STRING_32 ; body: USER ) + + +Updated user + +This can only be done by the logged in user. + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **STRING_32**| name that need to be updated | + **body** | [**USER**](USER.md)| Updated user object | + +### Return type + +{empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **user_by_name** +> user_by_name (username: STRING_32 ): detachable USER + + +Get user by user name + + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **STRING_32**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**USER**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/eiffel/gitpush.sh b/samples/client/petstore/eiffel/gitpush.sh new file mode 100644 index 00000000000..ed374619b13 --- /dev/null +++ b/samples/client/petstore/eiffel/gitpush.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/eiffel/src/api/pet_api.e b/samples/client/petstore/eiffel/src/api/pet_api.e new file mode 100644 index 00000000000..af019e6e799 --- /dev/null +++ b/samples/client/petstore/eiffel/src/api/pet_api.e @@ -0,0 +1,303 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +class + PET_API + +inherit + + API_I + + +feature -- API Access + + + add_pet (body: PET) + -- Add a new pet to the store + -- + -- + -- argument: body Pet object that needs to be added to the store (required) + -- + -- + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + l_request.set_body(body) + l_path := "/pet" + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<"application/json", "application/xml">>),"Content-Type") + l_request.set_auth_names (<<"petstore_auth">>) + l_response := api_client.call_api (l_path, "Post", l_request, agent serializer, Void) + if l_response.has_error then + last_error := l_response.error + end + end + + delete_pet (pet_id: INTEGER_64; api_key: detachable STRING_32) + -- Deletes a pet + -- + -- + -- argument: pet_id Pet id to delete (required) + -- + -- argument: api_key (optional) + -- + -- + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + + l_path := "/pet/{petId}" + l_path.replace_substring_all ("{"+"petId"+"}", api_client.url_encode (pet_id.out)) + if attached api_key as l_api_key then + l_request.add_header(l_api_key.out,"api_key"); + end + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<"petstore_auth">>) + l_response := api_client.call_api (l_path, "Delete", l_request, agent serializer, Void) + if l_response.has_error then + last_error := l_response.error + end + end + + find_pets_by_status (status: LIST [STRING_32]): detachable LIST [PET] + -- Finds Pets by status + -- Multiple status values can be provided with comma separated strings + -- + -- argument: status Status values that need to be considered for filter (required) + -- + -- + -- Result LIST [PET] + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + + l_path := "/pet/findByStatus" + l_request.fill_query_params(api_client.parameter_to_tuple("multi", "status", status)); + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<"petstore_auth">>) + l_response := api_client.call_api (l_path, "Get", l_request, Void, agent deserializer) + if l_response.has_error then + last_error := l_response.error + elseif attached { LIST [PET] } l_response.data ({ LIST [PET] }) as l_data then + Result := l_data + else + create last_error.make ("Unknown error: Status response [ " + l_response.status.out + "]") + end + end + + find_pets_by_tags (tags: LIST [STRING_32]): detachable LIST [PET] + -- Finds Pets by tags + -- Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + -- + -- argument: tags Tags to filter by (required) + -- + -- + -- Result LIST [PET] + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + + l_path := "/pet/findByTags" + l_request.fill_query_params(api_client.parameter_to_tuple("multi", "tags", tags)); + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<"petstore_auth">>) + l_response := api_client.call_api (l_path, "Get", l_request, Void, agent deserializer) + if l_response.has_error then + last_error := l_response.error + elseif attached { LIST [PET] } l_response.data ({ LIST [PET] }) as l_data then + Result := l_data + else + create last_error.make ("Unknown error: Status response [ " + l_response.status.out + "]") + end + end + + pet_by_id (pet_id: INTEGER_64): detachable PET + -- Find pet by ID + -- Returns a single pet + -- + -- argument: pet_id ID of pet to return (required) + -- + -- + -- Result PET + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + + l_path := "/pet/{petId}" + l_path.replace_substring_all ("{"+"petId"+"}", api_client.url_encode (pet_id.out)) + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<"api_key">>) + l_response := api_client.call_api (l_path, "Get", l_request, Void, agent deserializer) + if l_response.has_error then + last_error := l_response.error + elseif attached { PET } l_response.data ({ PET }) as l_data then + Result := l_data + else + create last_error.make ("Unknown error: Status response [ " + l_response.status.out + "]") + end + end + + update_pet (body: PET) + -- Update an existing pet + -- + -- + -- argument: body Pet object that needs to be added to the store (required) + -- + -- + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + l_request.set_body(body) + l_path := "/pet" + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<"application/json", "application/xml">>),"Content-Type") + l_request.set_auth_names (<<"petstore_auth">>) + l_response := api_client.call_api (l_path, "Put", l_request, agent serializer, Void) + if l_response.has_error then + last_error := l_response.error + end + end + + update_pet_with_form (pet_id: INTEGER_64; name: detachable STRING_32; status: detachable STRING_32) + -- Updates a pet in the store with form data + -- + -- + -- argument: pet_id ID of pet that needs to be updated (required) + -- + -- argument: name Updated name of the pet (optional) + -- + -- argument: status Updated status of the pet (optional) + -- + -- + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + + l_path := "/pet/{petId}" + l_path.replace_substring_all ("{"+"petId"+"}", api_client.url_encode (pet_id.out)) + if attached name as l_name then + l_request.add_form(l_name,"name"); + end + if attached status as l_status then + l_request.add_form(l_status,"status"); + end + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<"application/x-www-form-urlencoded">>),"Content-Type") + l_request.set_auth_names (<<"petstore_auth">>) + l_response := api_client.call_api (l_path, "Post", l_request, agent serializer, Void) + if l_response.has_error then + last_error := l_response.error + end + end + + upload_file (pet_id: INTEGER_64; additional_metadata: detachable STRING_32; file: detachable FILE): detachable API_RESPONSE + -- uploads an image + -- + -- + -- argument: pet_id ID of pet to update (required) + -- + -- argument: additional_metadata Additional data to pass to server (optional) + -- + -- argument: file file to upload (optional) + -- + -- + -- Result API_RESPONSE + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + + l_path := "/pet/{petId}/uploadImage" + l_path.replace_substring_all ("{"+"petId"+"}", api_client.url_encode (pet_id.out)) + if attached additional_metadata as l_additional_metadata then + l_request.add_form(l_additional_metadata,"additionalMetadata"); + end + if attached file as l_file then + l_request.add_form(l_file,"file"); + end + + if attached {STRING} api_client.select_header_accept (<<"application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<"multipart/form-data">>),"Content-Type") + l_request.set_auth_names (<<"petstore_auth">>) + l_response := api_client.call_api (l_path, "Post", l_request, Void, agent deserializer) + if l_response.has_error then + last_error := l_response.error + elseif attached { API_RESPONSE } l_response.data ({ API_RESPONSE }) as l_data then + Result := l_data + else + create last_error.make ("Unknown error: Status response [ " + l_response.status.out + "]") + end + end + + +end diff --git a/samples/client/petstore/eiffel/src/api/store_api.e b/samples/client/petstore/eiffel/src/api/store_api.e new file mode 100644 index 00000000000..04c0d9fc7db --- /dev/null +++ b/samples/client/petstore/eiffel/src/api/store_api.e @@ -0,0 +1,155 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +class + STORE_API + +inherit + + API_I + + +feature -- API Access + + + delete_order (order_id: INTEGER_64) + -- Delete purchase order by ID + -- For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors + -- + -- argument: order_id ID of the order that needs to be deleted (required) + -- + -- + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + + l_path := "/store/order/{orderId}" + l_path.replace_substring_all ("{"+"orderId"+"}", api_client.url_encode (order_id.out)) + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<>>) + l_response := api_client.call_api (l_path, "Delete", l_request, agent serializer, Void) + if l_response.has_error then + last_error := l_response.error + end + end + + inventory : detachable STRING_TABLE[INTEGER_32] + -- Returns pet inventories by status + -- Returns a map of status codes to quantities + -- + -- + -- Result STRING_TABLE[INTEGER_32] + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + + l_path := "/store/inventory" + + if attached {STRING} api_client.select_header_accept (<<"application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<"api_key">>) + l_response := api_client.call_api (l_path, "Get", l_request, Void, agent deserializer) + if l_response.has_error then + last_error := l_response.error + elseif attached { STRING_TABLE[INTEGER_32] } l_response.data ({ STRING_TABLE[INTEGER_32] }) as l_data then + Result := l_data + else + create last_error.make ("Unknown error: Status response [ " + l_response.status.out + "]") + end + end + + order_by_id (order_id: INTEGER_64): detachable ORDER + -- Find purchase order by ID + -- For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions + -- + -- argument: order_id ID of pet that needs to be fetched (required) + -- + -- + -- Result ORDER + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + + l_path := "/store/order/{orderId}" + l_path.replace_substring_all ("{"+"orderId"+"}", api_client.url_encode (order_id.out)) + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<>>) + l_response := api_client.call_api (l_path, "Get", l_request, Void, agent deserializer) + if l_response.has_error then + last_error := l_response.error + elseif attached { ORDER } l_response.data ({ ORDER }) as l_data then + Result := l_data + else + create last_error.make ("Unknown error: Status response [ " + l_response.status.out + "]") + end + end + + place_order (body: ORDER): detachable ORDER + -- Place an order for a pet + -- + -- + -- argument: body order placed for purchasing the pet (required) + -- + -- + -- Result ORDER + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + l_request.set_body(body) + l_path := "/store/order" + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<>>) + l_response := api_client.call_api (l_path, "Post", l_request, Void, agent deserializer) + if l_response.has_error then + last_error := l_response.error + elseif attached { ORDER } l_response.data ({ ORDER }) as l_data then + Result := l_data + else + create last_error.make ("Unknown error: Status response [ " + l_response.status.out + "]") + end + end + + +end diff --git a/samples/client/petstore/eiffel/src/api/user_api.e b/samples/client/petstore/eiffel/src/api/user_api.e new file mode 100644 index 00000000000..ce871778c70 --- /dev/null +++ b/samples/client/petstore/eiffel/src/api/user_api.e @@ -0,0 +1,269 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +class + USER_API + +inherit + + API_I + + +feature -- API Access + + + create_user (body: USER) + -- Create user + -- This can only be done by the logged in user. + -- + -- argument: body Created user object (required) + -- + -- + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + l_request.set_body(body) + l_path := "/user" + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<>>) + l_response := api_client.call_api (l_path, "Post", l_request, agent serializer, Void) + if l_response.has_error then + last_error := l_response.error + end + end + + create_users_with_array_input (body: LIST [USER]) + -- Creates list of users with given input array + -- + -- + -- argument: body List of user object (required) + -- + -- + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + l_request.set_body(body) + l_path := "/user/createWithArray" + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<>>) + l_response := api_client.call_api (l_path, "Post", l_request, agent serializer, Void) + if l_response.has_error then + last_error := l_response.error + end + end + + create_users_with_list_input (body: LIST [USER]) + -- Creates list of users with given input array + -- + -- + -- argument: body List of user object (required) + -- + -- + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + l_request.set_body(body) + l_path := "/user/createWithList" + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<>>) + l_response := api_client.call_api (l_path, "Post", l_request, agent serializer, Void) + if l_response.has_error then + last_error := l_response.error + end + end + + delete_user (username: STRING_32) + -- Delete user + -- This can only be done by the logged in user. + -- + -- argument: username The name that needs to be deleted (required) + -- + -- + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + + l_path := "/user/{username}" + l_path.replace_substring_all ("{"+"username"+"}", api_client.url_encode (username.out)) + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<>>) + l_response := api_client.call_api (l_path, "Delete", l_request, agent serializer, Void) + if l_response.has_error then + last_error := l_response.error + end + end + + login_user (username: STRING_32; password: STRING_32): detachable STRING_32 + -- Logs user into the system + -- + -- + -- argument: username The user name for login (required) + -- + -- argument: password The password for login in clear text (required) + -- + -- + -- Result STRING_32 + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + + l_path := "/user/login" + l_request.fill_query_params(api_client.parameter_to_tuple("", "username", username)); + l_request.fill_query_params(api_client.parameter_to_tuple("", "password", password)); + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<>>) + l_response := api_client.call_api (l_path, "Get", l_request, Void, agent deserializer) + if l_response.has_error then + last_error := l_response.error + elseif attached { STRING_32 } l_response.data ({ STRING_32 }) as l_data then + Result := l_data + else + create last_error.make ("Unknown error: Status response [ " + l_response.status.out + "]") + end + end + + logout_user + -- Logs out current logged in user session + -- + -- + -- + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + + l_path := "/user/logout" + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<>>) + l_response := api_client.call_api (l_path, "Get", l_request, agent serializer, Void) + if l_response.has_error then + last_error := l_response.error + end + end + + update_user (username: STRING_32; body: USER) + -- Updated user + -- This can only be done by the logged in user. + -- + -- argument: username name that need to be updated (required) + -- + -- argument: body Updated user object (required) + -- + -- + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + l_request.set_body(body) + l_path := "/user/{username}" + l_path.replace_substring_all ("{"+"username"+"}", api_client.url_encode (username.out)) + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<>>) + l_response := api_client.call_api (l_path, "Put", l_request, agent serializer, Void) + if l_response.has_error then + last_error := l_response.error + end + end + + user_by_name (username: STRING_32): detachable USER + -- Get user by user name + -- + -- + -- argument: username The name that needs to be fetched. Use user1 for testing. (required) + -- + -- + -- Result USER + local + l_path: STRING + l_request: API_CLIENT_REQUEST + l_response: API_CLIENT_RESPONSE + do + reset_error + create l_request + + l_path := "/user/{username}" + l_path.replace_substring_all ("{"+"username"+"}", api_client.url_encode (username.out)) + + if attached {STRING} api_client.select_header_accept (<<"application/xml", "application/json">>) as l_accept then + l_request.add_header(l_accept,"Accept"); + end + l_request.add_header(api_client.select_header_content_type (<<>>),"Content-Type") + l_request.set_auth_names (<<>>) + l_response := api_client.call_api (l_path, "Get", l_request, Void, agent deserializer) + if l_response.has_error then + last_error := l_response.error + elseif attached { USER } l_response.data ({ USER }) as l_data then + Result := l_data + else + create last_error.make ("Unknown error: Status response [ " + l_response.status.out + "]") + end + end + + +end diff --git a/samples/client/petstore/eiffel/src/api_client.e b/samples/client/petstore/eiffel/src/api_client.e new file mode 100644 index 00000000000..c55d55205a5 --- /dev/null +++ b/samples/client/petstore/eiffel/src/api_client.e @@ -0,0 +1,502 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +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("Swagger-Codegen//Eiffel"); + + create authentications.make (3) + authentications.force (create {API_KEY_AUTH}.make ("header", "api_key"), "api_key") + is_api_key_configured := True + authentications.force (create {OAUTH},"petstore_auth") + is_oauth_configured := True + end + +feature -- Access + + default_base_path: STRING = "http://petstore.swagger.io/v2" + -- 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 diff --git a/samples/client/petstore/eiffel/src/domain/api_response.e b/samples/client/petstore/eiffel/src/domain/api_response.e new file mode 100644 index 00000000000..0d5cd9145f0 --- /dev/null +++ b/samples/client/petstore/eiffel/src/domain/api_response.e @@ -0,0 +1,85 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +class API_RESPONSE + +inherit + + ANY + redefine + out + end + + +feature --Access + + code: INTEGER_32 + + type: detachable STRING_32 + + message: detachable STRING_32 + + +feature -- Change Element + + set_code (a_name: like code) + -- Set 'code' with 'a_name'. + do + code := a_name + ensure + code_set: code = a_name + end + + set_type (a_name: like type) + -- Set 'type' with 'a_name'. + do + type := a_name + ensure + type_set: type = a_name + end + + set_message (a_name: like message) + -- Set 'message' with 'a_name'. + do + message := a_name + ensure + message_set: message = a_name + end + + + feature -- Status Report + + out: STRING + -- + do + create Result.make_empty + Result.append("%Nclass API_RESPONSE%N") + if attached code as l_code then + Result.append ("%N") + Result.append (l_code.out) + Result.append ("%N") + end + if attached type as l_type then + Result.append ("%N") + Result.append (l_type.out) + Result.append ("%N") + end + if attached message as l_message then + Result.append ("%N") + Result.append (l_message.out) + Result.append ("%N") + end + end +end diff --git a/samples/client/petstore/eiffel/src/domain/category.e b/samples/client/petstore/eiffel/src/domain/category.e new file mode 100644 index 00000000000..e345efa79db --- /dev/null +++ b/samples/client/petstore/eiffel/src/domain/category.e @@ -0,0 +1,70 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +class CATEGORY + +inherit + + ANY + redefine + out + end + + +feature --Access + + id: INTEGER_64 + + name: detachable STRING_32 + + +feature -- Change Element + + set_id (a_name: like id) + -- Set 'id' with 'a_name'. + do + id := a_name + ensure + id_set: id = a_name + end + + set_name (a_name: like name) + -- Set 'name' with 'a_name'. + do + name := a_name + ensure + name_set: name = a_name + end + + + feature -- Status Report + + out: STRING + -- + do + create Result.make_empty + Result.append("%Nclass CATEGORY%N") + if attached id as l_id then + Result.append ("%N") + Result.append (l_id.out) + Result.append ("%N") + end + if attached name as l_name then + Result.append ("%N") + Result.append (l_name.out) + Result.append ("%N") + end + end +end diff --git a/samples/client/petstore/eiffel/src/domain/order.e b/samples/client/petstore/eiffel/src/domain/order.e new file mode 100644 index 00000000000..672559d0ad1 --- /dev/null +++ b/samples/client/petstore/eiffel/src/domain/order.e @@ -0,0 +1,130 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +class ORDER + +inherit + + ANY + redefine + out + end + + +feature --Access + + id: INTEGER_64 + + pet_id: INTEGER_64 + + quantity: INTEGER_32 + + ship_date: detachable DATE_TIME + + status: detachable STRING_32 + -- Order Status + complete: BOOLEAN + + +feature -- Change Element + + set_id (a_name: like id) + -- Set 'id' with 'a_name'. + do + id := a_name + ensure + id_set: id = a_name + end + + set_pet_id (a_name: like pet_id) + -- Set 'pet_id' with 'a_name'. + do + pet_id := a_name + ensure + pet_id_set: pet_id = a_name + end + + set_quantity (a_name: like quantity) + -- Set 'quantity' with 'a_name'. + do + quantity := a_name + ensure + quantity_set: quantity = a_name + end + + set_ship_date (a_name: like ship_date) + -- Set 'ship_date' with 'a_name'. + do + ship_date := a_name + ensure + ship_date_set: ship_date = a_name + end + + set_status (a_name: like status) + -- Set 'status' with 'a_name'. + do + status := a_name + ensure + status_set: status = a_name + end + + set_complete (a_name: like complete) + -- Set 'complete' with 'a_name'. + do + complete := a_name + ensure + complete_set: complete = a_name + end + + + feature -- Status Report + + out: STRING + -- + do + create Result.make_empty + Result.append("%Nclass ORDER%N") + if attached id as l_id then + Result.append ("%N") + Result.append (l_id.out) + Result.append ("%N") + end + if attached pet_id as l_pet_id then + Result.append ("%N") + Result.append (l_pet_id.out) + Result.append ("%N") + end + if attached quantity as l_quantity then + Result.append ("%N") + Result.append (l_quantity.out) + Result.append ("%N") + end + if attached ship_date as l_ship_date then + Result.append ("%N") + Result.append (l_ship_date.out) + Result.append ("%N") + end + if attached status as l_status then + Result.append ("%N") + Result.append (l_status.out) + Result.append ("%N") + end + if attached complete as l_complete then + Result.append ("%N") + Result.append (l_complete.out) + Result.append ("%N") + end + end +end diff --git a/samples/client/petstore/eiffel/src/domain/pet.e b/samples/client/petstore/eiffel/src/domain/pet.e new file mode 100644 index 00000000000..aefc0afd2ed --- /dev/null +++ b/samples/client/petstore/eiffel/src/domain/pet.e @@ -0,0 +1,134 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +class PET + +inherit + + ANY + redefine + out + end + + +feature --Access + + id: INTEGER_64 + + category: detachable CATEGORY + + name: detachable STRING_32 + + photo_urls: detachable LIST [STRING_32] + + tags: detachable LIST [TAG] + + status: detachable STRING_32 + -- pet status in the store + +feature -- Change Element + + set_id (a_name: like id) + -- Set 'id' with 'a_name'. + do + id := a_name + ensure + id_set: id = a_name + end + + set_category (a_name: like category) + -- Set 'category' with 'a_name'. + do + category := a_name + ensure + category_set: category = a_name + end + + set_name (a_name: like name) + -- Set 'name' with 'a_name'. + do + name := a_name + ensure + name_set: name = a_name + end + + set_photo_urls (a_name: like photo_urls) + -- Set 'photo_urls' with 'a_name'. + do + photo_urls := a_name + ensure + photo_urls_set: photo_urls = a_name + end + + set_tags (a_name: like tags) + -- Set 'tags' with 'a_name'. + do + tags := a_name + ensure + tags_set: tags = a_name + end + + set_status (a_name: like status) + -- Set 'status' with 'a_name'. + do + status := a_name + ensure + status_set: status = a_name + end + + + feature -- Status Report + + out: STRING + -- + do + create Result.make_empty + Result.append("%Nclass PET%N") + if attached id as l_id then + Result.append ("%N") + Result.append (l_id.out) + Result.append ("%N") + end + if attached category as l_category then + Result.append ("%N") + Result.append (l_category.out) + Result.append ("%N") + end + if attached name as l_name then + Result.append ("%N") + Result.append (l_name.out) + Result.append ("%N") + end + if attached photo_urls as l_photo_urls then + across l_photo_urls as ic loop + Result.append ("%N") + Result.append (ic.item.out) + Result.append ("%N") + end + end + if attached tags as l_tags then + across l_tags as ic loop + Result.append ("%N") + Result.append (ic.item.out) + Result.append ("%N") + end + end + if attached status as l_status then + Result.append ("%N") + Result.append (l_status.out) + Result.append ("%N") + end + end +end diff --git a/samples/client/petstore/eiffel/src/domain/tag.e b/samples/client/petstore/eiffel/src/domain/tag.e new file mode 100644 index 00000000000..082a805ce46 --- /dev/null +++ b/samples/client/petstore/eiffel/src/domain/tag.e @@ -0,0 +1,70 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +class TAG + +inherit + + ANY + redefine + out + end + + +feature --Access + + id: INTEGER_64 + + name: detachable STRING_32 + + +feature -- Change Element + + set_id (a_name: like id) + -- Set 'id' with 'a_name'. + do + id := a_name + ensure + id_set: id = a_name + end + + set_name (a_name: like name) + -- Set 'name' with 'a_name'. + do + name := a_name + ensure + name_set: name = a_name + end + + + feature -- Status Report + + out: STRING + -- + do + create Result.make_empty + Result.append("%Nclass TAG%N") + if attached id as l_id then + Result.append ("%N") + Result.append (l_id.out) + Result.append ("%N") + end + if attached name as l_name then + Result.append ("%N") + Result.append (l_name.out) + Result.append ("%N") + end + end +end diff --git a/samples/client/petstore/eiffel/src/domain/user.e b/samples/client/petstore/eiffel/src/domain/user.e new file mode 100644 index 00000000000..a8dd7350cc6 --- /dev/null +++ b/samples/client/petstore/eiffel/src/domain/user.e @@ -0,0 +1,160 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +class USER + +inherit + + ANY + redefine + out + end + + +feature --Access + + id: INTEGER_64 + + username: detachable STRING_32 + + first_name: detachable STRING_32 + + last_name: detachable STRING_32 + + email: detachable STRING_32 + + password: detachable STRING_32 + + phone: detachable STRING_32 + + user_status: INTEGER_32 + -- User Status + +feature -- Change Element + + set_id (a_name: like id) + -- Set 'id' with 'a_name'. + do + id := a_name + ensure + id_set: id = a_name + end + + set_username (a_name: like username) + -- Set 'username' with 'a_name'. + do + username := a_name + ensure + username_set: username = a_name + end + + set_first_name (a_name: like first_name) + -- Set 'first_name' with 'a_name'. + do + first_name := a_name + ensure + first_name_set: first_name = a_name + end + + set_last_name (a_name: like last_name) + -- Set 'last_name' with 'a_name'. + do + last_name := a_name + ensure + last_name_set: last_name = a_name + end + + set_email (a_name: like email) + -- Set 'email' with 'a_name'. + do + email := a_name + ensure + email_set: email = a_name + end + + set_password (a_name: like password) + -- Set 'password' with 'a_name'. + do + password := a_name + ensure + password_set: password = a_name + end + + set_phone (a_name: like phone) + -- Set 'phone' with 'a_name'. + do + phone := a_name + ensure + phone_set: phone = a_name + end + + set_user_status (a_name: like user_status) + -- Set 'user_status' with 'a_name'. + do + user_status := a_name + ensure + user_status_set: user_status = a_name + end + + + feature -- Status Report + + out: STRING + -- + do + create Result.make_empty + Result.append("%Nclass USER%N") + if attached id as l_id then + Result.append ("%N") + Result.append (l_id.out) + Result.append ("%N") + end + if attached username as l_username then + Result.append ("%N") + Result.append (l_username.out) + Result.append ("%N") + end + if attached first_name as l_first_name then + Result.append ("%N") + Result.append (l_first_name.out) + Result.append ("%N") + end + if attached last_name as l_last_name then + Result.append ("%N") + Result.append (l_last_name.out) + Result.append ("%N") + end + if attached email as l_email then + Result.append ("%N") + Result.append (l_email.out) + Result.append ("%N") + end + if attached password as l_password then + Result.append ("%N") + Result.append (l_password.out) + Result.append ("%N") + end + if attached phone as l_phone then + Result.append ("%N") + Result.append (l_phone.out) + Result.append ("%N") + end + if attached user_status as l_user_status then + Result.append ("%N") + Result.append (l_user_status.out) + Result.append ("%N") + end + end +end diff --git a/samples/client/petstore/eiffel/src/framework/api_client_request.e b/samples/client/petstore/eiffel/src/framework/api_client_request.e new file mode 100644 index 00000000000..51fd6841cfe --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/api_client_request.e @@ -0,0 +1,92 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +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 diff --git a/samples/client/petstore/eiffel/src/framework/api_client_response.e b/samples/client/petstore/eiffel/src/framework/api_client_response.e new file mode 100644 index 00000000000..9787f9672ca --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/api_client_response.e @@ -0,0 +1,74 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" +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 diff --git a/samples/client/petstore/eiffel/src/framework/api_error.e b/samples/client/petstore/eiffel/src/framework/api_error.e new file mode 100644 index 00000000000..e4cfc25666f --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/api_error.e @@ -0,0 +1,36 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +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 diff --git a/samples/client/petstore/eiffel/src/framework/api_i.e b/samples/client/petstore/eiffel/src/framework/api_i.e new file mode 100644 index 00000000000..37bc6f47b63 --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/api_i.e @@ -0,0 +1,112 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +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 \ No newline at end of file diff --git a/samples/client/petstore/eiffel/src/framework/auth/api_key_auth.e b/samples/client/petstore/eiffel/src/framework/auth/api_key_auth.e new file mode 100644 index 00000000000..4299d42e180 --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/auth/api_key_auth.e @@ -0,0 +1,77 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" +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]) + -- . + 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 diff --git a/samples/client/petstore/eiffel/src/framework/auth/authentication.e b/samples/client/petstore/eiffel/src/framework/auth/authentication.e new file mode 100644 index 00000000000..12c3f77c265 --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/auth/authentication.e @@ -0,0 +1,28 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +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 diff --git a/samples/client/petstore/eiffel/src/framework/auth/http_basic_auth.e b/samples/client/petstore/eiffel/src/framework/auth/http_basic_auth.e new file mode 100644 index 00000000000..e1528199e3d --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/auth/http_basic_auth.e @@ -0,0 +1,62 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +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]) + -- . + 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 diff --git a/samples/client/petstore/eiffel/src/framework/auth/oauth.e b/samples/client/petstore/eiffel/src/framework/auth/oauth.e new file mode 100644 index 00000000000..e432801c5fc --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/auth/oauth.e @@ -0,0 +1,43 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" +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]) + -- . + do + if attached access_token as l_access_token then + a_header_params.force ("Bearer " + l_access_token,"Authorization" ) + end + end +end diff --git a/samples/client/petstore/eiffel/src/framework/configuration.e b/samples/client/petstore/eiffel/src/framework/configuration.e new file mode 100644 index 00000000000..5f0d7ee52c3 --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/configuration.e @@ -0,0 +1,25 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +class + CONFIGURATION + +feature -- API client + + default_api_client: API_CLIENT + do + create Result.make + end +end diff --git a/samples/client/petstore/eiffel/src/framework/serialization/api_deserializer.e b/samples/client/petstore/eiffel/src/framework/serialization/api_deserializer.e new file mode 100644 index 00000000000..53f54dd1f9e --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/serialization/api_deserializer.e @@ -0,0 +1,26 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +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 diff --git a/samples/client/petstore/eiffel/src/framework/serialization/api_json_deserializer.e b/samples/client/petstore/eiffel/src/framework/serialization/api_json_deserializer.e new file mode 100644 index 00000000000..56442620c79 --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/serialization/api_json_deserializer.e @@ -0,0 +1,35 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +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 diff --git a/samples/client/petstore/eiffel/src/framework/serialization/api_json_serializer.e b/samples/client/petstore/eiffel/src/framework/serialization/api_json_serializer.e new file mode 100644 index 00000000000..8dab668cb92 --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/serialization/api_json_serializer.e @@ -0,0 +1,45 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +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 diff --git a/samples/client/petstore/eiffel/src/framework/serialization/api_serializer.e b/samples/client/petstore/eiffel/src/framework/serialization/api_serializer.e new file mode 100644 index 00000000000..e870c3da48d --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/serialization/api_serializer.e @@ -0,0 +1,27 @@ +note + description:"[ + Swagger Petstore + This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + OpenAPI spec version: 1.0.0 + Contact: apiteam@swagger.io + + 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" + +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 diff --git a/samples/client/petstore/eiffel/src/framework/serialization/json_basic_reflector_deserializer.e b/samples/client/petstore/eiffel/src/framework/serialization/json_basic_reflector_deserializer.e new file mode 100644 index 00000000000..91dc90ed929 --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/serialization/json_basic_reflector_deserializer.e @@ -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 + -- + 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 diff --git a/samples/client/petstore/eiffel/src/framework/serialization/json_type_utilities_ext.e b/samples/client/petstore/eiffel/src/framework/serialization/json_type_utilities_ext.e new file mode 100644 index 00000000000..bcc1c27d28f --- /dev/null +++ b/samples/client/petstore/eiffel/src/framework/serialization/json_type_utilities_ext.e @@ -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 diff --git a/samples/client/petstore/eiffel/test/api_test.ecf b/samples/client/petstore/eiffel/test/api_test.ecf new file mode 100644 index 00000000000..b6875d85f0b --- /dev/null +++ b/samples/client/petstore/eiffel/test/api_test.ecf @@ -0,0 +1,21 @@ + + + + + + /\.git$ + /\.svn$ + /CVS$ + /EIFGENs$ + + + + + + + + + + diff --git a/samples/client/petstore/eiffel/test/apis/pet_api_test.e b/samples/client/petstore/eiffel/test/apis/pet_api_test.e new file mode 100644 index 00000000000..d7e12953695 --- /dev/null +++ b/samples/client/petstore/eiffel/test/apis/pet_api_test.e @@ -0,0 +1,145 @@ +note + description: "API tests for PET_API" + date: "$Date$" + revision: "$Revision$" + + +class PET_API_TEST + +inherit + + EQA_TEST_SET + +feature -- Test routines + + + test_add_pet + -- Add a new pet to the store + -- + -- + local + l_body: PET + do + -- TODO: Initialize required params. + -- l_body + + -- api.add_pet(l_body) + assert ("not_implemented", False) + end + + test_delete_pet + -- Deletes a pet + -- + -- + local + l_petid: INTEGER_64 + l_api_key: STRING_32 + do + -- TODO: Initialize required params. + -- l_petid + + -- api.delete_pet(l_petid, l_api_key) + assert ("not_implemented", False) + end + + test_find_pets_by_status + -- Finds Pets by status + -- + -- Multiple status values can be provided with comma separated strings + local + l_response: LIST [PET] + l_status: LIST [STRING_32] + do + -- TODO: Initialize required params. + -- create {ARRAYED_LIST [STRING_32]} l_status.make (2) + + -- l_response := api.find_pets_by_status(l_status) + assert ("not_implemented", False) + end + + test_find_pets_by_tags + -- Finds Pets by tags + -- + -- Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + local + l_response: LIST [PET] + l_tags: LIST [STRING_32] + do + -- TODO: Initialize required params. + -- create {ARRAYED_LIST [STRING_32]} l_tags.make (2) + + -- l_response := api.find_pets_by_tags(l_tags) + assert ("not_implemented", False) + end + + test_pet_by_id + -- Find pet by ID + -- + -- Returns a single pet + local + l_response: PET + l_petid: INTEGER_64 + do + -- TODO: Initialize required params. + -- l_petid + + -- l_response := api.pet_by_id(l_petid) + assert ("not_implemented", False) + end + + test_update_pet + -- Update an existing pet + -- + -- + local + l_body: PET + do + -- TODO: Initialize required params. + -- l_body + + -- api.update_pet(l_body) + assert ("not_implemented", False) + end + + test_update_pet_with_form + -- Updates a pet in the store with form data + -- + -- + local + l_petid: INTEGER_64 + l_name: STRING_32 + l_status: STRING_32 + do + -- TODO: Initialize required params. + -- l_petid + + -- api.update_pet_with_form(l_petid, l_name, l_status) + assert ("not_implemented", False) + end + + test_upload_file + -- uploads an image + -- + -- + local + l_response: API_RESPONSE + l_petid: INTEGER_64 + l_additionalmetadata: STRING_32 + l_file: FILE + do + -- TODO: Initialize required params. + -- l_petid + + -- l_response := api.upload_file(l_petid, l_additionalmetadata, l_file) + assert ("not_implemented", False) + end + +feature {NONE} -- Implementation + + api: PET_API + -- Create an object instance of `PET_API'. + once + create { PET_API } Result + end + +end diff --git a/samples/client/petstore/eiffel/test/apis/store_api_test.e b/samples/client/petstore/eiffel/test/apis/store_api_test.e new file mode 100644 index 00000000000..75b5216cfbb --- /dev/null +++ b/samples/client/petstore/eiffel/test/apis/store_api_test.e @@ -0,0 +1,81 @@ +note + description: "API tests for STORE_API" + date: "$Date$" + revision: "$Revision$" + + +class STORE_API_TEST + +inherit + + EQA_TEST_SET + +feature -- Test routines + + + test_delete_order + -- Delete purchase order by ID + -- + -- For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors + local + l_orderid: INTEGER_64 + do + -- TODO: Initialize required params. + -- l_orderid + + -- api.delete_order(l_orderid) + assert ("not_implemented", False) + end + + test_inventory + -- Returns pet inventories by status + -- + -- Returns a map of status codes to quantities + local + l_response: STRING_TABLE[INTEGER_32] + do + -- TODO: Initialize required params. + + -- l_response := api.inventory + assert ("not_implemented", False) + end + + test_order_by_id + -- Find purchase order by ID + -- + -- For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions + local + l_response: ORDER + l_orderid: INTEGER_64 + do + -- TODO: Initialize required params. + -- l_orderid + + -- l_response := api.order_by_id(l_orderid) + assert ("not_implemented", False) + end + + test_place_order + -- Place an order for a pet + -- + -- + local + l_response: ORDER + l_body: ORDER + do + -- TODO: Initialize required params. + -- l_body + + -- l_response := api.place_order(l_body) + assert ("not_implemented", False) + end + +feature {NONE} -- Implementation + + api: STORE_API + -- Create an object instance of `STORE_API'. + once + create { STORE_API } Result + end + +end diff --git a/samples/client/petstore/eiffel/test/apis/user_api_test.e b/samples/client/petstore/eiffel/test/apis/user_api_test.e new file mode 100644 index 00000000000..edad881f1ec --- /dev/null +++ b/samples/client/petstore/eiffel/test/apis/user_api_test.e @@ -0,0 +1,140 @@ +note + description: "API tests for USER_API" + date: "$Date$" + revision: "$Revision$" + + +class USER_API_TEST + +inherit + + EQA_TEST_SET + +feature -- Test routines + + + test_create_user + -- Create user + -- + -- This can only be done by the logged in user. + local + l_body: USER + do + -- TODO: Initialize required params. + -- l_body + + -- api.create_user(l_body) + assert ("not_implemented", False) + end + + test_create_users_with_array_input + -- Creates list of users with given input array + -- + -- + local + l_body: LIST [USER] + do + -- TODO: Initialize required params. + -- create {ARRAYED_LIST [USER]} l_body.make (2) + + -- api.create_users_with_array_input(l_body) + assert ("not_implemented", False) + end + + test_create_users_with_list_input + -- Creates list of users with given input array + -- + -- + local + l_body: LIST [USER] + do + -- TODO: Initialize required params. + -- create {ARRAYED_LIST [USER]} l_body.make (2) + + -- api.create_users_with_list_input(l_body) + assert ("not_implemented", False) + end + + test_delete_user + -- Delete user + -- + -- This can only be done by the logged in user. + local + l_username: STRING_32 + do + -- TODO: Initialize required params. + -- l_username + + -- api.delete_user(l_username) + assert ("not_implemented", False) + end + + test_login_user + -- Logs user into the system + -- + -- + local + l_response: STRING_32 + l_username: STRING_32 + l_password: STRING_32 + do + -- TODO: Initialize required params. + -- l_username + -- l_password + + -- l_response := api.login_user(l_username, l_password) + assert ("not_implemented", False) + end + + test_logout_user + -- Logs out current logged in user session + -- + -- + local + do + -- TODO: Initialize required params. + + -- api.logout_user + assert ("not_implemented", False) + end + + test_update_user + -- Updated user + -- + -- This can only be done by the logged in user. + local + l_username: STRING_32 + l_body: USER + do + -- TODO: Initialize required params. + -- l_username + -- l_body + + -- api.update_user(l_username, l_body) + assert ("not_implemented", False) + end + + test_user_by_name + -- Get user by user name + -- + -- + local + l_response: USER + l_username: STRING_32 + do + -- TODO: Initialize required params. + -- l_username + + -- l_response := api.user_by_name(l_username) + assert ("not_implemented", False) + end + +feature {NONE} -- Implementation + + api: USER_API + -- Create an object instance of `USER_API'. + once + create { USER_API } Result + end + +end diff --git a/samples/client/petstore/eiffel/test/application.e b/samples/client/petstore/eiffel/test/application.e new file mode 100644 index 00000000000..b60cb204a86 --- /dev/null +++ b/samples/client/petstore/eiffel/test/application.e @@ -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 \ No newline at end of file From dd8d59bed162d2ddd1075d8d2a82103659a6ddef Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 13 Jul 2017 22:55:04 +0800 Subject: [PATCH 06/10] add jvelilla as eiffel template creator --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 71be1740139..564bc3cfc5d 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ ## 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: -- **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) - **API documentation generators**: **HTML**, **Confluence Wiki** - **Configuration files**: [**Apache2**](https://httpd.apache.org/) @@ -924,6 +924,7 @@ Here is a list of template creators: * Clojure: @xhh * Dart: @yissachar * Elixir: @niku + * Eiffel: @jvelilla * Groovy: @victorgit * Go: @wing328 * Go (rewritten in 2.3.0): @antihax From d20537b263d2bac09e121c8685d2a6b186dc69ce Mon Sep 17 00:00:00 2001 From: boosh Date: Thu, 13 Jul 2017 16:12:56 +0100 Subject: [PATCH 07/10] Clarify the Javascript README for local use (#6044) - Add instructions for installing the generated Javascript library locally without publishing to a remote npm registry. - Clarify what `main.js` is. --- .../main/resources/Javascript/README.mustache | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/Javascript/README.mustache b/modules/swagger-codegen/src/main/resources/Javascript/README.mustache index c13314a8960..4962803a76f 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/README.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/README.mustache @@ -31,6 +31,30 @@ Then install it via: 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/ +``` + +You should now be able to `require('{{{projectName}}}')` in javascript files from the directory you ran the last +command above from. + #### git # 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 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 browserify main.js > bundle.js From 21d33c4054a8996758acaca6405648d7c74d1964 Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 13 Jul 2017 23:25:23 +0800 Subject: [PATCH 08/10] skip pattern check for byte array in C# (#6048) --- .../src/main/resources/csharp/modelGeneric.mustache | 4 +++- .../csharp/SwaggerClient/src/IO.Swagger/Model/FormatTest.cs | 2 +- .../src/IO.Swagger/Model/FormatTest.cs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/csharp/modelGeneric.mustache b/modules/swagger-codegen/src/main/resources/csharp/modelGeneric.mustache index e8a543b2a0a..255984ded57 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/modelGeneric.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/modelGeneric.mustache @@ -241,13 +241,15 @@ this.{{name}} = {{name}}; {{/minimum}} {{#pattern}} + {{^isByteArray}} // {{{name}}} ({{{datatype}}}) pattern 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) { - 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}} {{/hasValidation}} {{/vars}} diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/FormatTest.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/FormatTest.cs index 2bf7d5997d2..ddf16ddad53 100644 --- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/FormatTest.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/FormatTest.cs @@ -415,7 +415,7 @@ namespace IO.Swagger.Model Regex regex_String = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); 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 diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/FormatTest.cs b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/FormatTest.cs index 8762cbe9751..706354c7b2d 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/FormatTest.cs +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/FormatTest.cs @@ -438,7 +438,7 @@ namespace IO.Swagger.Model Regex regex_String = new Regex(@"[a-z]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); 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 From d8bae71b8e680c223df7d3005feb2a649ffa4aa3 Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 13 Jul 2017 23:26:49 +0800 Subject: [PATCH 09/10] update JS petstore samples --- .../petstore/javascript-promise/README.md | 27 ++++++++++++++++++- samples/client/petstore/javascript/README.md | 27 ++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/samples/client/petstore/javascript-promise/README.md b/samples/client/petstore/javascript-promise/README.md index 6ad6f81b3f5..420c2e76e26 100644 --- a/samples/client/petstore/javascript-promise/README.md +++ b/samples/client/petstore/javascript-promise/README.md @@ -23,6 +23,30 @@ Then install it via: npm install swagger_petstore --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 swagger_petstore from, and run: + +```shell +npm link /path/to/ +``` + +You should now be able to `require('swagger_petstore')` in javascript files from the directory you ran the last +command above from. + #### git # If the library is hosted at a git repository, e.g. @@ -37,7 +61,8 @@ then install it via: 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`, -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 browserify main.js > bundle.js diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md index a58e731b223..de95e8d8001 100644 --- a/samples/client/petstore/javascript/README.md +++ b/samples/client/petstore/javascript/README.md @@ -23,6 +23,30 @@ Then install it via: npm install swagger_petstore --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 swagger_petstore from, and run: + +```shell +npm link /path/to/ +``` + +You should now be able to `require('swagger_petstore')` in javascript files from the directory you ran the last +command above from. + #### git # If the library is hosted at a git repository, e.g. @@ -37,7 +61,8 @@ then install it via: 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`, -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 browserify main.js > bundle.js From fdaf8ea65f0c4b0c6030fb4262d1b4656fbcd116 Mon Sep 17 00:00:00 2001 From: Isman Usoh Date: Thu, 13 Jul 2017 22:33:08 +0700 Subject: [PATCH 10/10] [Typescript-Angular2] add @summary JSDoc tag (#6028) * add @summary JSDoc tag * updatee sample and create windows script for typescript-angular2 * Fix for Review --- bin/windows/typescript-angular2-all.bat | 18 ++++++++++++++++++ .../resources/typescript-angular2/api.mustache | 4 +++- .../typescript-angular2/default/api/PetApi.ts | 16 ++++++++-------- .../default/api/StoreApi.ts | 8 ++++---- .../typescript-angular2/default/api/UserApi.ts | 16 ++++++++-------- .../typescript-angular2/npm/api/PetApi.ts | 16 ++++++++-------- .../typescript-angular2/npm/api/StoreApi.ts | 8 ++++---- .../typescript-angular2/npm/api/UserApi.ts | 16 ++++++++-------- .../with-interfaces/api/PetApi.ts | 16 ++++++++-------- .../with-interfaces/api/StoreApi.ts | 8 ++++---- .../with-interfaces/api/UserApi.ts | 16 ++++++++-------- 11 files changed, 81 insertions(+), 61 deletions(-) create mode 100644 bin/windows/typescript-angular2-all.bat diff --git a/bin/windows/typescript-angular2-all.bat b/bin/windows/typescript-angular2-all.bat new file mode 100644 index 00000000000..119de7e7bcc --- /dev/null +++ b/bin/windows/typescript-angular2-all.bat @@ -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% diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache index eac59ada743..08ab7e5bd51 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/api.mustache @@ -46,8 +46,10 @@ export class {{classname}} { {{#operation}} /** - * {{summary}} * {{notes}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} {{#allParams}}* @param {{paramName}} {{description}} {{/allParams}}*/ public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any): Observable<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> { diff --git a/samples/client/petstore/typescript-angular2/default/api/PetApi.ts b/samples/client/petstore/typescript-angular2/default/api/PetApi.ts index e5238eda30d..2d53ef4fcd2 100644 --- a/samples/client/petstore/typescript-angular2/default/api/PetApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/PetApi.ts @@ -42,8 +42,8 @@ export class PetApi { } /** - * Add a new pet to the store * + * @summary Add a new pet to the store * @param body Pet object that needs to be added to the store */ public addPet(body: models.Pet, extraHttpRequestParams?: any): Observable<{}> { @@ -58,8 +58,8 @@ export class PetApi { } /** - * Deletes a pet * + * @summary Deletes a pet * @param petId Pet id to delete * @param apiKey */ @@ -75,8 +75,8 @@ export class PetApi { } /** - * Finds Pets by status * Multiple status values can be provided with comma separated strings + * @summary Finds Pets by status * @param status Status values that need to be considered for filter */ public findPetsByStatus(status: Array, extraHttpRequestParams?: any): Observable> { @@ -91,8 +91,8 @@ export class PetApi { } /** - * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @summary Finds Pets by tags * @param tags Tags to filter by */ public findPetsByTags(tags: Array, extraHttpRequestParams?: any): Observable> { @@ -107,8 +107,8 @@ export class PetApi { } /** - * Find pet by ID * Returns a single pet + * @summary Find pet by ID * @param petId ID of pet to return */ public getPetById(petId: number, extraHttpRequestParams?: any): Observable { @@ -123,8 +123,8 @@ export class PetApi { } /** - * Update an existing pet * + * @summary Update an existing pet * @param body Pet object that needs to be added to the store */ public updatePet(body: models.Pet, extraHttpRequestParams?: any): Observable<{}> { @@ -139,8 +139,8 @@ export class PetApi { } /** - * Updates a pet in the store with form data * + * @summary Updates a pet in the store with form data * @param petId ID of pet that needs to be updated * @param name Updated name of the pet * @param status Updated status of the pet @@ -157,8 +157,8 @@ export class PetApi { } /** - * uploads an image * + * @summary uploads an image * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server * @param file file to upload diff --git a/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts b/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts index a4257efc440..d98c2c2047c 100644 --- a/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/StoreApi.ts @@ -42,8 +42,8 @@ export class StoreApi { } /** - * Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @summary Delete purchase order by ID * @param orderId ID of the order that needs to be deleted */ public deleteOrder(orderId: string, extraHttpRequestParams?: any): Observable<{}> { @@ -58,8 +58,8 @@ export class StoreApi { } /** - * Returns pet inventories by status * Returns a map of status codes to quantities + * @summary Returns pet inventories by status */ public getInventory(extraHttpRequestParams?: any): Observable<{ [key: string]: number; }> { return this.getInventoryWithHttpInfo(extraHttpRequestParams) @@ -73,8 +73,8 @@ export class StoreApi { } /** - * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @summary Find purchase order by ID * @param orderId ID of pet that needs to be fetched */ public getOrderById(orderId: number, extraHttpRequestParams?: any): Observable { @@ -89,8 +89,8 @@ export class StoreApi { } /** - * Place an order for a pet * + * @summary Place an order for a pet * @param body order placed for purchasing the pet */ public placeOrder(body: models.Order, extraHttpRequestParams?: any): Observable { diff --git a/samples/client/petstore/typescript-angular2/default/api/UserApi.ts b/samples/client/petstore/typescript-angular2/default/api/UserApi.ts index 681d5849424..4e7bcfbaf09 100644 --- a/samples/client/petstore/typescript-angular2/default/api/UserApi.ts +++ b/samples/client/petstore/typescript-angular2/default/api/UserApi.ts @@ -42,8 +42,8 @@ export class UserApi { } /** - * Create user * This can only be done by the logged in user. + * @summary Create user * @param body Created user object */ public createUser(body: models.User, extraHttpRequestParams?: any): Observable<{}> { @@ -58,8 +58,8 @@ export class UserApi { } /** - * Creates list of users with given input array * + * @summary Creates list of users with given input array * @param body List of user object */ public createUsersWithArrayInput(body: Array, extraHttpRequestParams?: any): Observable<{}> { @@ -74,8 +74,8 @@ export class UserApi { } /** - * Creates list of users with given input array * + * @summary Creates list of users with given input array * @param body List of user object */ public createUsersWithListInput(body: Array, extraHttpRequestParams?: any): Observable<{}> { @@ -90,8 +90,8 @@ export class UserApi { } /** - * Delete user * This can only be done by the logged in user. + * @summary Delete user * @param username The name that needs to be deleted */ public deleteUser(username: string, extraHttpRequestParams?: any): Observable<{}> { @@ -106,8 +106,8 @@ export class UserApi { } /** - * Get user by user name * + * @summary Get user by user name * @param username The name that needs to be fetched. Use user1 for testing. */ public getUserByName(username: string, extraHttpRequestParams?: any): Observable { @@ -122,8 +122,8 @@ export class UserApi { } /** - * Logs user into the system * + * @summary Logs user into the system * @param username The user name for login * @param password The password for login in clear text */ @@ -139,8 +139,8 @@ export class UserApi { } /** - * Logs out current logged in user session * + * @summary Logs out current logged in user session */ public logoutUser(extraHttpRequestParams?: any): Observable<{}> { return this.logoutUserWithHttpInfo(extraHttpRequestParams) @@ -154,8 +154,8 @@ export class UserApi { } /** - * Updated user * This can only be done by the logged in user. + * @summary Updated user * @param username name that need to be deleted * @param body Updated user object */ diff --git a/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts b/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts index e5238eda30d..2d53ef4fcd2 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/PetApi.ts @@ -42,8 +42,8 @@ export class PetApi { } /** - * Add a new pet to the store * + * @summary Add a new pet to the store * @param body Pet object that needs to be added to the store */ public addPet(body: models.Pet, extraHttpRequestParams?: any): Observable<{}> { @@ -58,8 +58,8 @@ export class PetApi { } /** - * Deletes a pet * + * @summary Deletes a pet * @param petId Pet id to delete * @param apiKey */ @@ -75,8 +75,8 @@ export class PetApi { } /** - * Finds Pets by status * Multiple status values can be provided with comma separated strings + * @summary Finds Pets by status * @param status Status values that need to be considered for filter */ public findPetsByStatus(status: Array, extraHttpRequestParams?: any): Observable> { @@ -91,8 +91,8 @@ export class PetApi { } /** - * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @summary Finds Pets by tags * @param tags Tags to filter by */ public findPetsByTags(tags: Array, extraHttpRequestParams?: any): Observable> { @@ -107,8 +107,8 @@ export class PetApi { } /** - * Find pet by ID * Returns a single pet + * @summary Find pet by ID * @param petId ID of pet to return */ public getPetById(petId: number, extraHttpRequestParams?: any): Observable { @@ -123,8 +123,8 @@ export class PetApi { } /** - * Update an existing pet * + * @summary Update an existing pet * @param body Pet object that needs to be added to the store */ public updatePet(body: models.Pet, extraHttpRequestParams?: any): Observable<{}> { @@ -139,8 +139,8 @@ export class PetApi { } /** - * Updates a pet in the store with form data * + * @summary Updates a pet in the store with form data * @param petId ID of pet that needs to be updated * @param name Updated name of the pet * @param status Updated status of the pet @@ -157,8 +157,8 @@ export class PetApi { } /** - * uploads an image * + * @summary uploads an image * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server * @param file file to upload diff --git a/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts b/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts index a4257efc440..d98c2c2047c 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/StoreApi.ts @@ -42,8 +42,8 @@ export class StoreApi { } /** - * Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @summary Delete purchase order by ID * @param orderId ID of the order that needs to be deleted */ public deleteOrder(orderId: string, extraHttpRequestParams?: any): Observable<{}> { @@ -58,8 +58,8 @@ export class StoreApi { } /** - * Returns pet inventories by status * Returns a map of status codes to quantities + * @summary Returns pet inventories by status */ public getInventory(extraHttpRequestParams?: any): Observable<{ [key: string]: number; }> { return this.getInventoryWithHttpInfo(extraHttpRequestParams) @@ -73,8 +73,8 @@ export class StoreApi { } /** - * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @summary Find purchase order by ID * @param orderId ID of pet that needs to be fetched */ public getOrderById(orderId: number, extraHttpRequestParams?: any): Observable { @@ -89,8 +89,8 @@ export class StoreApi { } /** - * Place an order for a pet * + * @summary Place an order for a pet * @param body order placed for purchasing the pet */ public placeOrder(body: models.Order, extraHttpRequestParams?: any): Observable { diff --git a/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts b/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts index 681d5849424..4e7bcfbaf09 100644 --- a/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts +++ b/samples/client/petstore/typescript-angular2/npm/api/UserApi.ts @@ -42,8 +42,8 @@ export class UserApi { } /** - * Create user * This can only be done by the logged in user. + * @summary Create user * @param body Created user object */ public createUser(body: models.User, extraHttpRequestParams?: any): Observable<{}> { @@ -58,8 +58,8 @@ export class UserApi { } /** - * Creates list of users with given input array * + * @summary Creates list of users with given input array * @param body List of user object */ public createUsersWithArrayInput(body: Array, extraHttpRequestParams?: any): Observable<{}> { @@ -74,8 +74,8 @@ export class UserApi { } /** - * Creates list of users with given input array * + * @summary Creates list of users with given input array * @param body List of user object */ public createUsersWithListInput(body: Array, extraHttpRequestParams?: any): Observable<{}> { @@ -90,8 +90,8 @@ export class UserApi { } /** - * Delete user * This can only be done by the logged in user. + * @summary Delete user * @param username The name that needs to be deleted */ public deleteUser(username: string, extraHttpRequestParams?: any): Observable<{}> { @@ -106,8 +106,8 @@ export class UserApi { } /** - * Get user by user name * + * @summary Get user by user name * @param username The name that needs to be fetched. Use user1 for testing. */ public getUserByName(username: string, extraHttpRequestParams?: any): Observable { @@ -122,8 +122,8 @@ export class UserApi { } /** - * Logs user into the system * + * @summary Logs user into the system * @param username The user name for login * @param password The password for login in clear text */ @@ -139,8 +139,8 @@ export class UserApi { } /** - * Logs out current logged in user session * + * @summary Logs out current logged in user session */ public logoutUser(extraHttpRequestParams?: any): Observable<{}> { return this.logoutUserWithHttpInfo(extraHttpRequestParams) @@ -154,8 +154,8 @@ export class UserApi { } /** - * Updated user * This can only be done by the logged in user. + * @summary Updated user * @param username name that need to be deleted * @param body Updated user object */ diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/PetApi.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/PetApi.ts index a87a3ba3edb..47593a22a8a 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/PetApi.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/PetApi.ts @@ -43,8 +43,8 @@ export class PetApi implements PetApiInterface { } /** - * Add a new pet to the store * + * @summary Add a new pet to the store * @param body Pet object that needs to be added to the store */ public addPet(body: models.Pet, extraHttpRequestParams?: any): Observable<{}> { @@ -59,8 +59,8 @@ export class PetApi implements PetApiInterface { } /** - * Deletes a pet * + * @summary Deletes a pet * @param petId Pet id to delete * @param apiKey */ @@ -76,8 +76,8 @@ export class PetApi implements PetApiInterface { } /** - * Finds Pets by status * Multiple status values can be provided with comma separated strings + * @summary Finds Pets by status * @param status Status values that need to be considered for filter */ public findPetsByStatus(status: Array, extraHttpRequestParams?: any): Observable> { @@ -92,8 +92,8 @@ export class PetApi implements PetApiInterface { } /** - * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @summary Finds Pets by tags * @param tags Tags to filter by */ public findPetsByTags(tags: Array, extraHttpRequestParams?: any): Observable> { @@ -108,8 +108,8 @@ export class PetApi implements PetApiInterface { } /** - * Find pet by ID * Returns a single pet + * @summary Find pet by ID * @param petId ID of pet to return */ public getPetById(petId: number, extraHttpRequestParams?: any): Observable { @@ -124,8 +124,8 @@ export class PetApi implements PetApiInterface { } /** - * Update an existing pet * + * @summary Update an existing pet * @param body Pet object that needs to be added to the store */ public updatePet(body: models.Pet, extraHttpRequestParams?: any): Observable<{}> { @@ -140,8 +140,8 @@ export class PetApi implements PetApiInterface { } /** - * Updates a pet in the store with form data * + * @summary Updates a pet in the store with form data * @param petId ID of pet that needs to be updated * @param name Updated name of the pet * @param status Updated status of the pet @@ -158,8 +158,8 @@ export class PetApi implements PetApiInterface { } /** - * uploads an image * + * @summary uploads an image * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server * @param file file to upload diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/StoreApi.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/StoreApi.ts index 4de8fdc315a..11ae6b687a6 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/StoreApi.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/StoreApi.ts @@ -43,8 +43,8 @@ export class StoreApi implements StoreApiInterface { } /** - * Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @summary Delete purchase order by ID * @param orderId ID of the order that needs to be deleted */ public deleteOrder(orderId: string, extraHttpRequestParams?: any): Observable<{}> { @@ -59,8 +59,8 @@ export class StoreApi implements StoreApiInterface { } /** - * Returns pet inventories by status * Returns a map of status codes to quantities + * @summary Returns pet inventories by status */ public getInventory(extraHttpRequestParams?: any): Observable<{ [key: string]: number; }> { return this.getInventoryWithHttpInfo(extraHttpRequestParams) @@ -74,8 +74,8 @@ export class StoreApi implements StoreApiInterface { } /** - * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @summary Find purchase order by ID * @param orderId ID of pet that needs to be fetched */ public getOrderById(orderId: number, extraHttpRequestParams?: any): Observable { @@ -90,8 +90,8 @@ export class StoreApi implements StoreApiInterface { } /** - * Place an order for a pet * + * @summary Place an order for a pet * @param body order placed for purchasing the pet */ public placeOrder(body: models.Order, extraHttpRequestParams?: any): Observable { diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/UserApi.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/UserApi.ts index 318c7ba6094..4fddd4c0902 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/UserApi.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/UserApi.ts @@ -43,8 +43,8 @@ export class UserApi implements UserApiInterface { } /** - * Create user * This can only be done by the logged in user. + * @summary Create user * @param body Created user object */ public createUser(body: models.User, extraHttpRequestParams?: any): Observable<{}> { @@ -59,8 +59,8 @@ export class UserApi implements UserApiInterface { } /** - * Creates list of users with given input array * + * @summary Creates list of users with given input array * @param body List of user object */ public createUsersWithArrayInput(body: Array, extraHttpRequestParams?: any): Observable<{}> { @@ -75,8 +75,8 @@ export class UserApi implements UserApiInterface { } /** - * Creates list of users with given input array * + * @summary Creates list of users with given input array * @param body List of user object */ public createUsersWithListInput(body: Array, extraHttpRequestParams?: any): Observable<{}> { @@ -91,8 +91,8 @@ export class UserApi implements UserApiInterface { } /** - * Delete user * This can only be done by the logged in user. + * @summary Delete user * @param username The name that needs to be deleted */ public deleteUser(username: string, extraHttpRequestParams?: any): Observable<{}> { @@ -107,8 +107,8 @@ export class UserApi implements UserApiInterface { } /** - * Get user by user name * + * @summary Get user by user name * @param username The name that needs to be fetched. Use user1 for testing. */ public getUserByName(username: string, extraHttpRequestParams?: any): Observable { @@ -123,8 +123,8 @@ export class UserApi implements UserApiInterface { } /** - * Logs user into the system * + * @summary Logs user into the system * @param username The user name for login * @param password The password for login in clear text */ @@ -140,8 +140,8 @@ export class UserApi implements UserApiInterface { } /** - * Logs out current logged in user session * + * @summary Logs out current logged in user session */ public logoutUser(extraHttpRequestParams?: any): Observable<{}> { return this.logoutUserWithHttpInfo(extraHttpRequestParams) @@ -155,8 +155,8 @@ export class UserApi implements UserApiInterface { } /** - * Updated user * This can only be done by the logged in user. + * @summary Updated user * @param username name that need to be deleted * @param body Updated user object */