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 commit d6d579f6159186531257cdfdd73b9caf9e9ffeba.

* Revert "run ./bin/utils/export_docs_generators.sh"

This reverts commit 1b81538198d4319fd1b4e97447303e3cc0e8dc99.

* Revert "update petstore samples"

This reverts commit f513add88396707f6991ae2e4920359583ec88f1.

* 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 commit 2a2eefe93d81b8d253745b8adb002ab2cb9eee04.

* 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 commit 2a2eefe93d81b8d253745b8adb002ab2cb9eee04)

* 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:
Hideki Okamoto 2019-09-13 16:56:54 +09:00 committed by William Cheng
parent f27ff79e93
commit f15f814d9b
32 changed files with 1147 additions and 1 deletions

View File

@ -65,7 +65,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
| | Languages/Frameworks |
|-|-|
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.0, .NET Core 2.0), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 8.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
**API clients** | **ActionScript**, **Ada**, **Apex**, **Bash**, **C**, **C#** (.net 2.0, 3.5 or later, .NET Standard 1.3 - 2.0, .NET Core 2.0), **C++** (cpp-restsdk, Qt5, Tizen), **Clojure**, **Dart (1.x, 2.x)**, **Elixir**, **Elm**, **Eiffel**, **Erlang**, **Go**, **Groovy**, **Haskell** (http-client, Servant), **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign, RestTemplate, RESTEasy, Vertx, Google API Client Library for Java, Rest-assured, Spring 5 Web Client), **Kotlin**, **Lua**, **Nim**, **Node.js/JavaScript** (ES5, ES6, AngularJS with Google Closure Compiler annotations, Flow types), **Objective-C**, **OCaml**, **Perl**, **PHP**, **PowerShell**, **Python**, **R**, **Ruby**, **Rust** (rust, rust-server), **Scala** (akka, http4s, scalaz, swagger-async-httpclient), **Swift** (2.x, 3.x, 4.x), **Typescript** (AngularJS, Angular (2.x - 8.x), Aurelia, Axios, Fetch, Inversify, jQuery, Node, Rxjs)
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot, Ktor), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra)
**API documentation generators** | **HTML**, **Confluence Wiki**
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
@ -699,6 +699,7 @@ Here is a list of template creators:
* JMeter: @davidkiss
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
* Lua: @daurnimator
* Nim: @hokamoto
* OCaml: @cgensoul
* Perl: @wing328 [:heart:](https://www.patreon.com/wing328)
* PHP (Guzzle): @baartosz
@ -825,6 +826,7 @@ If you want to join the committee, please kindly apply by sending an email to te
| Java | @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) |
| Kotlin | @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) |
| Lua | @daurnimator (2017/08) |
| Nim | |
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
| ObjC | |
| OCaml | @cgensoul (2019/08) |

31
bin/nim-client-petstore.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
SCRIPT="$0"
while [ -h "$SCRIPT" ] ; do
ls=$(ls -ld "$SCRIPT")
link=$(expr "$ls" : '.*-> \(.*\)$')
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=$(dirname "$SCRIPT")/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=$(dirname "$SCRIPT")/..
APP_DIR=$(cd "${APP_DIR}"; pwd)
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/openapi-generator/src/main/resources/nim-client -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml --additional-properties packageName=petstore -g nim -o samples/client/petstore/nim"
java ${JAVA_OPTS} -jar ${executable} ${ags}

View File

@ -28,6 +28,7 @@ declare -a scripts=(
"./bin/kotlin-springboot-petstore-server.sh"
"./bin/kotlin-springboot-petstore-server-reactive.sh"
"./bin/mysql-schema-petstore.sh"
"./bin/nim-client-petstore.sh"
"./bin/python-petstore-all.sh"
"./bin/openapi3/python-petstore.sh"
"./bin/php-petstore.sh"

View File

@ -0,0 +1,10 @@
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate --artifact-id "nim-petstore-client" -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml --additional-properties packageName=petstore -g nim -o samples\client\petstore\nim
java %JAVA_OPTS% -jar %executable% %ags%

View File

@ -38,6 +38,7 @@ The following generators are available:
* [jmeter](generators/jmeter)
* [kotlin](generators/kotlin)
* [lua](generators/lua)
* [nim](generators/nim)
* [objc](generators/objc)
* [ocaml](generators/ocaml)
* [perl](generators/perl)

13
docs/generators/nim.md Normal file
View File

@ -0,0 +1,13 @@
---
id: generator-opts-client-nim
title: Config Options for nim
sidebar_label: nim
---
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|

View File

@ -0,0 +1,309 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
static Logger LOGGER = LoggerFactory.getLogger(NimClientCodegen.class);
public static final String PROJECT_NAME = "projectName";
protected String packageName = "openapiclient";
protected String packageVersion = "1.0.0";
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "nim";
}
public String getHelp() {
return "Generates a nim client.";
}
public NimClientCodegen() {
super();
outputFolder = "generated-code" + File.separator + "nim";
modelTemplateFiles.put("model.mustache", ".nim");
apiTemplateFiles.put("api.mustache", ".nim");
embeddedTemplateDir = templateDir = "nim-client";
apiPackage = File.separator + packageName + File.separator + "apis";
modelPackage = File.separator + packageName + File.separator + "models";
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("sample_client.mustache", "", "sample_client.nim"));
supportingFiles.add(new SupportingFile("config.mustache", "", "config.nim"));
setReservedWordsLowerCase(
Arrays.asList(
"addr", "and", "as", "asm",
"bind", "block", "break",
"case", "cast", "concept", "const", "continue", "converter",
"defer", "discard", "distinct", "div", "do",
"elif", "else", "end", "enum", "except", "export",
"finally", "for", "from", "func",
"if", "import", "in", "include", "interface", "is", "isnot", "iterator",
"let",
"macro", "method", "mixin", "mod",
"nil", "not", "notin",
"object", "of", "or", "out",
"proc", "ptr",
"raise", "ref", "return",
"shl", "shr", "static",
"template", "try", "tuple", "type",
"using",
"var",
"when", "while",
"xor",
"yield"
)
);
defaultIncludes = new HashSet<String>(
Arrays.asList(
"array"
)
);
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"int",
"int8",
"int16",
"int32",
"int64",
"uint",
"uint8",
"uint16",
"uint32",
"uint64",
"float",
"float32",
"float64",
"bool",
"char",
"string",
"cstring",
"pointer")
);
typeMapping.clear();
typeMapping.put("integer", "int");
typeMapping.put("long", "int64");
typeMapping.put("number", "float");
typeMapping.put("float", "float");
typeMapping.put("double", "float64");
typeMapping.put("boolean", "bool");
typeMapping.put("UUID", "string");
typeMapping.put("URI", "string");
typeMapping.put("date", "string");
typeMapping.put("DateTime", "string");
typeMapping.put("password", "string");
typeMapping.put("file", "string");
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public void setPackageVersion(String packageVersion) {
this.packageVersion = packageVersion;
}
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
return postProcessModelsEnum(objs);
}
@Override
public void processOpts() {
super.processOpts();
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
}
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
}
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
apiPackage = File.separator + packageName + File.separator + "apis";
modelPackage = File.separator + packageName + File.separator + "models";
supportingFiles.add(new SupportingFile("lib.mustache", "", packageName + ".nim"));
}
@Override
public String escapeReservedWord(String name) {
LOGGER.warn("A reserved word \"" + name + "\" is used. Consider renaming the field name");
if (this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
return "`" + name + "`";
}
@Override
public String escapeQuotationMark(String input) {
return input.replace("\"", "");
}
@Override
public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "*_/").replace("/*", "/_*");
}
@Override
public String toModelImport(String name) {
name = name.replaceAll("-", "_");
if (importMapping.containsKey(name)) {
return "model_" + StringUtils.underscore(importMapping.get(name));
} else {
return "model_" + StringUtils.underscore(name);
}
}
@Override
public String toApiImport(String name) {
name = name.replaceAll("-", "_");
if (importMapping.containsKey(name)) {
return "api_" + StringUtils.underscore(importMapping.get(name));
} else {
return "api_" + StringUtils.underscore(name);
}
}
@Override
public String toModelFilename(String name) {
name = name.replaceAll("-", "_");
return "model_" + StringUtils.underscore(name);
}
@Override
public String toApiFilename(String name) {
name = name.replaceAll("-", "_");
return "api_" + StringUtils.underscore(name);
}
@Override
public String toOperationId(String operationId) {
String sanitizedOperationId = sanitizeName(operationId);
if (isReservedWord(sanitizedOperationId)) {
sanitizedOperationId = "call" + StringUtils.camelize(sanitizedOperationId, false);
}
return StringUtils.camelize(sanitizedOperationId, true);
}
@Override
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
@SuppressWarnings("unchecked")
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
@SuppressWarnings("unchecked")
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
for (CodegenOperation operation : operations) {
operation.httpMethod = operation.httpMethod.toLowerCase(Locale.ROOT);
}
return objs;
}
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
if (inner == null) {
return null;
}
return "seq[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
if (inner == null) {
inner = new StringSchema();
}
return "Table[string, " + getTypeDeclaration(inner) + "]";
}
String schemaType = getSchemaType(p);
if (typeMapping.containsKey(schemaType)) {
return typeMapping.get(schemaType);
}
if (schemaType.matches("\\d.*")) { // starts with number
return "`" + schemaType + "`";
} else {
return schemaType;
}
}
@Override
public String toVarName(String name) {
if (isReservedWord(name)) {
name = escapeReservedWord(name);
}
if (name.matches("^\\d.*")) {
name = "`" + name + "`";
}
return name;
}
@Override
public String toParamName(String name) {
return toVarName(name);
}
@Override
protected boolean needToImport(String type) {
if (defaultIncludes.contains(type)) {
return false;
} else if (languageSpecificPrimitives.contains(type)) {
return false;
} else if (typeMapping.containsKey(type) && languageSpecificPrimitives.contains(typeMapping.get(type))) {
return false;
}
return true;
}
@Override
public String toEnumName(CodegenProperty property) {
String name = StringUtils.camelize(property.name, false);
if (name.matches("\\d.*")) { // starts with number
return "`" + name + "`";
} else {
return name;
}
}
@Override
public String toEnumVarName(String name, String datatype) {
name = name.replace(" ", "_");
name = StringUtils.camelize(name, false);
if (name.matches("\\d.*")) { // starts with number
return "`" + name + "`";
} else {
return name;
}
}
}

View File

@ -61,6 +61,7 @@ org.openapitools.codegen.languages.JavascriptClosureAngularClientCodegen
org.openapitools.codegen.languages.JMeterClientCodegen
org.openapitools.codegen.languages.LuaClientCodegen
org.openapitools.codegen.languages.MysqlSchemaCodegen
org.openapitools.codegen.languages.NimClientCodegen
org.openapitools.codegen.languages.NodeJSServerCodegen
org.openapitools.codegen.languages.NodeJSExpressServerCodegen
org.openapitools.codegen.languages.ObjcClientCodegen

View File

@ -0,0 +1,43 @@
# Nim API client for {{{appName}}} (Package: {{{packageName}}})
{{#appDescription}}
{{{appDescription}}}
{{/appDescription}}
## 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: {{{appVersion}}}
- Package version: {{{packageVersion}}}
{{^hideGenerationTimestamp}}
- Build date: {{{generatedDate}}}
{{/hideGenerationTimestamp}}
- Build package: {{{generatorClass}}}
{{#infoUrl}}
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
{{/infoUrl}}
## Installation
Put the package under your project folder and add the following to the nimble file of your project:
```
import {{{packageName}}}
```
## Documentation for API Endpoints
All URIs are relative to *{{{basePath}}}*
Module | Proc | HTTP request | Description
------------ | ------------- | ------------- | -------------
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{{classFilename}}} | {{{operationId}}} | **{{#lambda.uppercase}}{{{httpMethod}}}{{/lambda.uppercase}}** {{{path}}} | {{#summary}}{{{summary}}}{{/summary}}
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
To generate documentation with Nim DocGen, use:
```
nim doc --project --index:on {{{packageName}}}.nim
```

View File

@ -0,0 +1,55 @@
{{>header}}
import httpclient
import json
import logging
import marshal
import options
import strformat
import strutils
import tables
import typetraits
import uri
{{#imports}}import ../models/{{import}}
{{/imports}}
{{#description}}# {{{description}}}{{/description}}
const basepath = "{{{basePath}}}"
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)
{{#operations}}{{#operation}}
proc {{{operationId}}}*(httpClient: HttpClient{{#allParams}}, {{{paramName}}}: {{#isString}}string{{/isString}}{{#isUuid}}string{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}{{/isContainer}}{{/isPrimitiveType}}{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{dataType}}}{{/datatypeWithEnum}}{{/isUuid}}{{/isString}}{{/allParams}}): {{^returnType}}Response{{/returnType}}{{#returnType}}(Option[{{{returnType}}}], Response){{/returnType}}{{#isDeprecated}} {.deprecated.}{{/isDeprecated}} =
## {{{summary}}}{{#hasBodyParam}}
httpClient.headers["Content-Type"] = "application/json"{{/hasBodyParam}}{{#hasFormParams}}{{^isMultipart}}
httpClient.headers["Content-Type"] = "application/x-www-form-urlencoded"{{/isMultipart}}{{#isMultipart}}
httpClient.headers["Content-Type"] = "multipart/form-data"{{/isMultipart}}{{/hasFormParams}}{{#hasHeaderParams}}{{#headerParams}}
httpClient.headers["{{{baseName}}}"] = {{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}{{/headerParams}}{{#description}} ## {{{description}}}{{/description}}{{/hasHeaderParams}}{{#hasQueryParams}}
let query_for_api_call = encodeQuery([{{#queryParams}}
("{{{baseName}}}", ${{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}), # {{{description}}}{{/queryParams}}
]){{/hasQueryParams}}{{#hasFormParams}}{{^isMultipart}}
let query_for_api_call = encodeQuery([{{#formParams}}
("{{{baseName}}}", ${{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}), # {{{description}}}{{/formParams}}
]){{/isMultipart}}{{#isMultipart}}
let query_for_api_call = newMultipartData({
{{#formParams}} "{{{baseName}}}": ${{{paramName}}}{{#isListContainer}}.join(","){{/isListContainer}}, # {{{description}}}
{{/formParams}}
}){{/isMultipart}}{{/hasFormParams}}{{#returnType}}
let response = httpClient.{{{httpMethod}}}(basepath & {{^pathParams}}"{{{path}}}"{{/pathParams}}{{#pathParams}}fmt"{{{path}}}"{{/pathParams}}{{#hasQueryParams}} & "?" & query_for_api_call{{/hasQueryParams}}{{#hasBodyParam}}{{#bodyParams}}, $(%{{{paramName}}}){{/bodyParams}}{{/hasBodyParam}}{{#hasFormParams}}, {{^isMultipart}}$query_for_api_call{{/isMultipart}}{{#isMultipart}}multipart=query_for_api_call{{/isMultipart}}{{/hasFormParams}})
constructResult[{{{returnType}}}](response){{/returnType}}{{^returnType}}
httpClient.{{{httpMethod}}}(basepath & {{^pathParams}}"{{{path}}}"{{/pathParams}}{{#pathParams}}fmt"{{{path}}}"{{/pathParams}}{{#hasQueryParams}} & "?" & query_for_api_call{{/hasQueryParams}}{{#hasBodyParam}}{{#bodyParams}}, $(%{{{paramName}}}){{/bodyParams}}{{/hasBodyParam}}{{#hasFormParams}}, {{^isMultipart}}$query_for_api_call{{/isMultipart}}{{#isMultipart}}multipart=query_for_api_call{{/isMultipart}}{{/hasFormParams}}){{/returnType}}
{{/operation}}{{/operations}}

View File

@ -0,0 +1 @@
const useragent* = "{{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{version}}}/nim"{{/httpUserAgent}}

View File

@ -0,0 +1,8 @@
#{{#appName}}
# {{{appName}}}{{/appName}}
# {{#appDescription}}
# {{{appDescription}}}{{/appDescription}}
# {{#version}}The version of the OpenAPI document: {{{version}}}{{/version}}
# {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}}
# Generated by: https://openapi-generator.tech
#

View File

@ -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}}

View File

@ -0,0 +1,23 @@
{{>header}}
import json
import tables
{{#imports}}import {{import}}
{{/imports}}{{#models}}{{#model}}{{#vars}}{{#isEnum}}
type {{{enumName}}}* {.pure.} = enum{{#allowableValues}}{{#enumVars}}
{{{name}}}{{/enumVars}}{{/allowableValues}}
{{/isEnum}}{{/vars}}
type {{{classname}}}* = object
## {{{description}}}{{#vars}}
{{{name}}}*: {{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#description}} ## {{{description}}}{{/description}}{{/vars}}
{{#vars}}{{#isEnum}}
func `%`*(v: {{{enumName}}}): JsonNode =
let str = case v:{{#allowableValues}}{{#enumVars}}
of {{{enumName}}}.{{{name}}}: {{{value}}}{{/enumVars}}{{/allowableValues}}
JsonNode(kind: JString, str: str)
func `$`*(v: {{{enumName}}}): string =
result = case v:{{#allowableValues}}{{#enumVars}}
of {{{enumName}}}.{{{name}}}: {{{value}}}{{/enumVars}}{{/allowableValues}}
{{/isEnum}}{{/vars}}{{/model}}{{/models}}

View File

@ -0,0 +1,14 @@
{{>header}}
import httpclient
import logging
import options
import {{{packageName}}}
import config
let logger = newConsoleLogger()
addHandler(logger)
let client = newHttpClient()
client.headers["User-Agent"] = config.useragent

View File

@ -0,0 +1,38 @@
package org.openapitools.codegen.nim;
import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.NimClientCodegen;
import org.testng.Assert;
import org.testng.annotations.Test;
public class NimClientCodegenTest {
@Test
public void testInitialConfigValues() throws Exception {
final NimClientCodegen codegen = new NimClientCodegen();
codegen.processOpts();
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE);
Assert.assertEquals(codegen.isHideGenerationTimestamp(), true);
}
@Test
public void testSettersForConfigValues() throws Exception {
final NimClientCodegen codegen = new NimClientCodegen();
codegen.setHideGenerationTimestamp(false);
codegen.processOpts();
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
Assert.assertEquals(codegen.isHideGenerationTimestamp(), false);
}
@Test
public void testAdditionalPropertiesPutForConfigValues() throws Exception {
final NimClientCodegen codegen = new NimClientCodegen();
codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false);
codegen.processOpts();
Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
Assert.assertEquals(codegen.isHideGenerationTimestamp(), false);
}
}

View File

@ -0,0 +1,31 @@
package org.openapitools.codegen.options;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.languages.NimClientCodegen;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
public class NimClientCodegenOptionsProvider implements OptionsProvider {
public static final String PROJECT_NAME_VALUE = "OpenAPI";
@Override
public String getLanguage() {
return "nim";
}
@Override
public Map<String, String> createOptions() {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder
.put(NimClientCodegen.PROJECT_NAME, PROJECT_NAME_VALUE)
.build();
}
@Override
public boolean isServer() {
return false;
}
}

View 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

View File

@ -0,0 +1 @@
4.1.3-SNAPSHOT

View 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
```

View File

@ -0,0 +1 @@
const useragent* = "OpenAPI-Generator/1.0.0/nim"

View 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

View 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)

View 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)

View 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))

View File

@ -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

View 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 Category* = object
## A category for a pet
id*: int64
name*: string

View 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"

View 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"

View 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

View 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

View 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