Skip to content

Commit 9f711ae

Browse files
jvelillawing328
authored andcommitted
[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.
1 parent ef076c3 commit 9f711ae

File tree

77 files changed

+7456
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+7456
-2
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/EiffelClientCodegen.java

Lines changed: 623 additions & 0 deletions
Large diffs are not rendered by default.

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ public GoClientCodegen() {
5656
"case", "defer", "go", "map", "struct",
5757
"chan", "else", "goto", "package", "switch",
5858
"const", "fallthrough", "if", "range", "type",
59-
"continue", "for", "import", "return", "var", "error", "ApiResponse",
60-
"nil")
59+
"continue", "for", "import", "return", "var", "error", "ApiResponse", "nil")
6160
// Added "error" as it's used so frequently that it may as well be a keyword
6261
);
6362

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Eiffel API client for {{packageName}}
2+
3+
{{#appDescription}}
4+
{{{appDescription}}}
5+
{{/appDescription}}
6+
7+
## Overview
8+
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.
9+
10+
- API version: {{appVersion}}
11+
- Package version: {{packageVersion}}
12+
{{^hideGenerationTimestamp}}
13+
- Build date: {{generatedDate}}
14+
{{/hideGenerationTimestamp}}
15+
- Build package: {{generatorClass}}
16+
{{#infoUrl}}
17+
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
18+
{{/infoUrl}}
19+
20+
## Installation
21+
Add the library into your Eiffel configuration file.
22+
```
23+
"<library name="api_client" location="%PATH_TO_EIFFEL_SWAGGER_CLIENT%\api_client.ecf"/>"
24+
```
25+
26+
## Documentation for API Endpoints
27+
28+
All URIs are relative to *{{basePath}}*
29+
30+
Class | Method | HTTP request | Description
31+
------------ | ------------- | ------------- | -------------
32+
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
33+
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
34+
35+
## Documentation For Models
36+
37+
{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
38+
{{/model}}{{/models}}
39+
40+
## Documentation For Authorization
41+
42+
{{^authMethods}} All endpoints do not require authorization.
43+
{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
44+
{{#authMethods}}## {{{name}}}
45+
46+
{{#isApiKey}}- **Type**: API key
47+
- **API key parameter name**: {{{keyParamName}}}
48+
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
49+
{{/isApiKey}}
50+
{{#isBasic}}- **Type**: HTTP basic authentication
51+
{{/isBasic}}
52+
{{#isOAuth}}- **Type**: OAuth
53+
- **Flow**: {{{flow}}}
54+
- **Authorization URL**: {{{authorizationUrl}}}
55+
- **Scopes**: {{^scopes}}N/A{{/scopes}}
56+
{{#scopes}} - **{{{scope}}}**: {{{description}}}
57+
{{/scopes}}
58+
{{/isOAuth}}
59+
60+
{{/authMethods}}
61+
62+
## Author
63+
64+
{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}}
65+
{{/hasMore}}{{/apis}}{{/apiInfo}}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{{>noteinfo}}
2+
{{#operations}}
3+
4+
class
5+
{{classname}}
6+
7+
inherit
8+
9+
API_I
10+
11+
12+
feature -- API Access
13+
14+
{{#operation}}
15+
16+
{{operationId}} {{#hasParams}}({{#allParams}}{{paramName}}: {{#required}}{{{dataType}}}{{/required}}{{^required}}detachable {{{dataType}}}{{/required}}{{#hasMore}}; {{/hasMore}}{{/allParams}}){{/hasParams}}{{#returnType}}: detachable {{{returnType}}}{{/returnType}}{{^returnType}}{{/returnType}}
17+
-- {{summary}}
18+
-- {{notes}}
19+
-- {{#allParams}}
20+
-- argument: {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
21+
-- {{/allParams}}
22+
-- {{#returnType}}
23+
-- Result {{returnType}}{{/returnType}}
24+
local
25+
l_path: STRING
26+
l_request: API_CLIENT_REQUEST
27+
l_response: API_CLIENT_RESPONSE
28+
do
29+
reset_error
30+
create l_request
31+
{{#bodyParam}}l_request.set_body({{paramName}}){{/bodyParam}}
32+
l_path := "{{{path}}}"
33+
{{#pathParams}}
34+
l_path.replace_substring_all ("{"+"{{baseName}}"+"}", api_client.url_encode ({{{paramName}}}.out))
35+
{{/pathParams}}
36+
{{#queryParams}}
37+
l_request.fill_query_params(api_client.parameter_to_tuple("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
38+
{{/queryParams}}
39+
{{#headerParams}}
40+
if attached {{paramName}} as l_{{paramName}} then
41+
l_request.add_header(l_{{paramName}}.out,"{{baseName}}");
42+
end
43+
{{/headerParams}}
44+
{{#formParams}}
45+
if attached {{paramName}} as l_{{paramName}} then
46+
l_request.add_form(l_{{paramName}},"{{baseName}}");
47+
end
48+
{{/formParams}}
49+
50+
if attached {STRING} api_client.select_header_accept (<<{{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}>>) as l_accept then
51+
l_request.add_header(l_accept,"Accept");
52+
end
53+
l_request.add_header(api_client.select_header_content_type (<<{{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}>>),"Content-Type")
54+
l_request.set_auth_names (<<{{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}}>>)
55+
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}})
56+
{{#returnType}}
57+
if l_response.has_error then
58+
last_error := l_response.error
59+
elseif attached { {{{returnType}}} } l_response.data ({ {{{returnType}}} }) as l_data then
60+
Result := l_data
61+
else
62+
create last_error.make ("Unknown error: Status response [ " + l_response.status.out + "]")
63+
end
64+
{{/returnType}}
65+
{{^returnType}}
66+
if l_response.has_error then
67+
last_error := l_response.error
68+
end
69+
{{/returnType}}
70+
end
71+
{{/operation}}
72+
73+
74+
end
75+
{{/operations}}

0 commit comments

Comments
 (0)