forked from loafle/openapi-generator-original
Add Nim client code generator (#3879)
* First version of Nim Client * Add some codes * Add some codes * Add some codes * Add some codes * Add some codes * First version of Nim Client * Add some codes * Add some codes * [Dart] Fix README template and update testing doco (#3809) * [Dart] Fix README template and update testing doco - deleted redundant shell script - fixed and updated README template - updated test package and moved to a dev_dependency - removed old unused dev_dependency packages - updated testing documentation in petstore sample * Remove references to dart-flutter-petstore.sh * Fix typos * Fix typo * Support custom git repository (#3757) * add gitHost param to GeneratorSettings and related * parameterize gitHost in READMEs * parameterize gitHost in go.mod * parameterize gitHost in git_push * update petstore samples * run ./bin/utils/export_docs_generators.sh * run meta-codehen.sh * Revert "run meta-codehen.sh" This reverts commitd6d579f615. * Revert "run ./bin/utils/export_docs_generators.sh" This reverts commit1b81538198. * Revert "update petstore samples" This reverts commitf513add883. * run ensure-up-to-date * Add links to article and video (#3820) * Better Go code format (#3819) * better varible naming * better comments * better code format for go experimental client * better comment, update samples * Add some codes * Add some codes * Add some codes * Add gRPC Protobuf schema generator (#3818) * add grpc protobuf generator * update doc * add new doc * add windows batch, comment out root proto * 1792 fix remote spec handling and hash calculation (#3440) * fixed bug where nullApi.java would be generated. Instead, generated DefaultApi.java to match the default path /{pathParam} (#3821) * Revert "1792 fix remote spec handling and hash calculation (#3440)" This reverts commit2a2eefe93d. * Add nickmeinhold to Dart technical committee (#3830) * Bug #2845 typescript angular inheritance (#3812) * issue #2845: enable 'supportsMultipleInheritance' on typescript angular client codegen - note I reran ./bin/openapi3/typescript-angular-petstore-all.sh and no changes occurred. this suggests to me that the petstore.yaml sample should be improved to make use of the anyOf / allOf / oneOf keywords, in order to better show the effects of changes on generated code. * issue #2845: run ./bin/openapi3/typescript-angular-petstore-all.sh * run `mvn clean package && ./bin/typescript-angular-petstore-all.sh` * revert extranous files * fix warnings in csharp-netcore client (#3831) * Add missing files to the form request (#3834) * [client][go] avoid duplicated reflect imports (#3847) * Following up for #3440 (1792 fix remote spec handling and hash calculation) (#3826) * This patch fixes the bug that we cannot access to remote files when checking file updates. Following up #3440, supporting auth. * 1792 fix remote spec handling and hash calculation (#3440) (cherry picked from commit2a2eefe93d) * fix detecting remote file / local file logic while finding the hash file, taking care of IllegalArgumentException for local files. * add testcase * Add a link (#3850) * Add Element AI to the list (#3856) * maven-plugin-plugin 3.6.0 (#3854) * [Java][okhttp-gson] fix failure to deserialize floats (#3846) * fixed bug where nullApi.java would be generated. Instead, generated DefaultApi.java to match the default path /{pathParam} * fix to bug #3157 * update samples * Adds Http Info To Dart Api (#3851) * [C++][Pistache] Add missing setter for arrays (#3837) * [C++][Pistache] Add missing setter for arrays Fixes #3769 * [C++][Pistache] Update Petstore sample * typescript-inversify: improve check for required parameters, support multiple media types (#3849) * [typescript-inversify] Allow falsy parameters A required parameter to an api method must not be `null` or `undefined`. It can be any other falsy value, e.g. `""`, `0` or `false` though. This change makes sure an error is only thrown in the former case and not in the latter. * [typescript-inversify] Handle multiple media types The Accept and Content-Type HTTP headers can contain a list of media types. Previously all but the first media type in the api definition were ignored. Now the headers are properly generated. * [typescript-inversify] Fix http client interface The api service methods allow the `body` parameter to be optional. The parameter is then passed to an `IHttpClient`. So it needs to be optional there as well. Also fixed the sample implementation `HttpClient`. Fixes #3618. * [typescript-inversify] Regenerate Petstore sample * [typescript-inversify] Use more explicit null check This does not change the semantic of the generated code, but makes it more explicit. Co-Authored-By: Esteban Gehring <esteban.gehring@gmail.com> * [typescript-angular] allow empty string basePath (#3489) * [typescript-angular] Fixing #2731 - empty string basePath * typescript-angular: refactor base path configuration * typescript-angular: refactor base path configuration * Fix/r/serialization fix and minor 3xx resp fix (#3817) * fix(qlik): fix for minor serialization bug * fix(r): add petsore generated classes * fix(r): indendation fixes * typescript-axios: Fix baseoptions (#3866) * Fixed missing baseOptions of typescript-axios. The typescript-axios template was missing the baseOptions setting when building an API Configuration. Set it. * update sample. * re-generate typescript axios samples * Rename gRPC generator to "protobuf-schema" (#3864) * rename grpc generator to protobuf-schema * update doc * Prepare v4.1.2 release (#3873) * update samples * update date * fix version in readme * BugFix #2053 Spring Boot fails to parse LocalDate query parameter (#3860) Adds the format annotation so that Spring is able to serialize OpenApi date/date-time format into LocalDate/OffsetDateTime. * update doc, samples (#3875) * update stable release * Update the batch for Windows * Add a test snippet * Update ensure-up-to-date * Add Nim to README.md * Ran ensure-up-to-date to pass CircleCI tests
This commit is contained in:
committed by
William Cheng
parent
f27ff79e93
commit
f15f814d9b
23
samples/client/petstore/nim/.openapi-generator-ignore
Normal file
23
samples/client/petstore/nim/.openapi-generator-ignore
Normal file
@@ -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
|
||||
1
samples/client/petstore/nim/.openapi-generator/VERSION
Normal file
1
samples/client/petstore/nim/.openapi-generator/VERSION
Normal file
@@ -0,0 +1 @@
|
||||
4.1.3-SNAPSHOT
|
||||
54
samples/client/petstore/nim/README.md
Normal file
54
samples/client/petstore/nim/README.md
Normal file
@@ -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
|
||||
```
|
||||
|
||||
1
samples/client/petstore/nim/config.nim
Normal file
1
samples/client/petstore/nim/config.nim
Normal file
@@ -0,0 +1 @@
|
||||
const useragent* = "OpenAPI-Generator/1.0.0/nim"
|
||||
32
samples/client/petstore/nim/petstore.nim
Normal file
32
samples/client/petstore/nim/petstore.nim
Normal file
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
# Models
|
||||
import petstore/models/model_api_response
|
||||
import petstore/models/model_category
|
||||
import petstore/models/model_order
|
||||
import petstore/models/model_pet
|
||||
import petstore/models/model_tag
|
||||
import petstore/models/model_user
|
||||
|
||||
export model_api_response
|
||||
export model_category
|
||||
export model_order
|
||||
export model_pet
|
||||
export model_tag
|
||||
export model_user
|
||||
|
||||
# APIs
|
||||
import petstore/apis/api_pet
|
||||
import petstore/apis/api_store
|
||||
import petstore/apis/api_user
|
||||
|
||||
export api_pet
|
||||
export api_store
|
||||
export api_user
|
||||
107
samples/client/petstore/nim/petstore/apis/api_pet.nim
Normal file
107
samples/client/petstore/nim/petstore/apis/api_pet.nim
Normal file
@@ -0,0 +1,107 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
import httpclient
|
||||
import json
|
||||
import logging
|
||||
import marshal
|
||||
import options
|
||||
import strformat
|
||||
import strutils
|
||||
import tables
|
||||
import typetraits
|
||||
import uri
|
||||
|
||||
import ../models/model_api_response
|
||||
import ../models/model_pet
|
||||
|
||||
const basepath = "http://petstore.swagger.io/v2"
|
||||
|
||||
template constructResult[T](response: Response): untyped =
|
||||
if response.code in {Http200, Http201, Http202, Http204, Http206}:
|
||||
try:
|
||||
when name(stripGenericParams(T.typedesc).typedesc) == name(Table):
|
||||
(some(json.to(parseJson(response.body), T.typedesc)), response)
|
||||
else:
|
||||
(some(marshal.to[T](response.body)), response)
|
||||
except JsonParsingError:
|
||||
# The server returned a malformed response though the response code is 2XX
|
||||
# TODO: need better error handling
|
||||
error("JsonParsingError")
|
||||
(none(T.typedesc), response)
|
||||
else:
|
||||
(none(T.typedesc), response)
|
||||
|
||||
|
||||
proc addPet*(httpClient: HttpClient, body: Pet): Response =
|
||||
## Add a new pet to the store
|
||||
httpClient.headers["Content-Type"] = "application/json"
|
||||
httpClient.post(basepath & "/pet", $(%body))
|
||||
|
||||
|
||||
proc deletePet*(httpClient: HttpClient, petId: int64, api_key: string): Response =
|
||||
## Deletes a pet
|
||||
httpClient.headers["api_key"] = api_key
|
||||
httpClient.delete(basepath & fmt"/pet/{petId}")
|
||||
|
||||
|
||||
proc findPetsByStatus*(httpClient: HttpClient, status: seq[Status]): (Option[seq[Pet]], Response) =
|
||||
## Finds Pets by status
|
||||
let query_for_api_call = encodeQuery([
|
||||
("status", $status.join(",")), # Status values that need to be considered for filter
|
||||
])
|
||||
|
||||
let response = httpClient.get(basepath & "/pet/findByStatus" & "?" & query_for_api_call)
|
||||
constructResult[seq[Pet]](response)
|
||||
|
||||
|
||||
proc findPetsByTags*(httpClient: HttpClient, tags: seq[string]): (Option[seq[Pet]], Response) {.deprecated.} =
|
||||
## Finds Pets by tags
|
||||
let query_for_api_call = encodeQuery([
|
||||
("tags", $tags.join(",")), # Tags to filter by
|
||||
])
|
||||
|
||||
let response = httpClient.get(basepath & "/pet/findByTags" & "?" & query_for_api_call)
|
||||
constructResult[seq[Pet]](response)
|
||||
|
||||
|
||||
proc getPetById*(httpClient: HttpClient, petId: int64): (Option[Pet], Response) =
|
||||
## Find pet by ID
|
||||
|
||||
let response = httpClient.get(basepath & fmt"/pet/{petId}")
|
||||
constructResult[Pet](response)
|
||||
|
||||
|
||||
proc updatePet*(httpClient: HttpClient, body: Pet): Response =
|
||||
## Update an existing pet
|
||||
httpClient.headers["Content-Type"] = "application/json"
|
||||
httpClient.put(basepath & "/pet", $(%body))
|
||||
|
||||
|
||||
proc updatePetWithForm*(httpClient: HttpClient, petId: int64, name: string, status: string): Response =
|
||||
## Updates a pet in the store with form data
|
||||
httpClient.headers["Content-Type"] = "application/x-www-form-urlencoded"
|
||||
let query_for_api_call = encodeQuery([
|
||||
("name", $name), # Updated name of the pet
|
||||
("status", $status), # Updated status of the pet
|
||||
])
|
||||
httpClient.post(basepath & fmt"/pet/{petId}", $query_for_api_call)
|
||||
|
||||
|
||||
proc uploadFile*(httpClient: HttpClient, petId: int64, additionalMetadata: string, file: string): (Option[ApiResponse], Response) =
|
||||
## uploads an image
|
||||
httpClient.headers["Content-Type"] = "multipart/form-data"
|
||||
let query_for_api_call = newMultipartData({
|
||||
"additionalMetadata": $additionalMetadata, # Additional data to pass to server
|
||||
"file": $file, # file to upload
|
||||
})
|
||||
|
||||
let response = httpClient.post(basepath & fmt"/pet/{petId}/uploadImage", multipart=query_for_api_call)
|
||||
constructResult[ApiResponse](response)
|
||||
|
||||
66
samples/client/petstore/nim/petstore/apis/api_store.nim
Normal file
66
samples/client/petstore/nim/petstore/apis/api_store.nim
Normal file
@@ -0,0 +1,66 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
import httpclient
|
||||
import json
|
||||
import logging
|
||||
import marshal
|
||||
import options
|
||||
import strformat
|
||||
import strutils
|
||||
import tables
|
||||
import typetraits
|
||||
import uri
|
||||
|
||||
import ../models/model_order
|
||||
|
||||
const basepath = "http://petstore.swagger.io/v2"
|
||||
|
||||
template constructResult[T](response: Response): untyped =
|
||||
if response.code in {Http200, Http201, Http202, Http204, Http206}:
|
||||
try:
|
||||
when name(stripGenericParams(T.typedesc).typedesc) == name(Table):
|
||||
(some(json.to(parseJson(response.body), T.typedesc)), response)
|
||||
else:
|
||||
(some(marshal.to[T](response.body)), response)
|
||||
except JsonParsingError:
|
||||
# The server returned a malformed response though the response code is 2XX
|
||||
# TODO: need better error handling
|
||||
error("JsonParsingError")
|
||||
(none(T.typedesc), response)
|
||||
else:
|
||||
(none(T.typedesc), response)
|
||||
|
||||
|
||||
proc deleteOrder*(httpClient: HttpClient, orderId: string): Response =
|
||||
## Delete purchase order by ID
|
||||
httpClient.delete(basepath & fmt"/store/order/{orderId}")
|
||||
|
||||
|
||||
proc getInventory*(httpClient: HttpClient): (Option[Table[string, int]], Response) =
|
||||
## Returns pet inventories by status
|
||||
|
||||
let response = httpClient.get(basepath & "/store/inventory")
|
||||
constructResult[Table[string, int]](response)
|
||||
|
||||
|
||||
proc getOrderById*(httpClient: HttpClient, orderId: int64): (Option[Order], Response) =
|
||||
## Find purchase order by ID
|
||||
|
||||
let response = httpClient.get(basepath & fmt"/store/order/{orderId}")
|
||||
constructResult[Order](response)
|
||||
|
||||
|
||||
proc placeOrder*(httpClient: HttpClient, body: Order): (Option[Order], Response) =
|
||||
## Place an order for a pet
|
||||
httpClient.headers["Content-Type"] = "application/json"
|
||||
|
||||
let response = httpClient.post(basepath & "/store/order", $(%body))
|
||||
constructResult[Order](response)
|
||||
|
||||
91
samples/client/petstore/nim/petstore/apis/api_user.nim
Normal file
91
samples/client/petstore/nim/petstore/apis/api_user.nim
Normal file
@@ -0,0 +1,91 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
import httpclient
|
||||
import json
|
||||
import logging
|
||||
import marshal
|
||||
import options
|
||||
import strformat
|
||||
import strutils
|
||||
import tables
|
||||
import typetraits
|
||||
import uri
|
||||
|
||||
import ../models/model_user
|
||||
|
||||
const basepath = "http://petstore.swagger.io/v2"
|
||||
|
||||
template constructResult[T](response: Response): untyped =
|
||||
if response.code in {Http200, Http201, Http202, Http204, Http206}:
|
||||
try:
|
||||
when name(stripGenericParams(T.typedesc).typedesc) == name(Table):
|
||||
(some(json.to(parseJson(response.body), T.typedesc)), response)
|
||||
else:
|
||||
(some(marshal.to[T](response.body)), response)
|
||||
except JsonParsingError:
|
||||
# The server returned a malformed response though the response code is 2XX
|
||||
# TODO: need better error handling
|
||||
error("JsonParsingError")
|
||||
(none(T.typedesc), response)
|
||||
else:
|
||||
(none(T.typedesc), response)
|
||||
|
||||
|
||||
proc createUser*(httpClient: HttpClient, body: User): Response =
|
||||
## Create user
|
||||
httpClient.headers["Content-Type"] = "application/json"
|
||||
httpClient.post(basepath & "/user", $(%body))
|
||||
|
||||
|
||||
proc createUsersWithArrayInput*(httpClient: HttpClient, body: seq[User]): Response =
|
||||
## Creates list of users with given input array
|
||||
httpClient.headers["Content-Type"] = "application/json"
|
||||
httpClient.post(basepath & "/user/createWithArray", $(%body))
|
||||
|
||||
|
||||
proc createUsersWithListInput*(httpClient: HttpClient, body: seq[User]): Response =
|
||||
## Creates list of users with given input array
|
||||
httpClient.headers["Content-Type"] = "application/json"
|
||||
httpClient.post(basepath & "/user/createWithList", $(%body))
|
||||
|
||||
|
||||
proc deleteUser*(httpClient: HttpClient, username: string): Response =
|
||||
## Delete user
|
||||
httpClient.delete(basepath & fmt"/user/{username}")
|
||||
|
||||
|
||||
proc getUserByName*(httpClient: HttpClient, username: string): (Option[User], Response) =
|
||||
## Get user by user name
|
||||
|
||||
let response = httpClient.get(basepath & fmt"/user/{username}")
|
||||
constructResult[User](response)
|
||||
|
||||
|
||||
proc loginUser*(httpClient: HttpClient, username: string, password: string): (Option[string], Response) =
|
||||
## Logs user into the system
|
||||
let query_for_api_call = encodeQuery([
|
||||
("username", $username), # The user name for login
|
||||
("password", $password), # The password for login in clear text
|
||||
])
|
||||
|
||||
let response = httpClient.get(basepath & "/user/login" & "?" & query_for_api_call)
|
||||
constructResult[string](response)
|
||||
|
||||
|
||||
proc logoutUser*(httpClient: HttpClient): Response =
|
||||
## Logs out current logged in user session
|
||||
httpClient.get(basepath & "/user/logout")
|
||||
|
||||
|
||||
proc updateUser*(httpClient: HttpClient, username: string, body: User): Response =
|
||||
## Updated user
|
||||
httpClient.headers["Content-Type"] = "application/json"
|
||||
httpClient.put(basepath & fmt"/user/{username}", $(%body))
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
import json
|
||||
import tables
|
||||
|
||||
|
||||
type ApiResponse* = object
|
||||
## Describes the result of uploading an image resource
|
||||
code*: int
|
||||
`type`*: string
|
||||
message*: string
|
||||
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
import json
|
||||
import tables
|
||||
|
||||
|
||||
type Category* = object
|
||||
## A category for a pet
|
||||
id*: int64
|
||||
name*: string
|
||||
40
samples/client/petstore/nim/petstore/models/model_order.nim
Normal file
40
samples/client/petstore/nim/petstore/models/model_order.nim
Normal file
@@ -0,0 +1,40 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
import json
|
||||
import tables
|
||||
|
||||
|
||||
type Status* {.pure.} = enum
|
||||
Placed
|
||||
Approved
|
||||
Delivered
|
||||
|
||||
type Order* = object
|
||||
## An order for a pets from the pet store
|
||||
id*: int64
|
||||
petId*: int64
|
||||
quantity*: int
|
||||
shipDate*: string
|
||||
status*: Status ## Order Status
|
||||
complete*: bool
|
||||
|
||||
func `%`*(v: Status): JsonNode =
|
||||
let str = case v:
|
||||
of Status.Placed: "placed"
|
||||
of Status.Approved: "approved"
|
||||
of Status.Delivered: "delivered"
|
||||
|
||||
JsonNode(kind: JString, str: str)
|
||||
|
||||
func `$`*(v: Status): string =
|
||||
result = case v:
|
||||
of Status.Placed: "placed"
|
||||
of Status.Approved: "approved"
|
||||
of Status.Delivered: "delivered"
|
||||
42
samples/client/petstore/nim/petstore/models/model_pet.nim
Normal file
42
samples/client/petstore/nim/petstore/models/model_pet.nim
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
import json
|
||||
import tables
|
||||
|
||||
import model_category
|
||||
import model_tag
|
||||
|
||||
type Status* {.pure.} = enum
|
||||
Available
|
||||
Pending
|
||||
Sold
|
||||
|
||||
type Pet* = object
|
||||
## A pet for sale in the pet store
|
||||
id*: int64
|
||||
category*: Category
|
||||
name*: string
|
||||
photoUrls*: seq[string]
|
||||
tags*: seq[Tag]
|
||||
status*: Status ## pet status in the store
|
||||
|
||||
func `%`*(v: Status): JsonNode =
|
||||
let str = case v:
|
||||
of Status.Available: "available"
|
||||
of Status.Pending: "pending"
|
||||
of Status.Sold: "sold"
|
||||
|
||||
JsonNode(kind: JString, str: str)
|
||||
|
||||
func `$`*(v: Status): string =
|
||||
result = case v:
|
||||
of Status.Available: "available"
|
||||
of Status.Pending: "pending"
|
||||
of Status.Sold: "sold"
|
||||
17
samples/client/petstore/nim/petstore/models/model_tag.nim
Normal file
17
samples/client/petstore/nim/petstore/models/model_tag.nim
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
import json
|
||||
import tables
|
||||
|
||||
|
||||
type Tag* = object
|
||||
## A tag for a pet
|
||||
id*: int64
|
||||
name*: string
|
||||
23
samples/client/petstore/nim/petstore/models/model_user.nim
Normal file
23
samples/client/petstore/nim/petstore/models/model_user.nim
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
import json
|
||||
import tables
|
||||
|
||||
|
||||
type User* = object
|
||||
## A User who is purchasing from the pet store
|
||||
id*: int64
|
||||
username*: string
|
||||
firstName*: string
|
||||
lastName*: string
|
||||
email*: string
|
||||
password*: string
|
||||
phone*: string
|
||||
userStatus*: int ## User Status
|
||||
22
samples/client/petstore/nim/sample_client.nim
Normal file
22
samples/client/petstore/nim/sample_client.nim
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# OpenAPI Petstore
|
||||
#
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
#
|
||||
|
||||
import httpclient
|
||||
import logging
|
||||
import options
|
||||
|
||||
import petstore
|
||||
|
||||
import config
|
||||
|
||||
let logger = newConsoleLogger()
|
||||
addHandler(logger)
|
||||
|
||||
let client = newHttpClient()
|
||||
client.headers["User-Agent"] = config.useragent
|
||||
Reference in New Issue
Block a user