-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Add Nim client code generator #3879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
f266380
First version of Nim Client
hokamoto 18d367a
Add some codes
hokamoto 9639569
Add some codes
hokamoto a999b5e
Add some codes
hokamoto 5d73b11
Add some codes
hokamoto 3880039
Add some codes
hokamoto c48f0a0
First version of Nim Client
hokamoto c5e4713
Add some codes
hokamoto feb96b1
Add some codes
hokamoto 5fdc0ab
Add some codes
hokamoto ae33303
Add some codes
hokamoto ba35508
Add some codes
hokamoto fc74ece
[Dart] Fix README template and update testing doco (#3809)
nickmeinhold 7b4a201
Support custom git repository (#3757)
qmuntal 2451702
Add links to article and video (#3820)
wing328 9ef73eb
Better Go code format (#3819)
wing328 c90c6c8
Add gRPC Protobuf schema generator (#3818)
wing328 bdfed92
1792 fix remote spec handling and hash calculation (#3440)
7c5cfb7
fixed bug where nullApi.java would be generated. Instead, generated …
bensimpson-ch 99eb680
Revert "1792 fix remote spec handling and hash calculation (#3440)"
wing328 ac1f19d
Add nickmeinhold to Dart technical committee (#3830)
wing328 9cbcebc
Bug #2845 typescript angular inheritance (#3812)
mnahkies 9ba0dd0
fix warnings in csharp-netcore client (#3831)
wing328 5d21a8f
Add missing files to the form request (#3834)
etherealjoy 8c637fb
[client][go] avoid duplicated reflect imports (#3847)
qmuntal f26f726
Following up for #3440 (1792 fix remote spec handling and hash calcul…
fuj1g0n 4a1eb91
Add a link (#3850)
ackintosh 3228ca2
Add Element AI to the list (#3856)
wing328 2fb08fb
maven-plugin-plugin 3.6.0 (#3854)
sullis 221443a
[Java][okhttp-gson] fix failure to deserialize floats (#3846)
bensimpson-ch adf1297
Adds Http Info To Dart Api (#3851)
austbot 86adb0a
[C++][Pistache] Add missing setter for arrays (#3837)
muttleyxd 82f00f2
typescript-inversify: improve check for required parameters, support …
bodograumann 0f10987
[typescript-angular] allow empty string basePath (#3489)
martinnovak bf441c2
Fix/r/serialization fix and minor 3xx resp fix (#3817)
Ramanth e51ffbe
typescript-axios: Fix baseoptions (#3866)
7474 0396bb4
Rename gRPC generator to "protobuf-schema" (#3864)
wing328 3dd0ebd
Prepare v4.1.2 release (#3873)
wing328 58ec946
fix version in readme
macjohnny 580ca11
BugFix #2053 Spring Boot fails to parse LocalDate query parameter (#3…
peyerroger fbb3b27
update doc, samples (#3875)
wing328 549fc8f
update stable release
wing328 bface47
Update the batch for Windows
hokamoto 5a28be0
Merge branch 'nim-client' of github.com:hokamoto/openapi-generator in…
hokamoto 19cc13b
Merge remote-tracking branch 'upstream/master' into nim-client
hokamoto 2db44c7
Add a test snippet
hokamoto bcec49b
Update ensure-up-to-date
hokamoto 7276034
Add Nim to README.md
hokamoto 090875b
Ran ensure-up-to-date to pass CircleCI tests
hokamoto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add some codes
- Loading branch information
commit ba355082a4d9c47ebf2ba3f72e244ff22599a256
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
modules/openapi-generator/src/main/resources/nim-client/lib.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| {{>header}} | ||
| # Models | ||
| {{#models}}{{#model}}import {{packageName}}/models/{{classFilename}} | ||
| {{/model}}{{/models}}{{#models}} | ||
| {{#model}}export {{classFilename}}{{/model}}{{/models}} | ||
|
|
||
| # APIs | ||
| {{#apiInfo}}{{#apis}}import {{packageName}}/apis/{{classFilename}} | ||
| {{/apis}}{{/apiInfo}}{{#apiInfo}} | ||
| {{#apis}}export {{classFilename}} | ||
| {{/apis}}{{/apiInfo}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,163 +3,12 @@ import httpclient | |
| import logging | ||
| import options | ||
|
|
||
| import {{{packageName}}} | ||
|
|
||
| import config | ||
|
|
||
| # Models | ||
| {{#models}}{{#model}}import {{packageName}}/models/{{classFilename}} | ||
| {{/model}}{{/models}} | ||
| # APIs | ||
| {{#apiInfo}}{{#apis}}import {{packageName}}/apis/{{classFilename}} | ||
| {{/apis}}{{/apiInfo}} | ||
| let logger = newConsoleLogger() | ||
| addHandler(logger) | ||
|
|
||
| let client = newHttpClient() | ||
| client.headers["User-Agent"] = config.useragent | ||
|
|
||
| # Test Pet | ||
| let category = Category(id: 1, name : "Shiba") | ||
| let tag1 = Tag(id: 1, name: "blood A") | ||
| let tag2 = Tag(id: 2, name: "tel 1234-5678") | ||
| let photos = @[ | ||
| "https://www.asahicom.jp/articles/images/AS20190719000785_commL.jpg", | ||
| "https://cdn0.mynvwm.com/wp-content/uploads/2019/02/adorable-animal-breed-1805164-e1549450482765.jpg" | ||
| ] | ||
| let pochi = Pet(id: 1, category: category, name: "Pochi", photoUrls: photos, tags: @[tag1, tag2], status: Available) | ||
| let tama = Pet(id: 1, category: category, name: "Tama", photoUrls: photos, tags: @[tag1], status: Sold) | ||
|
|
||
| # Test Order | ||
| let myorder = Order( | ||
| id: 1, | ||
| petId: 1, | ||
| quantity: 3, | ||
| shipDate: "2019-09-08T13:53:16.603+0000", | ||
| status: Delivered, | ||
| complete: false, | ||
| ) | ||
|
|
||
| # Test User | ||
| let jdoe = User( | ||
| id: 1, | ||
| username: "jdoe", | ||
| firstName: "John", | ||
| lastName: "Doe", | ||
| email: "[email protected]", | ||
| password: "password1234", | ||
| phone: "0011223344", | ||
| userStatus: 1 | ||
| ) | ||
|
|
||
| let asmithee = User( | ||
| id: 2, | ||
| username: "asmithee", | ||
| firstName: "Alan", | ||
| lastName: "Smithee", | ||
| email: "[email protected]", | ||
| password: "password5678", | ||
| phone: "99887766", | ||
| userStatus: 2 | ||
| ) | ||
|
|
||
| block: | ||
| let response = client.createUser(jdoe) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let response = client.deleteUser("jdoe") | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let response = client.createUsersWithArrayInput(@[jdoe, asmithee]) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let response = client.createUsersWithListInput(@[jdoe, asmithee]) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let response = client.updateUser("jdoe", jdoe) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let (api_result, response) = client.getUserByName("asmithee") | ||
| echo(repr(api_result)) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let (api_result, response) = client.loginUser("user", "pass") | ||
| echo(repr(api_result)) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let response = client.logoutUser() | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let (api_result, response) = client.getOrderById(1) | ||
| echo(repr(api_result)) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let response = client.deleteOrder("1") | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let (api_result, response) = client.placeOrder(myorder) | ||
| echo(repr(api_result)) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let (api_result, response) = client.getOrderById(1) | ||
| echo(repr(api_result)) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let (api_result, response) = client.getInventory() | ||
| echo(repr(api_result)) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let response = client.addPet(pochi) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let response = client.deletePet(1, "") | ||
| echo(response.code) | ||
| discard client.addPet(pochi) | ||
|
|
||
| block: | ||
| let (api_result, response) = client.findPetsByStatus(@[Sold]) | ||
| echo(repr(api_result)) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let (api_result, response) = client.findPetsByTags(@["blood A"]) | ||
| echo(repr(api_result)) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let (api_result, response) = client.getPetById(1) | ||
| echo(repr(api_result)) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let response = client.updatePet(tama) | ||
| echo(response.code) | ||
| block: | ||
| let (api_result, response) = client.getPetById(1) | ||
| echo(repr(api_result)) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let response = client.updatePetWithForm(1, "Kuro", "pending") | ||
| echo(response.code) | ||
| block: | ||
| let (api_result, response) = client.getPetById(1) | ||
| echo(repr(api_result)) | ||
| echo(response.code) | ||
|
|
||
| block: | ||
| let (api_result, response) = client.uploadFile(1, "kuro's photo", "kuro.jpg") | ||
| echo(repr(api_result)) | ||
| echo(response.code) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # OpenAPI Generator Ignore | ||
| # Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
|
||
| # 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 OpenAPI Generator 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 4.1.2-SNAPSHOT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Nim API client for OpenAPI Petstore (Package: petstore) | ||
|
|
||
| This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. | ||
|
|
||
| ## Overview | ||
|
|
||
| This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. | ||
|
|
||
| - API version: 1.0.0 | ||
| - Package version: 1.0.0 | ||
| - Build package: org.openapitools.codegen.languages.NimClientCodegen | ||
|
|
||
| ## Installation | ||
|
|
||
| Put the package under your project folder and add the following to the nimble file of your project: | ||
|
|
||
| ``` | ||
| import petstore | ||
| ``` | ||
|
|
||
| ## Documentation for API Endpoints | ||
|
|
||
| All URIs are relative to *http://petstore.swagger.io/v2* | ||
|
|
||
| Module | Proc | HTTP request | Description | ||
| ------------ | ------------- | ------------- | ------------- | ||
| api_pet | addPet | **POST** /pet | Add a new pet to the store | ||
| api_pet | deletePet | **DELETE** /pet/{petId} | Deletes a pet | ||
| api_pet | findPetsByStatus | **GET** /pet/findByStatus | Finds Pets by status | ||
| api_pet | findPetsByTags | **GET** /pet/findByTags | Finds Pets by tags | ||
| api_pet | getPetById | **GET** /pet/{petId} | Find pet by ID | ||
| api_pet | updatePet | **PUT** /pet | Update an existing pet | ||
| api_pet | updatePetWithForm | **POST** /pet/{petId} | Updates a pet in the store with form data | ||
| api_pet | uploadFile | **POST** /pet/{petId}/uploadImage | uploads an image | ||
| api_store | deleteOrder | **DELETE** /store/order/{orderId} | Delete purchase order by ID | ||
| api_store | getInventory | **GET** /store/inventory | Returns pet inventories by status | ||
| api_store | getOrderById | **GET** /store/order/{orderId} | Find purchase order by ID | ||
| api_store | placeOrder | **POST** /store/order | Place an order for a pet | ||
| api_user | createUser | **POST** /user | Create user | ||
| api_user | createUsersWithArrayInput | **POST** /user/createWithArray | Creates list of users with given input array | ||
| api_user | createUsersWithListInput | **POST** /user/createWithList | Creates list of users with given input array | ||
| api_user | deleteUser | **DELETE** /user/{username} | Delete user | ||
| api_user | getUserByName | **GET** /user/{username} | Get user by user name | ||
| api_user | loginUser | **GET** /user/login | Logs user into the system | ||
| api_user | logoutUser | **GET** /user/logout | Logs out current logged in user session | ||
| api_user | updateUser | **PUT** /user/{username} | Updated user | ||
|
|
||
|
|
||
| To generate documentation with Nim DocGen, use: | ||
|
|
||
| ``` | ||
| nim doc --project --index:on petstore.nim | ||
| ``` | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| const useragent* = "OpenAPI-Generator/1.0.0/nim" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're using 4 space indention so I'll reformat the code in a separate PR.