Compare commits

..

16 Commits

Author SHA1 Message Date
William Cheng
bb51faa1f7 unalias body parameters 2018-12-11 00:23:12 +08:00
Jean-François Côté
0b029088f4 Add Stingray to company using openspi-generator 2018-12-10 09:48:28 -05:00
William Cheng
66cff2b05a fix alias to free form object & map (#1638) 2018-12-10 22:46:41 +08:00
feihongmeilian
489c404783 Add instructions for erlang-server (#1643) 2018-12-10 17:45:19 +08:00
Denis Korenevskiy
a27224e50d [php] bugfix: Array and Map inner schema definition can be missing. (#1586) 2018-12-10 17:43:44 +08:00
William Cheng
98aa5f8db2 add erlang-proper to shippable CI (#1642) 2018-12-10 17:43:00 +08:00
Juan Facorro
87bc9d436f Introduce optional weight function for commands and other improvements (#1618)
* Generator erlang-proper

Used to generate PropEr generators for property-based testing

* Rearrange *_statem.erl functions and remove *_statem.hrl

* Optional weight function

* Optional argument to override generated values

* Export function with arity 1

* Move syntactic sugar to header file

* Only provide body when its allowed

* The weight function should not depend on the state
2018-12-10 11:41:12 +08:00
Jim Schubert
5b91d40a8a Update issue templates (#1636)
This updates issue templates to support auto-labeling, and multiple issue formats.
2018-12-10 11:30:55 +08:00
Akihito Nakano
f19794464b Delete --lang option (#1592)
* Delete --lang option

* Fix -l

* Fix -l flag (windows)

* Add migration guide

* Change to -g

* Remove lang option

* Change to -g
2018-12-09 19:26:51 +09:00
Akihito Nakano
7e3e9dba11 Replace Class.newInstance() with Constructor.newInstance() (#1635) 2018-12-08 22:31:57 +08:00
John Bush
c4f0521e10 Fix escaped regex values in Python client (#1517). (#1539)
* Fix escaped regex values in Python client (#1517).

* Override PythonClientCodegen toRegularExpression() method to correct
  issue with backslashes being escaped. This issue was a result of
  calling escapeText() in the parent DefaultCodegen class.

* Only escape unescaped forward slashes in PythonClientCodegen.

* Override addRegularExpressionDelimiter in PythonClientCodegen.java
  such that only unescaped forward slashes in the pattern get escaped.
* Adds a new test resource .yaml file for specifically testing this
  issue.

* Check for regular expression modifiers in PythonClientCodegen.

* Adds check in postProcessPattern() in PythonClientCodegen.java to
  check if regular expression has modifiers defined. If so, it throws an
  exception as modifiers are not currently supported in the Python
  client.

* PythonClientCodegen warns that regex modifiers are not supported.

* Changes behavior in PythonClientCodegen.java to no longer throw an
  IllegalArgumentException in the case that a pattern contains
  modifiers. A warning message will be logged instead stating that
  modifiers are not currently supported by the codegen class.

* Remove warning for PythonClientCodegen regex modifier support.

* Removes warning message from PythonClientCodegen.java stating that
  regular expression modifiers are not currently supported. Further
  code review and testing revealed that this feature is already
  supported and working.

* Add updated Python client sample files.
2018-12-08 11:32:55 +08:00
Phil Adams
2d39f14882 Fix NPE in ModelUtils.isFreeFormObject() (#1625)
Fixes #1696

An object schema containing no properties that also has additionalProperties
set to an object schema with no properties will cause
ModelUtils.isFreeFormObject to throw an NPE.
This PR adds additional checking to avoid the NPE.
2018-12-07 23:16:58 +08:00
William Cheng
2f4bea6967 remove isNotContainer (#1629) 2018-12-07 23:10:35 +08:00
Akihito Nakano
b84ec60306 Add ASKUL (#1631)
* Add ASKUL

* Update link
2018-12-07 23:05:26 +08:00
Benjamin Gill
2a4fe5bc0e @metaswitch is now using openapi-generator (#1632) 2018-12-07 22:23:53 +09:00
Tomek Cejner
922532da6a [core] Prevent NPE when enpoint did not define responses (#1617) 2018-12-07 11:57:16 +01:00
119 changed files with 1114 additions and 1190 deletions

10
.github/ISSUE_TEMPLATE/announcement.md vendored Normal file
View File

@@ -0,0 +1,10 @@
---
name: Announcement
about: Announcements related to the project
title: "[Announcement] TITLE"
labels: Announcement
assignees: ''
---

54
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,54 @@
---
name: Bug report
about: Create a bug report to help us improve
title: "[BUG] Description"
labels: 'Issue: Bug'
assignees: ''
---
<!--
Please follow the issue template below for bug reports.
Also please indicate in the issue title which language/library is concerned. Eg: [BUG][JAVA] Bug generating foo with bar
-->
##### Description
<!-- describe what is the question, suggestion or issue and why this is a problem for you. -->
##### openapi-generator version
<!-- which version of openapi-generator are you using, is it a regression? -->
##### OpenAPI declaration file content or url
<!-- if it is a bug, a json or yaml that produces it.
If you post the code inline, please wrap it with
```yaml
(here your code)
```
(for YAML code) or
```json
(here your code)
```
(for JSON code), so it becomes more readable. If it is longer than about ten lines,
please create a Gist (https://gist.github.com) or upload it somewhere else and
link it here.
-->
##### Command line used for generation
<!-- including the language, libraries and various options -->
##### Steps to reproduce
<!-- unambiguous set of steps to reproduce the bug.-->
##### Related issues/PRs
<!-- has a similar issue/PR been reported/opened before? Please do a search in https://github.com/openapitools/openapi-generator/issues?utf8=%E2%9C%93&q=is%3Aissue%20 -->
##### Suggest a fix
<!-- if you can't fix the bug yourself, perhaps you can point to what might be
causing the problem (line of code or commit), or simply make a suggestion -->

View File

@@ -0,0 +1,24 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[REQ] Feature Request Description"
labels: 'Enhancement: Feature'
assignees: ''
---
### Is your feature request related to a problem? Please describe.
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
## Describe the solution you'd like
<!-- A clear and concise description of what you want to happen. -->
## Describe alternatives you've considered
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
## Additional context
<!-- Add any other context or screenshots about the feature request here. -->

2
.gitignore vendored
View File

@@ -202,6 +202,8 @@ samples/client/petstore/groovy/build
# erlang
samples/client/petstore/erlang-client/_build/
samples/client/petstore/erlang-client/rebar.lock
samples/client/petstore/erlang-proper/_build/
samples/client/petstore/erlang-proper/rebar.lock
samples/server/petstore/erlang-server/_build/
samples/server/petstore/erlang-server/rebar.lock

View File

@@ -425,7 +425,6 @@ SYNOPSIS
[--import-mappings <import mappings>...]
[--instantiation-types <instantiation types>...]
[--invoker-package <invoker package>]
[(-l <language> | --lang <language>)]
[--language-specific-primitives <language specific primitives>...]
[--library <library>] [--log-to-stderr]
[--model-name-prefix <model name prefix>]
@@ -501,16 +500,19 @@ When code is generated from this project, it shall be considered **AS IS** and o
Here are some companies/projects (alphabetical order) using OpenAPI Generator in production. To add your company/project to the list, please visit [README.md](README.md) and click on the icon to edit the page.
- [Angular.Schule](https://angular.schule/)
- [ASKUL](https://www.askul.co.jp)
- [b<>com](https://b-com.com/en)
- [Bithost GmbH](https://www.bithost.ch)
- [Boxever](https://www.boxever.com/)
- [GMO Pepabo](https://pepabo.com/en/)
- [JustStar](https://www.juststarinfo.com)
- [Klarna](https://www.klarna.com/)
- [Metaswitch](https://www.metaswitch.com/)
- [Myworkout](https://myworkout.com)
- [Raiffeisen Schweiz Genossenschaft](https://www.raiffeisen.ch)
- [RepreZen API Studio](https://www.reprezen.com/swagger-openapi-code-generation-api-first-microservices-enterprise-development)
- [REST United](https://restunited.com)
- [Stingray](http://www.stingray.com)
- [Suva](https://www.suva.ch/)
- [Telstra](https://dev.telstra.com)
- [TUI InfoTec GmbH](http://www.tui-infotec.com/)

View File

@@ -28,11 +28,11 @@ fi
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
# Generate client
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l dart-jaguar -o samples/client/petstore/dart-jaguar/openapi -DhideGenerationTimestamp=true -DpubName=openapi"
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart-jaguar -o samples/client/petstore/dart-jaguar/openapi -DhideGenerationTimestamp=true -DpubName=openapi"
java $JAVA_OPTS -jar $executable $ags
# Generate non-browserClient and put it to the flutter sample app
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l dart-jaguar -o samples/client/petstore/dart-jaguar/flutter_petstore/openapi -DhideGenerationTimestamp=true -DpubName=openapi"
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart-jaguar -o samples/client/petstore/dart-jaguar/flutter_petstore/openapi -DhideGenerationTimestamp=true -DpubName=openapi"
java $JAVA_OPTS -jar $executable $ags
# There is a proposal to allow importing different libraries depending on the environment:

View File

@@ -1,32 +0,0 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
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 -B clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties $@"
ags="generate -t modules/openapi-generator/src/main/resources/dukescript -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dukescript -o samples/client/petstore/dukescript $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -28,7 +28,7 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
# complex module name used for testing
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -l perl -o samples/client/petstore-security-test/perl $@"
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g perl -o samples/client/petstore-security-test/perl $@"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -5,8 +5,8 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l dart-jaguar -o samples\client\petstore\dart-jaguar\swagger -DhideGenerationTimestamp=true -DbrowserClient=false
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -g dart-jaguar -o samples\client\petstore\dart-jaguar\swagger -DhideGenerationTimestamp=true -DbrowserClient=false
java %JAVA_OPTS% -jar %executable% %ags%
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l dart-jaguar -o samples\client\petstore\dart-jaguar\flutter_petstore\swagger -DhideGenerationTimestamp=true
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -g dart-jaguar -o samples\client\petstore\dart-jaguar\flutter_petstore\swagger -DhideGenerationTimestamp=true
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -1,10 +0,0 @@
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 -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g dukescript -o samples\client\petstore\dukescript
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -c bin\typescript-angular-v6-petstore-not-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v6-not-provided-in-root\builds\with-npm -D providedInRoot=false --additional-properties ngVersion=6.0.0
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -c bin\typescript-angular-v6-petstore-not-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v6-not-provided-in-root\builds\with-npm -D providedInRoot=false --additional-properties ngVersion=6.0.0
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-not-provided-in-root\builds\default -D providedInRoot=false --additional-properties ngVersion=6.0.0
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -o samples\client\petstore\typescript-angular-v6-not-provided-in-root\builds\default -D providedInRoot=false --additional-properties ngVersion=6.0.0
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -4,6 +4,6 @@ If Not Exist %executable% (
mvn clean package
)
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -c bin/typescript-angular-v6-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\with-npm --additional-properties ngVersion=6.0.0
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -c bin/typescript-angular-v6-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\with-npm --additional-properties ngVersion=6.0.0
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -4,6 +4,6 @@ If Not Exist %executable% (
mvn clean package
)
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\default --additional-properties ngVersion=6.0.0
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\default --additional-properties ngVersion=6.0.0
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -c bin\typescript-angular-v7-petstore-not-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v7-not-provided-in-root\builds\with-npm -D providedInRoot=false --additional-properties ngVersion=7.0.0
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -c bin\typescript-angular-v7-petstore-not-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v7-not-provided-in-root\builds\with-npm -D providedInRoot=false --additional-properties ngVersion=7.0.0
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v7-not-provided-in-root\builds\default -D providedInRoot=false --additional-properties ngVersion=7.0.0
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -o samples\client\petstore\typescript-angular-v7-not-provided-in-root\builds\default -D providedInRoot=false --additional-properties ngVersion=7.0.0
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -4,6 +4,6 @@ If Not Exist %executable% (
mvn clean package
)
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -c bin/typescript-angular-v7-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v7-provided-in-root\builds\with-npm --additional-properties ngVersion=7.0.0
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -c bin/typescript-angular-v7-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v7-provided-in-root\builds\with-npm --additional-properties ngVersion=7.0.0
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -4,6 +4,6 @@ If Not Exist %executable% (
mvn clean package
)
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v7-provided-in-root\builds\default --additional-properties ngVersion=7.0.0
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -o samples\client\petstore\typescript-angular-v7-provided-in-root\builds\default --additional-properties ngVersion=7.0.0
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -11,6 +11,17 @@ Another approach to find breaking changes is to look at issue and pull requests
* link:https://github.com/OpenAPITools/openapi-generator/labels/Breaking%20change%20%28with%20fallback%29[Breaking change (with fallback)]
* link:https://github.com/OpenAPITools/openapi-generator/labels/Breaking%20change%20%28without%20fallback%29[Breaking change (without fallback)]
=== From 3.x to 4.0.0
Version `4.0.0` is a major release, which contains some breaking changes without fallback.
==== The `-l` (`--lang`) option has been deleted
The option is replaced with `-g` (`--generator-name`).
* `-g` allows the same values as `-l`
* See `langs` command for the list of generator name
=== From 3.1.x to 3.2.0
Version `3.2.0` is a minor version of OpenAPI-Generator, in comparison to `3.1.x` it contains some breaking changes, but with the possibility to fallback to the old behavior.

View File

@@ -37,10 +37,6 @@ public class ConfigHelp implements Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(Generate.class);
@Option(name = {"-l", "--lang"}, title = "language",
description = "language to get config help for")
private String lang;
@Option(name = {"-g", "--generator-name"}, title = "generator name",
description = "generator to get config help for")
private String generatorName;
@@ -57,16 +53,9 @@ public class ConfigHelp implements Runnable {
@Override
public void run() {
// TODO: After 3.0.0 release (maybe for 3.1.0): Fully deprecate lang.
if (isEmpty(generatorName)) {
if (isNotEmpty(lang)) {
LOGGER.warn("The '--lang' and '-l' are deprecated and may reference language names only in the next major release (4.0). Please use --generator-name /-g instead.");
generatorName = lang;
} else {
System.err.println("[error] A generator name (--generator-name / -g) is required.");
System.exit(1);
}
System.err.println("[error] A generator name (--generator-name / -g) is required.");
System.exit(1);
}
try {

View File

@@ -49,10 +49,6 @@ public class Generate implements Runnable {
@Option(name = {"-v", "--verbose"}, description = "verbose mode")
private Boolean verbose;
@Option(name = {"-l", "--lang"}, title = "language",
description = "client language to generate (maybe class name in classpath, required)")
private String lang;
@Option(name = {"-g", "--generator-name"}, title = "generator name",
description = "generator to use (see langs command for list)")
private String generatorName;
@@ -255,12 +251,8 @@ public class Generate implements Runnable {
configurator.setInputSpec(spec);
}
// TODO: After 3.0.0 release (maybe for 3.1.0): Fully deprecate lang.
if (isNotEmpty(generatorName)) {
configurator.setGeneratorName(generatorName);
} else if (isNotEmpty(lang)) {
LOGGER.warn("The '--lang' and '-l' are deprecated and may reference language names only in the next major release (4.0). Please use --generator-name /-g instead.");
configurator.setGeneratorName(lang);
} else {
System.err.println("[error] A generator name (--generator-name / -g) is required.");
System.exit(1);

View File

@@ -45,7 +45,7 @@ public class CodegenConfigLoader {
// else try to load directly
try {
return (CodegenConfig) Class.forName(name).newInstance();
return (CodegenConfig) Class.forName(name).getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new GeneratorNotFoundException("Can't load config class with name '".concat(name) + "'\nAvailable:\n" + availableConfigs.toString(), e);
}

View File

@@ -17,6 +17,7 @@
package org.openapitools.codegen;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
@@ -35,7 +36,7 @@ public final class CodegenModelFactory {
throw new IllegalArgumentException(implementation.getSimpleName() + " doesn't extend " + type.getDefaultImplementation().getSimpleName());
}
try {
implementation.newInstance();
implementation.getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
@@ -46,8 +47,8 @@ public final class CodegenModelFactory {
public static <T> T newInstance(CodegenModelType type) {
Class<?> classType = typeMapping.get(type);
try {
return (T) (classType != null ? classType : type.getDefaultImplementation()).newInstance();
} catch (IllegalAccessException | InstantiationException e) {
return (T) (classType != null ? classType : type.getDefaultImplementation()).getDeclaredConstructor().newInstance();
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}

View File

@@ -53,7 +53,7 @@ public class CodegenProperty implements Cloneable {
public boolean exclusiveMaximum;
public boolean hasMore, required, secondaryParam;
public boolean hasMoreNonReadOnly; // for model constructor, true if next property is not readonly
public boolean isPrimitiveType, isModel, isContainer, isNotContainer;
public boolean isPrimitiveType, isModel, isContainer;
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isFile,
isBoolean, isDate, isDateTime, isUuid, isEmail, isFreeFormObject;
public boolean isListContainer, isMapContainer;
@@ -434,7 +434,6 @@ public class CodegenProperty implements Cloneable {
result = prime * result + ((hasMoreNonReadOnly ? 13 : 31));
result = prime * result + ((isContainer ? 13 : 31));
result = prime * result + (isEnum ? 1231 : 1237);
result = prime * result + ((isNotContainer ? 13 : 31));
result = prime * result + ((isPrimitiveType ? 13 : 31));
result = prime * result + ((isModel ? 13 : 31));
result = prime * result + ((isReadOnly ? 13 : 31));
@@ -586,9 +585,6 @@ public class CodegenProperty implements Cloneable {
if (this.isContainer != other.isContainer) {
return false;
}
if (this.isNotContainer != other.isNotContainer) {
return false;
}
if (this.isEnum != other.isEnum) {
return false;
}
@@ -772,7 +768,6 @@ public class CodegenProperty implements Cloneable {
", isPrimitiveType=" + isPrimitiveType +
", isModel=" + isModel +
", isContainer=" + isContainer +
", isNotContainer=" + isNotContainer +
", isString=" + isString +
", isNumeric=" + isNumeric +
", isInteger=" + isInteger +

View File

@@ -2264,7 +2264,7 @@ public class DefaultCodegen implements CodegenConfig {
}
protected void setNonArrayMapProperty(CodegenProperty property, String type) {
property.isNotContainer = true;
property.isContainer = false;
if (languageSpecificPrimitives().contains(type)) {
property.isPrimitiveType = true;
} else {
@@ -4304,7 +4304,7 @@ public class DefaultCodegen implements CodegenConfig {
body, Map<String, Schema> schemas, Set<String> imports) {
List<CodegenParameter> parameters = new ArrayList<CodegenParameter>();
LOGGER.debug("debugging fromRequestBodyToFormParameters= " + body);
Schema schema = ModelUtils.getSchemaFromRequestBody(body);
Schema schema = ModelUtils.unaliasSchema(globalSchemas, ModelUtils.getSchemaFromRequestBody(body));
if (StringUtils.isNotBlank(schema.get$ref())) {
schema = schemas.get(ModelUtils.getSimpleRef(schema.get$ref()));
}
@@ -4319,7 +4319,7 @@ public class DefaultCodegen implements CodegenConfig {
// array of schema
if (ModelUtils.isArraySchema(s)) {
final ArraySchema arraySchema = (ArraySchema) s;
Schema inner = arraySchema.getItems();
Schema inner = ModelUtils.unaliasSchema(globalSchemas, (arraySchema.getItems()));
if (inner == null) {
LOGGER.warn("warning! No inner type supplied for array parameter \"" + s.getName() + "\", using String");
inner = new StringSchema().description("//TODO automatically added by openapi-generator due to missing iner type definition in the spec");
@@ -4471,14 +4471,14 @@ public class DefaultCodegen implements CodegenConfig {
String name = null;
LOGGER.debug("Request body = " + body);
Schema schema = ModelUtils.getSchemaFromRequestBody(body);
Schema schema = ModelUtils.unaliasSchema(globalSchemas, ModelUtils.getSchemaFromRequestBody(body));
if (StringUtils.isNotBlank(schema.get$ref())) {
name = ModelUtils.getSimpleRef(schema.get$ref());
schema = schemas.get(name);
}
if (ModelUtils.isMapSchema(schema)) {
Schema inner = ModelUtils.getAdditionalProperties(schema);
Schema inner = ModelUtils.unaliasSchema(globalSchemas, ModelUtils.getAdditionalProperties(schema));
if (inner == null) {
inner = new StringSchema().description("//TODO automatically added by openapi-generator");
schema.setAdditionalProperties(inner);
@@ -4506,7 +4506,7 @@ public class DefaultCodegen implements CodegenConfig {
setParameterNullable(codegenParameter, codegenProperty);
} else if (ModelUtils.isArraySchema(schema)) {
final ArraySchema arraySchema = (ArraySchema) schema;
Schema inner = arraySchema.getItems();
Schema inner = ModelUtils.unaliasSchema(globalSchemas, arraySchema.getItems());
if (inner == null) {
inner = new StringSchema().description("//TODO automatically added by openapi-generator");
arraySchema.setItems(inner);

View File

@@ -43,15 +43,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import java.util.*;
import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.StringUtils.escape;
@@ -1036,6 +1028,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
continue;
}
for (Operation operation : path.readOperations()) {
LOGGER.info("Processing operation " + operation.getOperationId());
if (hasBodyParameter(openAPI, operation) || hasFormParameter(openAPI, operation)) {
String defaultContentType = hasFormParameter(openAPI, operation) ? "application/x-www-form-urlencoded" : "application/json";
List<String> consumes = new ArrayList<String>(getConsumesInfo(openAPI, operation));
@@ -1052,8 +1045,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
protected static String getAccept(OpenAPI openAPI, Operation operation) {
String accepts = null;
String defaultContentType = "application/json";
ArrayList<String> produces = new ArrayList<String>(getProducesInfo(openAPI, operation));
if (produces != null && !produces.isEmpty()) {
Set<String> producesInfo = getProducesInfo(openAPI, operation);
if (producesInfo != null && !producesInfo.isEmpty()) {
ArrayList<String> produces = new ArrayList<String>(producesInfo);
StringBuilder sb = new StringBuilder();
for (String produce : produces) {
if (defaultContentType.equalsIgnoreCase(produce)) {

View File

@@ -18,6 +18,7 @@ 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.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption;
@@ -352,9 +353,17 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
Schema inner = ap.getItems();
if (inner == null) {
LOGGER.warn(ap.getName() + "(array property) does not have a proper inner type defined.Default to string");
inner = new StringSchema().description("TODO default missing array inner type to string");
}
return getTypeDeclaration(inner) + "[]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = ModelUtils.getAdditionalProperties(p);
if (inner == null) {
LOGGER.warn(p.getName() + "(map property) does not have a proper inner type defined. Default to string");
inner = new StringSchema().description("TODO default missing map inner type to string");
}
return getSchemaType(p) + "[string," + getTypeDeclaration(inner) + "]";
} else if (StringUtils.isNotBlank(p.get$ref())) { // model
String type = super.getTypeDeclaration(p);

View File

@@ -1,104 +0,0 @@
/*
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.*;
import java.io.File;
public class DukeScriptClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String sourceFolder = "src";
protected String apiVersion = "1.0.0";
public CodegenType getTag() {
return CodegenType.CLIENT;
}
public String getName() {
return "dukescript";
}
public String getHelp() {
return "Generates a DukeScript @Model client library (beta).";
}
public DukeScriptClientCodegen() {
super();
outputFolder = "generated-code/dukescript";
modelTemplateFiles.put(
"model.mustache",
"VMD.java");
apiTemplateFiles.put(
"api.mustache",
"Connector.java");
templateDir = "dukescript";
apiPackage = "org.openapitools.client.api";
modelPackage = "org.openapitools.client.model";
additionalProperties.put("apiVersion", apiVersion);
typeMapping.put("string", "String");
typeMapping.put("integer", "int");
typeMapping.put("long", "long");
typeMapping.put("short", "short");
typeMapping.put("short", "short");
typeMapping.put("Boolean", "boolean");
typeMapping.put("boolean", "boolean");
typeMapping.put("Date", "long");
typeMapping.put("DateTime", "long");
}
@Override
public String escapeReservedWord(String name) {
return "_" + name; // add an underscore to the name
}
public String modelFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
}
@Override
public String apiFileFolder() {
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
}
@Override
public String getSchemaType(Schema p) {
String openAPIType = super.getSchemaType(p);
String type = null;
if (typeMapping.containsKey(openAPIType)) {
type = typeMapping.get(openAPIType);
if (languageSpecificPrimitives.contains(type)) {
return type;
}
} else {
type = openAPIType;
}
return type;
}
@Override
public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "*_/").replace("/*", "/_*");
}
@Override
public String escapeQuotationMark(String input) {
// remove " to avoid code injection
return input.replace("\"", "");
}
}

View File

@@ -381,6 +381,19 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
return toApiName(name);
}
@Override
public String addRegularExpressionDelimiter(String pattern) {
if (StringUtils.isEmpty(pattern)) {
return pattern;
}
if (!pattern.matches("^/.*")) {
// Perform a negative lookbehind on each `/` to ensure that it is escaped.
return "/" + pattern.replaceAll("(?<!\\\\)\\/", "\\\\/") + "/";
}
return pattern;
}
@Override
public String apiFileFolder() {
@@ -635,6 +648,11 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
return null;
}
@Override
public String toRegularExpression(String pattern) {
return addRegularExpressionDelimiter(pattern);
}
@Override
public void setParameterExampleValue(CodegenParameter p) {
String example;

View File

@@ -547,20 +547,17 @@ public class ModelUtils {
if ("object".equals(schema.getType())) {
// no properties
if ((schema.getProperties() == null || schema.getProperties().isEmpty())) {
if (schema.getAdditionalProperties() == null) {
Schema addlProps = getAdditionalProperties(schema);
// additionalProperties not defined
if (addlProps == null) {
return true;
} else {
// additionalProperties set to true
if (schema.getAdditionalProperties() instanceof Boolean
&& (Boolean) schema.getAdditionalProperties()) {
return true;
}
// additionalProperties is set to {}
if (schema.getAdditionalProperties() instanceof Schema && schema.getAdditionalProperties() != null
&& schema.getAdditionalProperties() instanceof ObjectSchema
&& ((Schema) schema.getAdditionalProperties()).getProperties().isEmpty()) {
return true;
if (addlProps instanceof ObjectSchema) {
ObjectSchema objSchema = (ObjectSchema) addlProps;
// additionalProperties defined as {}
if (objSchema.getProperties() == null || objSchema.getProperties().isEmpty()) {
return true;
}
}
}
}
@@ -771,21 +768,23 @@ public class ModelUtils {
} else if (ref.getEnum() != null && !ref.getEnum().isEmpty()) {
// top-level enum class
return schema;
} else if (isFreeFormObject(ref)) {
return schema;
} else if (isArraySchema(ref)) {
return unaliasSchema(allSchemas, allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
} else if (isComposedSchema(ref)) {
return schema;
} else if (isMapSchema(ref)) {
if (ref.getProperties() != null && !ref.getProperties().isEmpty()) // has properties
if (ref.getProperties() != null && !ref.getProperties().isEmpty()) // has at least one property
return schema; // treat it as model
else {
// treat it as a typical map
return unaliasSchema(allSchemas, allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
}
} else if (isObjectSchema(ref)) { // model
return schema;
if (ref.getProperties() != null && !ref.getProperties().isEmpty()) { // has at least one property
return schema;
} else { // free form object (type: object)
return unaliasSchema(allSchemas, allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
}
} else {
return unaliasSchema(allSchemas, allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
}

View File

@@ -8,9 +8,9 @@
{{/isEnum}}
{{/isPrimitiveType}}
{{/isContainer}}
{{#isNotContainer}}
{{^isContainer}}
{{^isPrimitiveType}}
@Valid
{{/isPrimitiveType}}
{{/isNotContainer}}
{{/isContainer}}
{{>beanValidationCore}}

View File

@@ -1,6 +1,6 @@
{{#required}}
@NotNull
{{/required}}{{#isContainer}}{{^isPrimitiveType}}{{^isEnum}}
@Valid{{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{#isNotContainer}}{{^isPrimitiveType}}
@Valid{{/isPrimitiveType}}{{/isNotContainer}}
@Valid{{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}
@Valid{{/isPrimitiveType}}{{/isContainer}}
{{>beanValidationCore}}

View File

@@ -20,7 +20,6 @@ org.openapitools.codegen.languages.CSharpDotNet2ClientCodegen
org.openapitools.codegen.languages.CSharpNancyFXServerCodegen
org.openapitools.codegen.languages.DartClientCodegen
org.openapitools.codegen.languages.DartJaguarClientCodegen
org.openapitools.codegen.languages.DukeScriptClientCodegen
org.openapitools.codegen.languages.EiffelClientCodegen
org.openapitools.codegen.languages.ElixirClientCodegen
org.openapitools.codegen.languages.ElmClientCodegen

View File

@@ -83,17 +83,17 @@ namespace {{packageName}}.Models
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return {{#vars}}{{#isNotContainer}}
return {{#vars}}{{^isContainer}}
(
{{name}} == other.{{name}} ||
{{name}} != null &&
{{name}}.Equals(other.{{name}})
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{^isNotContainer}}
){{#hasMore}} && {{/hasMore}}{{/isContainer}}{{#isContainer}}
(
{{name}} == other.{{name}} ||
{{name}} != null &&
{{name}}.SequenceEqual(other.{{name}})
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}{{^vars}}false{{/vars}};
){{#hasMore}} && {{/hasMore}}{{/isContainer}}{{/vars}}{{^vars}}false{{/vars}};
}
/// <summary>

View File

@@ -83,17 +83,17 @@ namespace {{packageName}}.Models
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return {{#vars}}{{#isNotContainer}}
return {{#vars}}{{^isContainer}}
(
{{name}} == other.{{name}} ||
{{name}} != null &&
{{name}}.Equals(other.{{name}})
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{^isNotContainer}}
){{#hasMore}} && {{/hasMore}}{{/isContainer}}{{#isContainer}}
(
{{name}} == other.{{name}} ||
{{name}} != null &&
{{name}}.SequenceEqual(other.{{name}})
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}{{^vars}}false{{/vars}};
){{#hasMore}} && {{/hasMore}}{{/isContainer}}{{/vars}}{{^vars}}false{{/vars}};
}
/// <summary>

View File

@@ -43,10 +43,10 @@ public:
/// <summary>
/// {{description}}
/// </summary>
{{^isNotContainer}}{{{dataType}}}& {{getter}}();
{{/isNotContainer}}{{#isNotContainer}}{{{dataType}}} {{getter}}() const;
{{#isContainer}}{{{dataType}}}& {{getter}}();
{{/isContainer}}{{^isContainer}}{{{dataType}}} {{getter}}() const;
void {{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPrimitiveType}} value);
{{/isNotContainer}}{{^required}}bool {{nameInCamelCase}}IsSet() const;
{{/isContainer}}{{^required}}bool {{nameInCamelCase}}IsSet() const;
void unset{{name}}();
{{/required}}
{{/vars}}

View File

@@ -9,10 +9,10 @@ namespace {{this}} {
{{classname}}::{{classname}}()
{
{{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}m_{{name}} = {{{defaultValue}}};
{{#vars}}{{^isContainer}}{{#isPrimitiveType}}m_{{name}} = {{{defaultValue}}};
{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isString}}m_{{name}} = {{{defaultValue}}};
{{/isString}}{{#isDateTime}}m_{{name}} = {{{defaultValue}}};
{{/isDateTime}}{{/isPrimitiveType}}{{/isNotContainer}}{{^required}}m_{{name}}IsSet = false;
{{/isDateTime}}{{/isPrimitiveType}}{{/isContainer}}{{^required}}m_{{name}}IsSet = false;
{{/required}}{{/vars}}
}
@@ -145,11 +145,11 @@ void {{classname}}::fromJson(const nlohmann::json& val)
}
{{#vars}}{{^isNotContainer}}{{{dataType}}}& {{classname}}::{{getter}}()
{{#vars}}{{#isContainer}}{{{dataType}}}& {{classname}}::{{getter}}()
{
return m_{{name}};
}
{{/isNotContainer}}{{#isNotContainer}}{{{dataType}}} {{classname}}::{{getter}}() const
{{/isContainer}}{{^isContainer}}{{{dataType}}} {{classname}}::{{getter}}() const
{
return m_{{name}};
}
@@ -158,7 +158,7 @@ void {{classname}}::{{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPri
m_{{name}} = value;
{{^required}}m_{{name}}IsSet = true;{{/required}}
}
{{/isNotContainer}}
{{/isContainer}}
{{^required}}bool {{classname}}::{{nameInCamelCase}}IsSet() const
{
return m_{{name}}IsSet;

View File

@@ -49,9 +49,9 @@ public:
/// <summary>
/// {{description}}
/// </summary>
{{^isNotContainer}}{{{dataType}}}& {{getter}}();
{{/isNotContainer}}{{#isNotContainer}}{{{dataType}}} {{getter}}() const;
{{/isNotContainer}}{{^required}}bool {{nameInCamelCase}}IsSet() const;
{{#isContainer}}{{{dataType}}}& {{getter}}();
{{/isContainer}}{{^isContainer}}{{{dataType}}} {{getter}}() const;
{{/isContainer}}{{^required}}bool {{nameInCamelCase}}IsSet() const;
void unset{{name}}();
{{/required}}

View File

@@ -11,7 +11,7 @@ namespace {{this}} {
{
{{#vars}}
{{^isInherited}}
{{#isNotContainer}}
{{^isContainer}}
{{#isPrimitiveType}}
m_{{name}} = {{{defaultValue}}};
{{/isPrimitiveType}}
@@ -23,7 +23,7 @@ namespace {{this}} {
m_{{name}} = {{{defaultValue}}};
{{/isDateTime}}
{{/isPrimitiveType}}
{{/isNotContainer}}
{{/isContainer}}
{{^required}}
m_{{name}}IsSet = false;
{{/required}}
@@ -591,18 +591,18 @@ void {{classname}}::fromMultiPart(std::shared_ptr<MultipartFormData> multipart,
{{#vars}}
{{^isInherited}}
{{^isNotContainer}}
{{#isContainer}}
{{{dataType}}}& {{classname}}::{{getter}}()
{
return m_{{name}};
}
{{/isNotContainer}}
{{#isNotContainer}}
{{/isContainer}}
{{^isContainer}}
{{{dataType}}} {{classname}}::{{getter}}() const
{
return m_{{name}};
}
{{/isNotContainer}}
{{/isContainer}}
{{#isPrimitiveType}}
void {{classname}}::{{setter}}({{{dataType}}} value)

View File

@@ -18,10 +18,10 @@ namespace {{this}} {
{{classname}}::{{classname}}()
{
{{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}m_{{name}} = {{{defaultValue}}};
{{#vars}}{{^isContainer}}{{#isPrimitiveType}}m_{{name}} = {{{defaultValue}}};
{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isString}}m_{{name}} = {{{defaultValue}}};
{{/isString}}{{#isDateTime}}m_{{name}} = {{{defaultValue}}};
{{/isDateTime}}{{/isPrimitiveType}}{{/isNotContainer}}{{/vars}}
{{/isDateTime}}{{/isPrimitiveType}}{{/isContainer}}{{/vars}}
}
{{classname}}::~{{classname}}()
@@ -33,7 +33,7 @@ std::string {{classname}}::toJsonString()
std::stringstream ss;
ptree pt;
{{#vars}}
{{#isNotContainer}}
{{^isContainer}}
{{#isPrimitiveType}}
pt.put("{{name}}", m_{{name}});
{{/isPrimitiveType}}
@@ -45,7 +45,7 @@ std::string {{classname}}::toJsonString()
pt.put("{{name}}", m_{{name}});
{{/isDateTime}}
{{/isPrimitiveType}}
{{/isNotContainer}}
{{/isContainer}}
{{/vars}}
write_json(ss, pt, false);
return ss.str();
@@ -57,7 +57,7 @@ void {{classname}}::fromJsonString(std::string const& jsonString)
ptree pt;
read_json(ss,pt);
{{#vars}}
{{#isNotContainer}}
{{^isContainer}}
{{#isPrimitiveType}}
m_{{name}} = pt.get("{{name}}", {{{defaultValue}}});
{{/isPrimitiveType}}
@@ -69,7 +69,7 @@ void {{classname}}::fromJsonString(std::string const& jsonString)
m_{{name}} = pt.get("{{name}}", {{{defaultValue}}});
{{/isDateTime}}
{{/isPrimitiveType}}
{{/isNotContainer}}
{{/isContainer}}
{{/vars}}
}

View File

@@ -27,9 +27,9 @@ void
{{#isContainer}}
//{{defaultValue}}{{baseType}}> {{name}};
{{/isContainer}}
{{#isNotContainer}}
{{^isContainer}}
//{{name}} = {{defaultValue}};
{{/isNotContainer}}
{{/isContainer}}
{{/vars}}
}

View File

@@ -158,17 +158,17 @@ this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
if (input == null)
return false;
return {{#vars}}{{#parent}}base.Equals(input) && {{/parent}}{{#isNotContainer}}
return {{#vars}}{{#parent}}base.Equals(input) && {{/parent}}{{^isContainer}}
(
this.{{name}} == input.{{name}} ||
(this.{{name}} != null &&
this.{{name}}.Equals(input.{{name}}))
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{^isNotContainer}}
){{#hasMore}} && {{/hasMore}}{{/isContainer}}{{#isContainer}}
(
this.{{name}} == input.{{name}} ||
this.{{name}} != null &&
this.{{name}}.SequenceEqual(input.{{name}})
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}};
){{#hasMore}} && {{/hasMore}}{{/isContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}};
}
/// <summary>

View File

@@ -158,17 +158,17 @@ this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
if (input == null)
return false;
return {{#vars}}{{#parent}}base.Equals(input) && {{/parent}}{{#isNotContainer}}
return {{#vars}}{{#parent}}base.Equals(input) && {{/parent}}{{^isContainer}}
(
this.{{name}} == input.{{name}} ||
(this.{{name}} != null &&
this.{{name}}.Equals(input.{{name}}))
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{^isNotContainer}}
){{#hasMore}} && {{/hasMore}}{{/isContainer}}{{#isContainer}}
(
this.{{name}} == input.{{name}} ||
this.{{name}} != null &&
this.{{name}}.SequenceEqual(input.{{name}})
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}};
){{#hasMore}} && {{/hasMore}}{{/isContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}};
}
/// <summary>

View File

@@ -1,26 +0,0 @@
package {{package}};
import java.util.List;
import java.util.function.Consumer;
import {{modelPackage}}.*;
import net.java.html.json.Model;
import net.java.html.json.ModelOperation;
import net.java.html.json.OnReceive;
import net.java.html.json.Property;
{{#operations}}
@ModelOperation
@Model(className = "{{classname}}", targetId = "", properties = {
@Property(name="url", type=String.class )
})
public class {{classname}}Connector {
{{#operation}} // {{summary}}
@OnReceive(method = "{{httpMethod}}", {{#allParams}}{{#isBodyParam}}data={{dataType}}.class, {{/isBodyParam}}{{/allParams}} url = "{url}{{path}}")
public static void {{operationId}}( {{classname}} model{{#bodyParam}}{{#isBodyParam}}, {{dataType}} {{paramName}}{{/isBodyParam}}{{/bodyParam}}{{#hasProduces}},{{#isListContainer}}List<{{returnBaseType}}> result{{/isListContainer}}{{^isListContainer}} {{baseName}} result{{/isListContainer}},Consumer<{{#isListContainer}}List<{{returnBaseType}}>{{/isListContainer}}{{^isListContainer}} {{baseName}}{{/isListContainer}}> onSuccess{{/hasProduces}}, Consumer<Throwable> onError) {
}
{{/operation}}
{{/operations}}
}

View File

@@ -1,24 +0,0 @@
package {{package}};
{{#models}}
{{#model}}
import java.util.List;
import net.java.html.json.ComputedProperty;
import net.java.html.json.Function;
import net.java.html.json.Model;
import net.java.html.json.ModelOperation;
import net.java.html.json.OnPropertyChange;
import net.java.html.json.OnReceive;
import net.java.html.json.Property;
@Model(className = "{{classname}}", targetId = "", properties = {
{{#vars}}
{{^-first}}, {{/-first}}{{^isListContainer}}@Property(name = "{{baseName}}", type = {{baseType}}.class){{/isListContainer}}{{#isListContainer}}@Property(name = "{{baseName}}", type = {{#items}}{{datatype}}{{/items}}.class, array=true){{/isListContainer}}
{{/vars}}
}
)
public class {{classname}}VMD{
}
{{/model}}
{{/models}}

View File

@@ -18,13 +18,20 @@
Method = {{httpMethod}},
Host = application:get_env({{packageName}}, host, "http://localhost:8080"),
Path = ["{{{replacedPathName}}}"],
{{#isBodyAllowed}}
Body = {{^formParams.isEmpty}}{form, [{{#formParams}}{{#required}}{{^-first}}, {{/-first}}{<<"{{{baseName}}}">>, {{paramName}}{{/required}}{{/formParams}}]++{{packageName}}_utils:optional_params([{{#formParams}}{{^required}}{{^-first}}, {{/-first}}'{{{baseName}}}'{{/required}}{{/formParams}}], _OptionalParams)}{{/formParams.isEmpty}}{{#formParams.isEmpty}}{{#bodyParams.isEmpty}}[]{{/bodyParams.isEmpty}}{{^bodyParams.isEmpty}}{{#bodyParams}}{{paramName}}{{/bodyParams}}{{/bodyParams.isEmpty}}{{/formParams.isEmpty}},
ContentType = {{#hasConsumes}}hd([{{#consumes}}{{^-first}}, {{/-first}}"{{mediaType}}"{{/consumes}}]){{/hasConsumes}}{{^hasConsumes}}<<"text/plain">>{{/hasConsumes}},
ContentType = {{#hasConsumes}}hd([{{#consumes}}{{^-first}}, {{/-first}}"{{mediaType}}"{{/consumes}}]){{/hasConsumes}}{{^hasConsumes}}"text/plain"{{/hasConsumes}},
{{/isBodyAllowed}}
{{^queryParams.isEmpty}}
QueryString = [{{#queryParams}}{{^-first}}, {{/-first}}<<"{{{baseName}}}=">>, {{{paramName}}}, <<"&">>{{/queryParams}}],
{{/queryParams.isEmpty}}
{{#isBodyAllowed}}
{{packageName}}_utils:request(Method, [Host, ?BASE_URL, Path{{^queryParams.isEmpty}}, <<"?">>, QueryString{{/queryParams.isEmpty}}], jsx:encode(Body), ContentType).
{{/isBodyAllowed}}
{{^isBodyAllowed}}
{{packageName}}_utils:request(Method, [Host, ?BASE_URL, Path{{^queryParams.isEmpty}}, <<"?">>, QueryString{{/queryParams.isEmpty}}]).
{{/isBodyAllowed}}
{{/operation}}
{{/operations}}

View File

@@ -5,7 +5,9 @@
-include("{{packageName}}.hrl").
-export([{{classname}}/0]).
{{^isEnum}}{{^isArrayModel}}
-export([{{classname}}/1]).
{{/isArrayModel}}{{/isEnum}}
-export_type([{{classname}}/0]).
-type {{classname}}() ::{{#isEnum}}
@@ -15,12 +17,23 @@
| {{/-first}}{'{{name}}', {{dataType}} }{{/vars}}
].{{/isArrayModel}}{{/isEnum}}
{{classname}}() ->{{#isEnum}}
{{#isEnum}}
{{classname}}() ->
elements([{{#allowableValues.values}}{{^-first}}, {{/-first}}<<"{{.}}">>{{/allowableValues.values}}]).
{{/isEnum}}{{#isArrayModel}}
list({{arrayModelType}}{{#minItems}}, {{minItems}}{{#maxItems}}, {{maxItems}}{{/maxItems}}{{/minItems}}).{{/isArrayModel}}{{^isEnum}}{{^isArrayModel}}
[ {{#vars}}{{^-first}}
, {{/-first}}{'{{baseName}}', {{#isString}}{{#isEnum}}elements([{{#allowableValues.values}}{{^-first}}, {{/-first}}<<"{{.}}">>{{/allowableValues.values}}]){{/isEnum}}{{^isEnum}}binary({{#minLength}}{{minLength}}{{#maxLength}}, {{maxLength}}{{/maxLength}}{{/minLength}}){{/isEnum}}{{/isString}}{{^isString}}{{baseType}}{{/isString}} }{{/vars}}
].{{/isArrayModel}}{{/isEnum}}
{{/isEnum}}
{{#isArrayModel}}
{{classname}}() ->
list({{arrayModelType}}{{#minItems}}, {{minItems}}{{#maxItems}}, {{maxItems}}{{/maxItems}}{{/minItems}}).
{{/isArrayModel}}
{{^isEnum}}{{^isArrayModel}}
{{classname}}() ->
{{classname}}([]).
{{classname}}(Fields) ->
Default = [ {{#vars}}{{^-first}}
, {{/-first}}{'{{baseName}}', {{#isString}}{{#isEnum}}elements([{{#allowableValues.values}}{{^-first}}, {{/-first}}<<"{{.}}">>{{/allowableValues.values}}]){{/isEnum}}{{^isEnum}}binary({{#minLength}}{{minLength}}{{#maxLength}}, {{maxLength}}{{/maxLength}}{{/minLength}}){{/isEnum}}{{/isString}}{{^isString}}{{baseType}}{{/isString}} }{{/vars}}
],
lists:ukeymerge(1, lists:sort(Fields), lists:sort(Default)).
{{/isArrayModel}}{{/isEnum}}
{{/model}}
{{/models}}

View File

@@ -4,4 +4,4 @@
{shell, [{apps, [{{packageName}}]}]}.
{plugins, [rebar3_proper]}.
{plugins, [rebar3_proper]}.

View File

@@ -1,25 +1,49 @@
%%==============================================================================
%% Setup
%% Syntactic sugar
%%==============================================================================
setup() -> ok.
command(State) ->
Funs0 = [ {F, list_to_atom(atom_to_list(F) ++ "_args")}
|| {F, _} <- ?MODULE:module_info(exports)
],
%%==============================================================================
%% Cleanup
%%==============================================================================
Funs1 = [ X || {_, FArgs} = X <- Funs0,
erlang:function_exported(?MODULE, FArgs, 1)
],
cleanup() -> ok.
WeightFun = case erlang:function_exported(?MODULE, weight, 1) of
true -> fun ?MODULE:weight/1;
false -> fun(_) -> 1 end
end,
%%==============================================================================
%% Initial State
%%==============================================================================
proper_types:frequency([ { WeightFun(F)
, {call, ?MODULE, F, ?MODULE:FArgs(State)}
}
|| {F, FArgs} <- Funs1
]).
initial_state() -> #{}.
precondition(S, {call, M, F, Args}) ->
Pre = list_to_atom(atom_to_list(F) ++ "_pre"),
case erlang:function_exported(M, Pre, 1) of
true -> M:Pre(S);
false -> true
end
andalso
case erlang:function_exported(M, Pre, 2) of
true -> M:Pre(S, Args);
false -> true
end.
%%==============================================================================
%% State transitions callbacks
%%
%% operation_pre(State) -> true.
%% operation_next(State, Result, Args) -> State.
%% operation_post(State, Args, Result) -> true.
%%==============================================================================
next_state(S, Res, {call, M, F, Args}) ->
Next = list_to_atom(atom_to_list(F) ++ "_next"),
case erlang:function_exported(M, Next, 3) of
true -> M:Next(S, Res, Args);
false -> S
end.
postcondition(S, {call, M, F, Args}, Res) ->
Post = list_to_atom(atom_to_list(F) ++ "_post"),
case erlang:function_exported(M, Post, 3) of
true -> M:Post(S, Args, Res);
false -> true
end.

View File

@@ -9,66 +9,7 @@
-compile(export_all).
-compile(nowarn_export_all).
%%==============================================================================
%% PropEr callbacks
%%==============================================================================
command(State) ->
Funs0 = [ {F, list_to_atom(atom_to_list(F) ++ "_args")}
|| {F, _} <- ?MODULE:module_info(exports)
],
Funs1 = [ X || {_, FArgs} = X <- Funs0,
erlang:function_exported(?MODULE, FArgs, 1)
],
proper_types:oneof([ {call, ?MODULE, F, ?MODULE:FArgs(State)}
|| {F, FArgs} <- Funs1
]).
precondition(S, {call, M, F, Args}) ->
Pre = list_to_atom(atom_to_list(F) ++ "_pre"),
case erlang:function_exported(M, Pre, 1) of
true -> M:Pre(S);
false -> true
end
andalso
case erlang:function_exported(M, Pre, 2) of
true -> M:Pre(S, Args);
false -> true
end.
next_state(S, Res, {call, M, F, Args}) ->
Next = list_to_atom(atom_to_list(F) ++ "_next"),
case erlang:function_exported(M, Next, 3) of
true -> M:Next(S, Res, Args);
false -> S
end.
postcondition(S, {call, M, F, Args}, Res) ->
Post = list_to_atom(atom_to_list(F) ++ "_post"),
case erlang:function_exported(M, Post, 3) of
true -> M:Post(S, Args, Res);
false -> true
end.
{{#operations}}
{{#operation}}
%%==============================================================================
%% {{operationId}}
%%==============================================================================
{{operationId}}({{#allParams}}{{#required}}{{^-first}}, {{/-first}}{{paramName}}{{/required}}{{/allParams}}) ->
{{classname}}_api:{{operationId}}({{#allParams}}{{#required}}{{^-first}}, {{/-first}}{{paramName}}{{/required}}{{/allParams}}).
{{operationId}}_args(S) ->
Args = [{{#allParams}}{{#required}}{{^-first}}, {{/-first}}{{dataType}}{{/required}}{{/allParams}}],
case erlang:function_exported(?MODULE, '{{operationId}}_args_custom', 2) of
true -> ?MODULE:{{operationId}}_args_custom(S, Args);
false -> Args
end.
{{/operation}}
{{/operations}}
-include("{{packageName}}_statem.hrl").
%%==============================================================================
%% The statem's property
@@ -99,7 +40,34 @@ prop_main() ->
).
%%==============================================================================
%% Include file with setup, cleanup, initial_state
%% and state transitions callbacks
%% Setup
%%==============================================================================
-include("{{classname}}_statem.hrl").
setup() -> ok.
%%==============================================================================
%% Cleanup
%%==============================================================================
cleanup() -> ok.
%%==============================================================================
%% Initial State
%%==============================================================================
initial_state() -> #{}.
{{#operations}}
{{#operation}}
%%==============================================================================
%% {{operationId}}
%%==============================================================================
{{operationId}}({{#allParams}}{{#required}}{{^-first}}, {{/-first}}{{paramName}}{{/required}}{{/allParams}}) ->
{{classname}}_api:{{operationId}}({{#allParams}}{{#required}}{{^-first}}, {{/-first}}{{paramName}}{{/required}}{{/allParams}}).
{{operationId}}_args(_S) ->
[{{#allParams}}{{#required}}{{^-first}}, {{/-first}}{{dataType}}{{/required}}{{/allParams}}].
{{/operation}}
{{/operations}}

View File

@@ -11,6 +11,48 @@ Dependency: [Cowboy](https://github.com/ninenines/cowboy)
TODO
## Getting started
Use erlang-server with erlang.mk
TODO
1, Create an application by using erlang.mk
$ mkdir http_server
$ cd http_server
$ wget https://erlang.mk/erlang.mk
$ make -f erlang.mk bootstrap bootstrap-rel
$ make run
2, Modify the Makefile in the http_server directory to the following to introduce the dependency library:
PROJECT = http_server
PROJECT_DESCRIPTION = New project
PROJECT_VERSION = 0.1.0
DEPS = cowboy jesse jsx
dep_cowboy_commit = 2.5.0
dep_jesse_commit = 1.5.2
dep_jsx_commit = 2.9.0
DEP_PLUGINS = cowboy jesse jsx
PACKAGES += rfc3339
pkg_rfc3339_name = rfc3339
pkg_rfc3339_description = an erlang/elixir rfc3339 lib
pkg_rfc3339_homepage = https://github.com/talentdeficit/rfc3339
pkg_rfc3339_fetch = git
pkg_rfc3339_repo = https://github.com/talentdeficit/rfc3339
pkg_rfc3339_commit = master
include erlang.mk
3, Generate erlang-server project using openapi-generator
https://github.com/OpenAPITools/openapi-generator#2---getting-started
4, Copy erlang-server file to http_server project,Don't forget the 'priv' folder.
5, Start in the http_server project:
1, Introduce the following line in the http_server_app:start(_Type, _Args) function
openapi_server:start(http_server, #{ip=>{127,0,0,1}, port=>8080, net_opts=>[]})
2, Compilation http_server project
$ make
3, Start erlang virtual machine
$erl -pa ./deps/cowboy/ebin -pa ./deps/cowlib/ebin -pa ./deps/ranch/ebin -pa ./deps/jsx/ebin -pa ./deps/jesse/ebin -pa ./deps/rfc3339/ebin -pa ./ebin
4, Start project
application:ensure_all_started(http_server).

View File

@@ -1,6 +1,6 @@
{{#required}}
@NotNull
{{/required}}{{#isContainer}}{{^isPrimitiveType}}{{^isEnum}}
@Valid{{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{#isNotContainer}}{{^isPrimitiveType}}
@Valid{{/isPrimitiveType}}{{/isNotContainer}}
@Valid{{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}
@Valid{{/isPrimitiveType}}{{/isContainer}}
{{>beanValidationCore}}

View File

@@ -42,12 +42,12 @@ public class {{classname}}: JSONEncodable {
// MARK: JSONEncodable
func encodeToJSON() -> AnyObject {
var nillableDictionary = [String:AnyObject?](){{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}{{^isEnum}}{{#isInteger}}
var nillableDictionary = [String:AnyObject?](){{#vars}}{{^isContainer}}{{#isPrimitiveType}}{{^isEnum}}{{#isInteger}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isInteger}}{{#isLong}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isLong}}{{^isLong}}{{^isInteger}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{/isInteger}}{{/isLong}}{{/isEnum}}{{/isPrimitiveType}}{{#isEnum}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.rawValue{{/isEnum}}{{^isPrimitiveType}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isPrimitiveType}}{{/isNotContainer}}{{#isContainer}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isPrimitiveType}}{{/isContainer}}{{#isContainer}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isContainer}}{{/vars}}
let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:]
return dictionary

View File

@@ -77,12 +77,12 @@ open class {{classname}}: {{#parent}}{{{parent}}}{{/parent}}{{^parent}}JSONEncod
{{/additionalPropertiesType}}
// MARK: JSONEncodable
{{#parent}}override {{/parent}}open func encodeToJSON() -> Any {
var nillableDictionary = {{#parent}}super.encodeToJSON() as? [String:Any?] ?? {{/parent}}[String:Any?](){{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}{{^isEnum}}{{#isInteger}}
var nillableDictionary = {{#parent}}super.encodeToJSON() as? [String:Any?] ?? {{/parent}}[String:Any?](){{#vars}}{{^isContainer}}{{#isPrimitiveType}}{{^isEnum}}{{#isInteger}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isInteger}}{{#isLong}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isLong}}{{^isLong}}{{^isInteger}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{/isInteger}}{{/isLong}}{{/isEnum}}{{/isPrimitiveType}}{{#isEnum}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.rawValue{{/isEnum}}{{^isPrimitiveType}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isPrimitiveType}}{{/isNotContainer}}{{#isContainer}}{{^isEnum}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isPrimitiveType}}{{/isContainer}}{{#isContainer}}{{^isEnum}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isEnum}}{{#isEnum}}{{#isListContainer}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.map({$0.rawValue}).encodeToJSON(){{/isListContainer}}{{#isMapContainer}}//TODO: handle enum map scenario{{/isMapContainer}}{{/isEnum}}{{/isContainer}}{{/vars}}

View File

@@ -30,7 +30,7 @@ let enumsMap: {[index: string]: any} = {
{{#hasEnums}}
{{#vars}}
{{#isEnum}}
{{#isContainer}}"{{classname}}.{{enumName}}": {{classname}}.{{enumName}}{{/isContainer}}{{#isNotContainer}}"{{datatypeWithEnum}}": {{datatypeWithEnum}}{{/isNotContainer}},
{{#isContainer}}"{{classname}}.{{enumName}}": {{classname}}.{{enumName}}{{/isContainer}}{{^isContainer}}"{{datatypeWithEnum}}": {{datatypeWithEnum}}{{/isContainer}},
{{/isEnum}}
{{/vars}}
{{/hasEnums}}

View File

@@ -67,7 +67,7 @@ public class DartModelTest {
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isPrimitiveType);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "name");
@@ -78,7 +78,7 @@ public class DartModelTest {
Assert.assertTrue(property2.hasMore);
Assert.assertTrue(property2.required);
Assert.assertTrue(property2.isPrimitiveType);
Assert.assertTrue(property2.isNotContainer);
Assert.assertFalse(property2.isContainer);
final CodegenProperty property3 = cm.vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
@@ -89,7 +89,7 @@ public class DartModelTest {
Assert.assertEquals(property3.baseType, "DateTime");
Assert.assertFalse(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
}
@Test(description = "convert a model with list property")
@@ -117,7 +117,7 @@ public class DartModelTest {
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isPrimitiveType);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "urls");
@@ -176,7 +176,7 @@ public class DartModelTest {
Assert.assertEquals(property1.name, "children");
Assert.assertEquals(property1.baseType, "Children");
Assert.assertFalse(property1.required);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
}
@Test(description = "convert a model with complex list property")
@@ -228,7 +228,6 @@ public class DartModelTest {
Assert.assertEquals(property1.containerType, "map");
Assert.assertFalse(property1.required);
Assert.assertTrue(property1.isContainer);
Assert.assertFalse(property1.isNotContainer);
}
@Test(description = "convert an array model")

View File

@@ -101,7 +101,7 @@ public class JavaModelTest {
Assert.assertEquals(property1.baseType, "Long");
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = vars.get(1);
Assert.assertEquals(property2.baseName, "name");
@@ -116,7 +116,7 @@ public class JavaModelTest {
Assert.assertEquals(property2.example, "Tony");
Assert.assertTrue(property2.hasMore);
Assert.assertTrue(property2.required);
Assert.assertTrue(property2.isNotContainer);
Assert.assertFalse(property2.isContainer);
final CodegenProperty property3 = vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
@@ -130,7 +130,7 @@ public class JavaModelTest {
Assert.assertEquals(property3.baseType, "Date");
Assert.assertFalse(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
}
@Test(description = "convert a model with list property")
@@ -264,7 +264,7 @@ public class JavaModelTest {
Assert.assertEquals(property.defaultValue, null);
Assert.assertEquals(property.baseType, "Boolean");
Assert.assertFalse(property.required);
Assert.assertTrue(property.isNotContainer);
Assert.assertFalse(property.isContainer);
}
@Test(description = "convert a model with complex properties")
@@ -290,7 +290,7 @@ public class JavaModelTest {
Assert.assertEquals(property.defaultValue, "null");
Assert.assertEquals(property.baseType, "Children");
Assert.assertFalse(property.required);
Assert.assertTrue(property.isNotContainer);
Assert.assertFalse(property.isContainer);
}
@Test(description = "convert a model with complex list property")
@@ -348,8 +348,6 @@ public class JavaModelTest {
Assert.assertEquals(property.containerType, "map");
Assert.assertFalse(property.required);
Assert.assertTrue(property.isContainer);
Assert.assertFalse(property.isNotContainer);
}
@Test(description = "convert a model with an array property with item name")
@@ -385,7 +383,6 @@ public class JavaModelTest {
Assert.assertEquals(property.containerType, "array");
Assert.assertFalse(property.required);
Assert.assertTrue(property.isContainer);
Assert.assertFalse(property.isNotContainer);
final CodegenProperty itemsProperty = property.items;
Assert.assertEquals(itemsProperty.baseName,"child");
@@ -450,7 +447,7 @@ public class JavaModelTest {
Assert.assertEquals(property.baseType, "String");
Assert.assertFalse(property.hasMore);
Assert.assertTrue(property.required);
Assert.assertTrue(property.isNotContainer);
Assert.assertFalse(property.isContainer);
}
@Test(description = "convert a model with a 2nd char upper-case property names")
@@ -476,7 +473,7 @@ public class JavaModelTest {
Assert.assertEquals(property.baseType, "String");
Assert.assertFalse(property.hasMore);
Assert.assertTrue(property.required);
Assert.assertTrue(property.isNotContainer);
Assert.assertFalse(property.isContainer);
}
@Test(description = "convert a model starting with two upper-case letter property names")
@@ -502,7 +499,7 @@ public class JavaModelTest {
Assert.assertEquals(property.baseType, "String");
Assert.assertFalse(property.hasMore);
Assert.assertTrue(property.required);
Assert.assertTrue(property.isNotContainer);
Assert.assertFalse(property.isContainer);
}
@Test(description = "convert hyphens per issue 503")
@@ -564,7 +561,7 @@ public class JavaModelTest {
Assert.assertEquals(property.baseType, "byte[]");
Assert.assertFalse(property.hasMore);
Assert.assertFalse(property.required);
Assert.assertTrue(property.isNotContainer);
Assert.assertFalse(property.isContainer);
}
@Test(description = "translate an invalid param name")
@@ -588,7 +585,7 @@ public class JavaModelTest {
Assert.assertEquals(property.defaultValue, null);
Assert.assertEquals(property.baseType, "String");
Assert.assertFalse(property.hasMore);
Assert.assertTrue(property.isNotContainer);
Assert.assertFalse(property.isContainer);
}
@Test(description = "convert a parameter")
@@ -719,7 +716,7 @@ public class JavaModelTest {
Assert.assertEquals(property2.example, "Tony");
Assert.assertTrue(property2.hasMore);
Assert.assertTrue(property2.required);
Assert.assertTrue(property2.isNotContainer);
Assert.assertFalse(property2.isContainer);
Assert.assertTrue(property2.isXmlAttribute);
Assert.assertEquals(property2.xmlName, "myName");
Assert.assertNull(property2.xmlNamespace);
@@ -734,7 +731,7 @@ public class JavaModelTest {
Assert.assertEquals(property3.baseType, "Date");
Assert.assertFalse(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
Assert.assertFalse(property3.isXmlAttribute);
Assert.assertEquals(property3.xmlName, "myCreatedAt");
Assert.assertEquals(property3.xmlNamespace, "myNamespace");
@@ -802,7 +799,7 @@ public class JavaModelTest {
Assert.assertEquals(cp.dataType, "Boolean");
Assert.assertEquals(cp.name, "property");
Assert.assertEquals(cp.baseType, "Boolean");
Assert.assertTrue(cp.isNotContainer);
Assert.assertFalse(cp.isContainer);
Assert.assertTrue(cp.isBoolean);
Assert.assertEquals(cp.getter, "isProperty");
}
@@ -817,7 +814,7 @@ public class JavaModelTest {
Assert.assertEquals(cp.dataType, "Integer");
Assert.assertEquals(cp.name, "property");
Assert.assertEquals(cp.baseType, "Integer");
Assert.assertTrue(cp.isNotContainer);
Assert.assertFalse(cp.isContainer);
Assert.assertTrue(cp.isInteger);
Assert.assertFalse(cp.isLong);
Assert.assertEquals(cp.getter, "getProperty");
@@ -835,7 +832,7 @@ public class JavaModelTest {
Assert.assertEquals(cp.dataType, "Long");
Assert.assertEquals(cp.name, "property");
Assert.assertEquals(cp.baseType, "Long");
Assert.assertTrue(cp.isNotContainer);
Assert.assertFalse(cp.isContainer);
Assert.assertTrue(cp.isLong);
Assert.assertFalse(cp.isInteger);
Assert.assertEquals(cp.getter, "getProperty");
@@ -912,7 +909,7 @@ public class JavaModelTest {
Assert.assertEquals(cp.dataType, "String");
Assert.assertEquals(cp.name, "somePropertyWithMinMaxAndPattern");
Assert.assertEquals(cp.baseType, "String");
Assert.assertTrue(cp.isNotContainer);
Assert.assertFalse(cp.isContainer);
Assert.assertFalse(cp.isLong);
Assert.assertFalse(cp.isInteger);
Assert.assertTrue(cp.isString);
@@ -938,7 +935,7 @@ public class JavaModelTest {
Assert.assertEquals(cp.dataType, "String");
Assert.assertEquals(cp.name, "somePropertyWithMinMaxAndPattern");
Assert.assertEquals(cp.baseType, "String");
Assert.assertTrue(cp.isNotContainer);
Assert.assertFalse(cp.isContainer);
Assert.assertFalse(cp.isLong);
Assert.assertFalse(cp.isInteger);
Assert.assertTrue(cp.isString);
@@ -967,7 +964,7 @@ public class JavaModelTest {
Assert.assertEquals(cp.dataType, "String");
Assert.assertEquals(cp.name, "somePropertyWithMinMaxAndPattern");
Assert.assertEquals(cp.baseType, "String");
Assert.assertTrue(cp.isNotContainer);
Assert.assertFalse(cp.isContainer);
Assert.assertFalse(cp.isLong);
Assert.assertFalse(cp.isInteger);
Assert.assertTrue(cp.isString);

View File

@@ -90,7 +90,7 @@ public class KotlinClientCodegenModelTest {
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isPrimitiveType);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "name");
@@ -101,7 +101,7 @@ public class KotlinClientCodegenModelTest {
Assert.assertTrue(property2.hasMore);
Assert.assertTrue(property2.required);
Assert.assertTrue(property2.isPrimitiveType);
Assert.assertTrue(property2.isNotContainer);
Assert.assertFalse(property2.isContainer);
final CodegenProperty property3 = cm.vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
@@ -111,7 +111,7 @@ public class KotlinClientCodegenModelTest {
Assert.assertEquals(property3.baseType, "java.time.LocalDateTime");
Assert.assertFalse(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
}
@Test(description = "convert a simple model: threetenbp")
@@ -131,7 +131,7 @@ public class KotlinClientCodegenModelTest {
Assert.assertEquals(property3.baseType, "org.threeten.bp.LocalDateTime");
Assert.assertFalse(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
}
@Test(description = "convert a simple model: date string")
@@ -151,7 +151,7 @@ public class KotlinClientCodegenModelTest {
Assert.assertEquals(property3.baseType, "kotlin.String");
Assert.assertFalse(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
}
@Test(description = "convert a simple model: date java8")
@@ -171,7 +171,7 @@ public class KotlinClientCodegenModelTest {
Assert.assertEquals(property3.baseType, "java.time.LocalDateTime");
Assert.assertFalse(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
}
@Test(description = "convert a model with array property to default kotlin.Array")

View File

@@ -98,7 +98,7 @@ public class ObjcModelTest {
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isPrimitiveType);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "name");
@@ -109,7 +109,7 @@ public class ObjcModelTest {
Assert.assertTrue(property2.hasMore);
Assert.assertTrue(property2.required);
Assert.assertTrue(property2.isPrimitiveType);
Assert.assertTrue(property2.isNotContainer);
Assert.assertFalse(property2.isContainer);
final CodegenProperty property3 = cm.vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
@@ -119,7 +119,7 @@ public class ObjcModelTest {
Assert.assertEquals(property3.baseType, "NSDate");
Assert.assertFalse(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
}
@Test(description = "convert a model with list property")
@@ -147,7 +147,7 @@ public class ObjcModelTest {
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isPrimitiveType);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "urls");
@@ -208,7 +208,7 @@ public class ObjcModelTest {
Assert.assertEquals(property1.name, "children");
Assert.assertEquals(property1.baseType, "OAIChildren");
Assert.assertFalse(property1.required);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
}
@Test(description = "convert a model with complex list property")
@@ -260,7 +260,6 @@ public class ObjcModelTest {
Assert.assertEquals(property1.containerType, "map");
Assert.assertFalse(property1.required);
Assert.assertTrue(property1.isContainer);
Assert.assertFalse(property1.isNotContainer);
}
@Test(description = "convert an array model")

View File

@@ -73,7 +73,7 @@ public class PhpModelTest {
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isPrimitiveType);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "name");
@@ -84,7 +84,7 @@ public class PhpModelTest {
Assert.assertTrue(property2.hasMore);
Assert.assertTrue(property2.required);
Assert.assertTrue(property2.isPrimitiveType);
Assert.assertTrue(property2.isNotContainer);
Assert.assertFalse(property2.isContainer);
final CodegenProperty property3 = cm.vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
@@ -95,7 +95,7 @@ public class PhpModelTest {
Assert.assertEquals(property3.baseType, "\\DateTime");
Assert.assertFalse(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
}
@Test(description = "convert a model with list property")
@@ -123,7 +123,7 @@ public class PhpModelTest {
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isPrimitiveType);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "urls");
@@ -182,7 +182,7 @@ public class PhpModelTest {
Assert.assertEquals(property1.name, "children");
Assert.assertEquals(property1.baseType, "Children");
Assert.assertFalse(property1.required);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
}
@Test(description = "convert a model with complex list property")
@@ -234,7 +234,6 @@ public class PhpModelTest {
Assert.assertEquals(property1.containerType, "map");
Assert.assertFalse(property1.required);
Assert.assertTrue(property1.isContainer);
Assert.assertFalse(property1.isNotContainer);
}
@Test(description = "convert an array model")

View File

@@ -17,6 +17,11 @@
package org.openapitools.codegen.python;
import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.parser.core.models.ParseOptions;
import org.openapitools.codegen.CodegenOperation;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -54,4 +59,25 @@ public class PythonClientCodegenTest {
Assert.assertEquals(codegen.isHideGenerationTimestamp(), false);
}
@Test(description = "test regex patterns")
public void testRegularExpressionOpenAPISchemaVersion3() {
final OpenAPI openAPI = new OpenAPIParser()
.readLocation("src/test/resources/3_0/issue_1517.yaml", null, new ParseOptions()).getOpenAPI();
final PythonClientCodegen codegen = new PythonClientCodegen();
final String path = "/ping";
final Operation p = openAPI.getPaths().get(path).getGet();
final CodegenOperation op = codegen.fromOperation(path, "get", p, openAPI.getComponents().getSchemas());
// pattern_no_forward_slashes '^pattern$'
Assert.assertEquals(op.allParams.get(0).pattern, "/^pattern$/");
// pattern_two_slashes '/^pattern$/'
Assert.assertEquals(op.allParams.get(1).pattern, "/^pattern$/");
// pattern_dont_escape_backslash '/^pattern\d{3}$/'
Assert.assertEquals(op.allParams.get(2).pattern, "/^pattern\\d{3}$/");
// pattern_dont_escape_escaped_forward_slash '/^pattern\/\d{3}$/'
Assert.assertEquals(op.allParams.get(3).pattern, "/^pattern\\/\\d{3}$/");
// pattern_escape_unescaped_forward_slash '^pattern/\d{3}$'
Assert.assertEquals(op.allParams.get(4).pattern, "/^pattern\\/\\d{3}$/");
// pattern_with_modifiers '/^pattern\d{3}$/i
Assert.assertEquals(op.allParams.get(5).pattern, "/^pattern\\d{3}$/i");
}
}

View File

@@ -197,7 +197,7 @@ public class PythonTest {
Assert.assertEquals(property1.name, "children");
Assert.assertEquals(property1.baseType, "Children");
Assert.assertFalse(property1.required);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
}
@Test(description = "convert a model with complex list property")

View File

@@ -67,7 +67,7 @@ public class ScalaAkkaClientCodegenTest {
Assert.assertEquals(property1.baseType, "Long");
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "name");
@@ -79,7 +79,7 @@ public class ScalaAkkaClientCodegenTest {
Assert.assertEquals(property2.baseType, "String");
Assert.assertTrue(property2.hasMore);
Assert.assertTrue(property2.required);
Assert.assertTrue(property2.isNotContainer);
Assert.assertFalse(property2.isContainer);
final CodegenProperty property3 = cm.vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
@@ -91,7 +91,7 @@ public class ScalaAkkaClientCodegenTest {
Assert.assertEquals(property3.baseType, "DateTime");
Assert.assertFalse(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
}
@Test(description = "convert a model with list property")
@@ -173,7 +173,7 @@ public class ScalaAkkaClientCodegenTest {
Assert.assertNull(property1.defaultValue);
Assert.assertEquals(property1.baseType, "Children");
Assert.assertFalse(property1.required);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
}
@Test(description = "convert a model with complex list property")
@@ -231,7 +231,6 @@ public class ScalaAkkaClientCodegenTest {
Assert.assertEquals(property1.containerType, "map");
Assert.assertFalse(property1.required);
Assert.assertTrue(property1.isContainer);
Assert.assertFalse(property1.isNotContainer);
}
@Test(description = "convert an array model")

View File

@@ -66,7 +66,7 @@ public class ScalaHttpClientModelTest {
Assert.assertEquals(property1.baseType, "Long");
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "name");
@@ -78,7 +78,7 @@ public class ScalaHttpClientModelTest {
Assert.assertEquals(property2.baseType, "String");
Assert.assertTrue(property2.hasMore);
Assert.assertTrue(property2.required);
Assert.assertTrue(property2.isNotContainer);
Assert.assertFalse(property2.isContainer);
final CodegenProperty property3 = cm.vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
@@ -90,7 +90,7 @@ public class ScalaHttpClientModelTest {
Assert.assertEquals(property3.baseType, "Date");
Assert.assertFalse(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
}
@Test(description = "convert a model with list property")
@@ -172,7 +172,7 @@ public class ScalaHttpClientModelTest {
Assert.assertNull(property1.defaultValue);
Assert.assertEquals(property1.baseType, "Children");
Assert.assertFalse(property1.required);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
}
@Test(description = "convert a model with complex list property")
@@ -230,7 +230,6 @@ public class ScalaHttpClientModelTest {
Assert.assertEquals(property1.containerType, "map");
Assert.assertFalse(property1.required);
Assert.assertTrue(property1.isContainer);
Assert.assertFalse(property1.isNotContainer);
}
@Test(description = "convert an array model")

View File

@@ -72,7 +72,7 @@ public class Swift4ModelTest {
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isPrimitiveType);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "name");
@@ -83,7 +83,7 @@ public class Swift4ModelTest {
Assert.assertTrue(property2.hasMore);
Assert.assertTrue(property2.required);
Assert.assertTrue(property2.isPrimitiveType);
Assert.assertTrue(property2.isNotContainer);
Assert.assertFalse(property2.isContainer);
final CodegenProperty property3 = cm.vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
@@ -93,7 +93,7 @@ public class Swift4ModelTest {
Assert.assertEquals(property3.baseType, "Date");
Assert.assertTrue(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
final CodegenProperty property4 = cm.vars.get(3);
Assert.assertEquals(property4.baseName, "binary");
@@ -103,7 +103,7 @@ public class Swift4ModelTest {
Assert.assertEquals(property4.baseType, "URL");
Assert.assertTrue(property4.hasMore);
Assert.assertFalse(property4.required);
Assert.assertTrue(property4.isNotContainer);
Assert.assertFalse(property4.isContainer);
final CodegenProperty property5 = cm.vars.get(4);
Assert.assertEquals(property5.baseName, "byte");
@@ -113,7 +113,7 @@ public class Swift4ModelTest {
Assert.assertEquals(property5.baseType, "Data");
Assert.assertTrue(property5.hasMore);
Assert.assertFalse(property5.required);
Assert.assertTrue(property5.isNotContainer);
Assert.assertFalse(property5.isContainer);
final CodegenProperty property6 = cm.vars.get(5);
Assert.assertEquals(property6.baseName, "uuid");
@@ -123,7 +123,7 @@ public class Swift4ModelTest {
Assert.assertEquals(property6.baseType, "UUID");
Assert.assertTrue(property6.hasMore);
Assert.assertFalse(property6.required);
Assert.assertTrue(property6.isNotContainer);
Assert.assertFalse(property6.isContainer);
final CodegenProperty property7 = cm.vars.get(6);
Assert.assertEquals(property7.baseName, "dateOfBirth");
@@ -133,7 +133,7 @@ public class Swift4ModelTest {
Assert.assertEquals(property7.baseType, "Date");
Assert.assertFalse(property7.hasMore);
Assert.assertFalse(property7.required);
Assert.assertTrue(property7.isNotContainer);
Assert.assertFalse(property7.isContainer);
}
}

View File

@@ -77,7 +77,7 @@ public class TypeScriptFetchModelTest {
Assert.assertEquals(property1.baseType, "number");
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "name");
@@ -87,7 +87,7 @@ public class TypeScriptFetchModelTest {
Assert.assertEquals(property2.baseType, "string");
Assert.assertTrue(property2.hasMore);
Assert.assertTrue(property2.required);
Assert.assertTrue(property2.isNotContainer);
Assert.assertFalse(property2.isContainer);
final CodegenProperty property3 = cm.vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
@@ -97,7 +97,7 @@ public class TypeScriptFetchModelTest {
Assert.assertEquals(property3.defaultValue, "undefined");
Assert.assertTrue(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
final CodegenProperty property4 = cm.vars.get(3);
Assert.assertEquals(property4.baseName, "birthDate");
@@ -107,7 +107,7 @@ public class TypeScriptFetchModelTest {
Assert.assertEquals(property4.defaultValue, "undefined");
Assert.assertFalse(property4.hasMore);
Assert.assertFalse(property4.required);
Assert.assertTrue(property4.isNotContainer);
Assert.assertFalse(property4.isContainer);
}
@Test(description = "convert a model with list property")
@@ -133,7 +133,7 @@ public class TypeScriptFetchModelTest {
Assert.assertEquals(property1.baseType, "number");
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "urls");

View File

@@ -65,7 +65,7 @@ public class TypeScriptAngularModelTest {
Assert.assertEquals(property1.baseType, "number");
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "name");
@@ -75,7 +75,7 @@ public class TypeScriptAngularModelTest {
Assert.assertEquals(property2.baseType, "string");
Assert.assertTrue(property2.hasMore);
Assert.assertTrue(property2.required);
Assert.assertTrue(property2.isNotContainer);
Assert.assertFalse(property2.isContainer);
final CodegenProperty property3 = cm.vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
@@ -86,7 +86,7 @@ public class TypeScriptAngularModelTest {
Assert.assertEquals(property3.defaultValue, "undefined");
Assert.assertTrue(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
final CodegenProperty property4 = cm.vars.get(3);
Assert.assertEquals(property4.baseName, "birthDate");
@@ -97,7 +97,7 @@ public class TypeScriptAngularModelTest {
Assert.assertEquals(property4.defaultValue, "undefined");
Assert.assertFalse(property4.hasMore);
Assert.assertFalse(property4.required);
Assert.assertTrue(property4.isNotContainer);
Assert.assertFalse(property4.isContainer);
}
@Test(description = "convert a model with list property")
@@ -123,7 +123,7 @@ public class TypeScriptAngularModelTest {
Assert.assertEquals(property1.baseType, "number");
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "urls");

View File

@@ -65,7 +65,7 @@ public class TypeScriptAngularJsModelTest {
Assert.assertEquals(property1.baseType, "number");
Assert.assertTrue(property1.hasMore);
Assert.assertTrue(property1.required);
Assert.assertTrue(property1.isNotContainer);
Assert.assertFalse(property1.isContainer);
final CodegenProperty property2 = cm.vars.get(1);
Assert.assertEquals(property2.baseName, "name");
@@ -75,7 +75,7 @@ public class TypeScriptAngularJsModelTest {
Assert.assertEquals(property2.baseType, "string");
Assert.assertTrue(property2.hasMore);
Assert.assertTrue(property2.required);
Assert.assertTrue(property2.isNotContainer);
Assert.assertFalse(property2.isContainer);
final CodegenProperty property3 = cm.vars.get(2);
Assert.assertEquals(property3.baseName, "createdAt");
@@ -85,7 +85,7 @@ public class TypeScriptAngularJsModelTest {
Assert.assertEquals(property3.defaultValue, "undefined");
Assert.assertTrue(property3.hasMore);
Assert.assertFalse(property3.required);
Assert.assertTrue(property3.isNotContainer);
Assert.assertFalse(property3.isContainer);
final CodegenProperty property4 = cm.vars.get(3);
Assert.assertEquals(property4.baseName, "birthDate");
@@ -95,7 +95,7 @@ public class TypeScriptAngularJsModelTest {
Assert.assertEquals(property4.defaultValue, "undefined");
Assert.assertFalse(property4.hasMore);
Assert.assertFalse(property4.required);
Assert.assertTrue(property4.isNotContainer);
Assert.assertFalse(property4.isContainer);
}
@Test(description = "convert a model with list property")

View File

@@ -199,4 +199,32 @@ public class ModelUtilsTest {
Assert.assertEquals(refToComposedSchema, ModelUtils.unaliasSchema(allSchemas, refToComposedSchema));
}
/**
* Issue https://github.com/OpenAPITools/openapi-generator/issues/1624.
* ModelUtils.isFreeFormObject() should not throw an NPE when passed an empty
* object schema that has additionalProperties defined as an empty object schema.
*/
@Test
public void testIsFreeFormObject() {
// Create initial "empty" object schema.
ObjectSchema objSchema = new ObjectSchema();
Assert.assertTrue(ModelUtils.isFreeFormObject(objSchema));
// Set additionalProperties to an empty ObjectSchema.
objSchema.setAdditionalProperties(new ObjectSchema());
Assert.assertTrue(ModelUtils.isFreeFormObject(objSchema));
// Add a single property to the schema (no longer a free-form object).
Map<String, Schema> props = new HashMap<>();
props.put("prop1", new StringSchema());
objSchema.setProperties(props);
Assert.assertFalse(ModelUtils.isFreeFormObject(objSchema));
// Test a non-object schema
Assert.assertFalse(ModelUtils.isFreeFormObject(new StringSchema()));
// Test a null schema
Assert.assertFalse(ModelUtils.isFreeFormObject(null));
}
}

View File

@@ -0,0 +1,51 @@
openapi: 3.0.1
info:
title: Test Regex generation for parameter validation
version: 1.0.0
components:
headers:
responses:
OK_200:
description: OK
paths:
/ping:
get:
summary: Get Payment Information
description: Returns the content of a payment object
parameters:
- name: pattern_no_forward_slashes
in: header
schema:
type: string
pattern: '^pattern$'
- name: pattern_two_slashes
in: header
schema:
type: string
pattern: '/^pattern$/'
- name: pattern_dont_escape_backslash
in: header
schema:
type: string
pattern: '^pattern\d{3}$'
- name: pattern_dont_escape_escaped_forward_slash
in: header
schema:
type: string
pattern: '^pattern\/\d{3}$'
- name: pattern_escape_unescaped_forward_slash
in: header
schema:
type: string
pattern: '^pattern/\d{3}$'
- name: pattern_with_modifiers
in: header
schema:
type: string
pattern: '/^pattern\d{3}$/i'
responses:
'200':
$ref: "#/components/responses/OK_200"

View File

@@ -1222,6 +1222,7 @@
<module>samples/client/petstore/elm</module>
<module>samples/client/petstore/elixir</module>
<module>samples/client/petstore/erlang-client</module>
<module>samples/client/petstore/erlang-proper</module>
<!-- servers -->
<!-- disable erlang server test due to dependency issues -->
<module>samples/server/petstore/erlang-server</module>

View File

@@ -1 +1 @@
2.3.0-SNAPSHOT
3.3.4-SNAPSHOT

View File

@@ -1,11 +1,11 @@
# petstore-api
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end --
This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
- API version: 1.0.0 */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
- Package version: 1.0.0
- Build package: io.swagger.codegen.languages.PythonClientCodegen
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
## Requirements.
@@ -50,13 +50,14 @@ import time
import petstore_api
from petstore_api.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = petstore_api.FakeApi()
test_code_inject____end____rn_n_r = 'test_code_inject____end____rn_n_r_example' # str | To test code injection */ ' \" =end -- \\r\\n \\n \\r (optional)
api_instance = petstore_api.FakeApi(petstore_api.ApiClient(configuration))
unknown_base_type = petstore_api.UNKNOWN_BASE_TYPE() # UNKNOWN_BASE_TYPE | (optional)
try:
# To test code injection */ ' \" =end -- \\r\\n \\n \\r
api_instance.test_code_inject____end__rn_n_r(test_code_inject____end____rn_n_r=test_code_inject____end____rn_n_r)
api_instance.test_code_inject____end__rn_n_r(unknown_base_type=unknown_base_type)
except ApiException as e:
print("Exception when calling FakeApi->test_code_inject____end__rn_n_r: %s\n" % e)
@@ -64,7 +65,7 @@ except ApiException as e:
## Documentation for API Endpoints
All URIs are relative to *https://petstore.swagger.io */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r*
All URIs are relative to *http://petstore.swagger.io */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
@@ -97,5 +98,6 @@ Class | Method | HTTP request | Description
## Author
apiteam@swagger.io */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r
something@something.abc */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r

View File

@@ -1,6 +1,6 @@
# petstore_api.FakeApi
All URIs are relative to *https://petstore.swagger.io */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r*
All URIs are relative to *http://petstore.swagger.io */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r/v2 */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r*
Method | HTTP request | Description
------------- | ------------- | -------------
@@ -8,7 +8,9 @@ Method | HTTP request | Description
# **test_code_inject____end__rn_n_r**
> test_code_inject____end__rn_n_r(test_code_inject____end____rn_n_r=test_code_inject____end____rn_n_r)
> test_code_inject____end__rn_n_r(unknown_base_type=unknown_base_type)
To test code injection */ ' \" =end -- \\r\\n \\n \\r
To test code injection */ ' \" =end -- \\r\\n \\n \\r
@@ -22,11 +24,11 @@ from pprint import pprint
# create an instance of the API class
api_instance = petstore_api.FakeApi()
test_code_inject____end____rn_n_r = 'test_code_inject____end____rn_n_r_example' # str | To test code injection */ ' \" =end -- \\r\\n \\n \\r (optional)
unknown_base_type = petstore_api.UNKNOWN_BASE_TYPE() # UNKNOWN_BASE_TYPE | (optional)
try:
# To test code injection */ ' \" =end -- \\r\\n \\n \\r
api_instance.test_code_inject____end__rn_n_r(test_code_inject____end____rn_n_r=test_code_inject____end____rn_n_r)
api_instance.test_code_inject____end__rn_n_r(unknown_base_type=unknown_base_type)
except ApiException as e:
print("Exception when calling FakeApi->test_code_inject____end__rn_n_r: %s\n" % e)
```
@@ -35,7 +37,7 @@ except ApiException as e:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**test_code_inject____end____rn_n_r** | **str**| To test code injection */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r | [optional]
**unknown_base_type** | [**UNKNOWN_BASE_TYPE**](UNKNOWN_BASE_TYPE.md)| | [optional]
### Return type
@@ -48,7 +50,7 @@ No authorization required
### HTTP request headers
- **Content-Type**: application/json, */ \" =end --
- **Accept**: application/json, */ \" =end --
- **Accept**: Not defined
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
git_user_id=$1
git_repo_id=$2
@@ -36,7 +36,7 @@ git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git

View File

@@ -3,18 +3,20 @@
# flake8: noqa
"""
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
OpenAPI Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end -- # noqa: E501
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Contact: something@something.abc */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
__version__ = "1.0.0"
# import apis into sdk package
from petstore_api.api.fake_api import FakeApi

View File

@@ -1,13 +1,13 @@
# coding: utf-8
"""
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
OpenAPI Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end -- # noqa: E501
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Contact: something@something.abc */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://openapi-generator.tech
"""
@@ -22,10 +22,10 @@ from petstore_api.api_client import ApiClient
class FakeApi(object):
"""NOTE: This class is auto generated by the swagger code generator program.
"""NOTE: This class is auto generated by OpenAPI Generator
Ref: https://openapi-generator.tech
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
"""
def __init__(self, api_client=None):
@@ -34,56 +34,59 @@ class FakeApi(object):
self.api_client = api_client
def test_code_inject____end__rn_n_r(self, **kwargs): # noqa: E501
"""To test code injection */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r # noqa: E501
"""To test code injection */ ' \" =end -- \\r\\n \\n \\r # noqa: E501
To test code injection */ ' \" =end -- \\r\\n \\n \\r # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.test_code_inject____end__rn_n_r(async=True)
asynchronous HTTP request, please pass async_req=True
>>> thread = api.test_code_inject____end__rn_n_r(async_req=True)
>>> result = thread.get()
:param async bool
:param str test_code_inject____end____rn_n_r: To test code injection */ ' \" =end -- \\r\\n \\n \\r
:param async_req bool
:param UNKNOWN_BASE_TYPE unknown_base_type:
:return: None
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async'):
if kwargs.get('async_req'):
return self.test_code_inject____end__rn_n_r_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.test_code_inject____end__rn_n_r_with_http_info(**kwargs) # noqa: E501
return data
def test_code_inject____end__rn_n_r_with_http_info(self, **kwargs): # noqa: E501
"""To test code injection */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r # noqa: E501
"""To test code injection */ ' \" =end -- \\r\\n \\n \\r # noqa: E501
To test code injection */ ' \" =end -- \\r\\n \\n \\r # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async=True
>>> thread = api.test_code_inject____end__rn_n_r_with_http_info(async=True)
asynchronous HTTP request, please pass async_req=True
>>> thread = api.test_code_inject____end__rn_n_r_with_http_info(async_req=True)
>>> result = thread.get()
:param async bool
:param str test_code_inject____end____rn_n_r: To test code injection */ ' \" =end -- \\r\\n \\n \\r
:param async_req bool
:param UNKNOWN_BASE_TYPE unknown_base_type:
:return: None
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['test_code_inject____end____rn_n_r'] # noqa: E501
all_params.append('async')
local_var_params = locals()
all_params = ['unknown_base_type'] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method test_code_inject____end__rn_n_r" % key
)
params[key] = val
del params['kwargs']
local_var_params[key] = val
del local_var_params['kwargs']
collection_formats = {}
@@ -95,14 +98,10 @@ class FakeApi(object):
form_params = []
local_var_files = {}
if 'test_code_inject____end____rn_n_r' in params:
form_params.append(('test code inject */ &#39; &quot; &#x3D;end -- \r\n \n \r', params['test_code_inject____end____rn_n_r'])) # noqa: E501
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json', '*/ \" =end -- ']) # noqa: E501
if 'unknown_base_type' in local_var_params:
body_params = local_var_params['unknown_base_type']
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json', '*/ \" =end -- ']) # noqa: E501
@@ -120,8 +119,8 @@ class FakeApi(object):
files=local_var_files,
response_type=None, # noqa: E501
auth_settings=auth_settings,
async=params.get('async'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats=collection_formats)

View File

@@ -1,12 +1,12 @@
# coding: utf-8
"""
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
OpenAPI Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end -- # noqa: E501
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Contact: something@something.abc */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
@@ -29,15 +29,15 @@ from petstore_api import rest
class ApiClient(object):
"""Generic API client for Swagger client library builds.
"""Generic API client for OpenAPI client library builds.
Swagger generic API client. This client handles the client-
OpenAPI generic API client. This client handles the client-
server communication, and is invariant across implementations. Specifics of
the methods and models for each application are generated from the Swagger
the methods and models for each application are generated from the OpenAPI
templates.
NOTE: This class is auto generated by the swagger code generator program.
Ref: https://github.com/swagger-api/swagger-codegen
NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
:param configuration: .Configuration object for this client
@@ -46,6 +46,8 @@ class ApiClient(object):
the API.
:param cookie: a cookie to include in the header when making calls
to the API
:param pool_threads: The number of threads to use for async requests
to the API. More threads means more concurrent API requests.
"""
PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types
@@ -59,25 +61,37 @@ class ApiClient(object):
'datetime': datetime.datetime,
'object': object,
}
_pool = None
def __init__(self, configuration=None, header_name=None, header_value=None,
cookie=None):
cookie=None, pool_threads=None):
if configuration is None:
configuration = Configuration()
self.configuration = configuration
self.pool_threads = pool_threads
self.pool = ThreadPool()
self.rest_client = rest.RESTClientObject(configuration)
self.default_headers = {}
if header_name is not None:
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'Swagger-Codegen/1.0.0/python'
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
def __del__(self):
self.pool.close()
self.pool.join()
if self._pool:
self._pool.close()
self._pool.join()
self._pool = None
@property
def pool(self):
"""Create thread pool on first request
avoids instantiating unused threadpool for blocking clients.
"""
if self._pool is None:
self._pool = ThreadPool(self.pool_threads)
return self._pool
@property
def user_agent(self):
@@ -177,7 +191,7 @@ class ApiClient(object):
convert to string in iso8601 format.
If obj is list, sanitize each element in the list.
If obj is dict, return the dict.
If obj is swagger model, return the properties dict.
If obj is OpenAPI model, return the properties dict.
:param obj: The data to serialize.
:return: The serialized form of data.
@@ -199,12 +213,12 @@ class ApiClient(object):
obj_dict = obj
else:
# Convert model obj to dict except
# attributes `swagger_types`, `attribute_map`
# attributes `openapi_types`, `attribute_map`
# and attributes which value is not None.
# Convert attribute name to json key in
# model definition for request.
obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
for attr, _ in six.iteritems(obj.swagger_types)
for attr, _ in six.iteritems(obj.openapi_types)
if getattr(obj, attr) is not None}
return {key: self.sanitize_for_serialization(val)
@@ -245,12 +259,12 @@ class ApiClient(object):
if type(klass) == str:
if klass.startswith('list['):
sub_kls = re.match('list\[(.*)\]', klass).group(1)
sub_kls = re.match(r'list\[(.*)\]', klass).group(1)
return [self.__deserialize(sub_data, sub_kls)
for sub_data in data]
if klass.startswith('dict('):
sub_kls = re.match('dict\(([^,]*), (.*)\)', klass).group(2)
sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2)
return {k: self.__deserialize(v, sub_kls)
for k, v in six.iteritems(data)}
@@ -274,12 +288,12 @@ class ApiClient(object):
def call_api(self, resource_path, method,
path_params=None, query_params=None, header_params=None,
body=None, post_params=None, files=None,
response_type=None, auth_settings=None, async=None,
response_type=None, auth_settings=None, async_req=None,
_return_http_data_only=None, collection_formats=None,
_preload_content=True, _request_timeout=None):
"""Makes the HTTP request (synchronous) and returns deserialized data.
To make an async request, set the async parameter.
To make an async_req request, set the async_req parameter.
:param resource_path: Path to method endpoint.
:param method: Method to call.
@@ -294,7 +308,7 @@ class ApiClient(object):
:param response: Response data type.
:param files dict: key -> filename, value -> filepath,
for `multipart/form-data`.
:param async bool: execute request asynchronously
:param async_req bool: execute request asynchronously
:param _return_http_data_only: response data without head status code
and headers
:param collection_formats: dict of collection formats for path, query,
@@ -307,13 +321,13 @@ class ApiClient(object):
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return:
If async parameter is True,
If async_req parameter is True,
the request will be called asynchronously.
The method will return the request thread.
If parameter async is False or missing,
If parameter async_req is False or missing,
then the method will return the response directly.
"""
if not async:
if not async_req:
return self.__call_api(resource_path, method,
path_params, query_params, header_params,
body, post_params, files,
@@ -546,7 +560,7 @@ class ApiClient(object):
return data
def __deserialize_object(self, value):
"""Return a original value.
"""Return an original value.
:return: object.
"""
@@ -599,13 +613,13 @@ class ApiClient(object):
:return: model object.
"""
if not klass.swagger_types and not hasattr(klass,
if not klass.openapi_types and not hasattr(klass,
'get_real_child_model'):
return data
kwargs = {}
if klass.swagger_types is not None:
for attr, attr_type in six.iteritems(klass.swagger_types):
if klass.openapi_types is not None:
for attr, attr_type in six.iteritems(klass.openapi_types):
if (data is not None and
klass.attribute_map[attr] in data and
isinstance(data, (list, dict))):

View File

@@ -1,13 +1,13 @@
# coding: utf-8
"""
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
OpenAPI Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end -- # noqa: E501
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Contact: something@something.abc */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://openapi-generator.tech
"""
@@ -38,16 +38,16 @@ class TypeWithDefault(type):
class Configuration(six.with_metaclass(TypeWithDefault, object)):
"""NOTE: This class is auto generated by the swagger code generator program.
"""NOTE: This class is auto generated by OpenAPI Generator
Ref: https://github.com/swagger-api/swagger-codegen
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
def __init__(self):
"""Constructor"""
# Default Base url
self.host = "https://petstore.swagger.io */ ' \" =end -- \\r\\n \\n \\r/v2 */ ' \" =end -- \\r\\n \\n \\r"
self.host = "http://petstore.swagger.io */ ' \" =end -- \\r\\n \\n \\r/v2 */ ' \" =end -- \\r\\n \\n \\r"
# Temp file folder for downloading files
self.temp_folder_path = None
@@ -134,17 +134,6 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
self.logger_file_handler.setFormatter(self.logger_formatter)
for _, logger in six.iteritems(self.logger):
logger.addHandler(self.logger_file_handler)
if self.logger_stream_handler:
logger.removeHandler(self.logger_stream_handler)
else:
# If not set logging file,
# then add stream handler and remove file handler.
self.logger_stream_handler = logging.StreamHandler()
self.logger_stream_handler.setFormatter(self.logger_formatter)
for _, logger in six.iteritems(self.logger):
logger.addHandler(self.logger_stream_handler)
if self.logger_file_handler:
logger.removeHandler(self.logger_file_handler)
@property
def debug(self):

View File

@@ -2,13 +2,13 @@
# flake8: noqa
"""
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
OpenAPI Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end -- # noqa: E501
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Contact: something@something.abc */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://openapi-generator.tech
"""

View File

@@ -1,13 +1,13 @@
# coding: utf-8
"""
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
OpenAPI Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end -- # noqa: E501
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Contact: something@something.abc */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://openapi-generator.tech
"""
@@ -18,19 +18,20 @@ import six
class ModelReturn(object):
"""NOTE: This class is auto generated by the swagger code generator program.
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
swagger_types = {
openapi_types = {
'_return': 'int'
}
@@ -39,7 +40,7 @@ class ModelReturn(object):
}
def __init__(self, _return=None): # noqa: E501
"""ModelReturn - a model defined in Swagger""" # noqa: E501
"""ModelReturn - a model defined in OpenAPI""" # noqa: E501
self.__return = None
self.discriminator = None
@@ -74,7 +75,7 @@ class ModelReturn(object):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.swagger_types):
for attr, _ in six.iteritems(self.openapi_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(

View File

@@ -1,13 +1,13 @@
# coding: utf-8
"""
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
OpenAPI Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end -- # noqa: E501
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Contact: something@something.abc */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://openapi-generator.tech
"""
@@ -27,7 +27,7 @@ from six.moves.urllib.parse import urlencode
try:
import urllib3
except ImportError:
raise ImportError('Swagger python client requires urllib3.')
raise ImportError('OpenAPI Python client requires urllib3.')
logger = logging.getLogger(__name__)

View File

@@ -1,13 +1,13 @@
# coding: utf-8
"""
Swagger Petstore */ ' \" =end -- \\r\\n \\n \\r
OpenAPI Petstore */ ' \" =end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end -- # noqa: E501
OpenAPI spec version: 1.0.0 */ ' \" =end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Contact: something@something.abc */ ' \" =end -- \\r\\n \\n \\r
Generated by: https://openapi-generator.tech
"""
@@ -27,10 +27,10 @@ REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"]
setup(
name=NAME,
version=VERSION,
description="Swagger Petstore */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r",
author_email="apiteam@swagger.io */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r",
description="OpenAPI Petstore */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r",
author_email="something@something.abc */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r",
url="",
keywords=["Swagger", "Swagger Petstore */ &#39; \&quot; &#x3D;end -- \\r\\n \\n \\r"],
keywords=["OpenAPI", "OpenAPI-Generator", "OpenAPI Petstore */ ' \" =end -- \\r\\n \\n \\r"],
install_requires=REQUIRES,
packages=find_packages(),
include_package_data=True,

View File

@@ -4,7 +4,7 @@ envlist = py27, py3
[testenv]
deps=-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands=
nosetests \
[]
[]

View File

@@ -1,23 +0,0 @@
# 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

@@ -1 +0,0 @@
4.0.0-SNAPSHOT

View File

@@ -1,65 +0,0 @@
package org.openapitools.client.api;
import java.util.List;
import java.util.function.Consumer;
import org.openapitools.client.model.*;
import net.java.html.json.Model;
import net.java.html.json.ModelOperation;
import net.java.html.json.OnReceive;
import net.java.html.json.Property;
@ModelOperation
@Model(className = "PetApi", targetId = "", properties = {
@Property(name="url", type=String.class )
})
public class PetApiConnector {
// Add a new pet to the store
@OnReceive(method = "POST", data=Pet.class, url = "{url}/pet")
public static void addPet( PetApi model, Pet pet, Consumer<Throwable> onError) {
}
// Deletes a pet
@OnReceive(method = "DELETE", url = "{url}/pet/{petId}")
public static void deletePet( PetApi model, Consumer<Throwable> onError) {
}
// Finds Pets by status
@OnReceive(method = "GET", url = "{url}/pet/findByStatus")
public static void findPetsByStatus( PetApi model,List<Pet> result,Consumer<List<Pet>> onSuccess, Consumer<Throwable> onError) {
}
// Finds Pets by tags
@OnReceive(method = "GET", url = "{url}/pet/findByTags")
public static void findPetsByTags( PetApi model,List<Pet> result,Consumer<List<Pet>> onSuccess, Consumer<Throwable> onError) {
}
// Find pet by ID
@OnReceive(method = "GET", url = "{url}/pet/{petId}")
public static void getPetById( PetApi model, Pet result,Consumer< Pet> onSuccess, Consumer<Throwable> onError) {
}
// Update an existing pet
@OnReceive(method = "PUT", data=Pet.class, url = "{url}/pet")
public static void updatePet( PetApi model, Pet pet, Consumer<Throwable> onError) {
}
// Updates a pet in the store with form data
@OnReceive(method = "POST", url = "{url}/pet/{petId}")
public static void updatePetWithForm( PetApi model, Consumer<Throwable> onError) {
}
// uploads an image
@OnReceive(method = "POST", url = "{url}/pet/{petId}/uploadImage")
public static void uploadFile( PetApi model, Pet result,Consumer< Pet> onSuccess, Consumer<Throwable> onError) {
}
}

View File

@@ -1,41 +0,0 @@
package org.openapitools.client.api;
import java.util.List;
import java.util.function.Consumer;
import org.openapitools.client.model.*;
import net.java.html.json.Model;
import net.java.html.json.ModelOperation;
import net.java.html.json.OnReceive;
import net.java.html.json.Property;
@ModelOperation
@Model(className = "StoreApi", targetId = "", properties = {
@Property(name="url", type=String.class )
})
public class StoreApiConnector {
// Delete purchase order by ID
@OnReceive(method = "DELETE", url = "{url}/store/order/{orderId}")
public static void deleteOrder( StoreApi model, Consumer<Throwable> onError) {
}
// Returns pet inventories by status
@OnReceive(method = "GET", url = "{url}/store/inventory")
public static void getInventory( StoreApi model, Store result,Consumer< Store> onSuccess, Consumer<Throwable> onError) {
}
// Find purchase order by ID
@OnReceive(method = "GET", url = "{url}/store/order/{orderId}")
public static void getOrderById( StoreApi model, Store result,Consumer< Store> onSuccess, Consumer<Throwable> onError) {
}
// Place an order for a pet
@OnReceive(method = "POST", data=Order.class, url = "{url}/store/order")
public static void placeOrder( StoreApi model, Order order, Store result,Consumer< Store> onSuccess, Consumer<Throwable> onError) {
}
}

View File

@@ -1,65 +0,0 @@
package org.openapitools.client.api;
import java.util.List;
import java.util.function.Consumer;
import org.openapitools.client.model.*;
import net.java.html.json.Model;
import net.java.html.json.ModelOperation;
import net.java.html.json.OnReceive;
import net.java.html.json.Property;
@ModelOperation
@Model(className = "UserApi", targetId = "", properties = {
@Property(name="url", type=String.class )
})
public class UserApiConnector {
// Create user
@OnReceive(method = "POST", data=User.class, url = "{url}/user")
public static void createUser( UserApi model, User user, Consumer<Throwable> onError) {
}
// Creates list of users with given input array
@OnReceive(method = "POST", data=List.class, url = "{url}/user/createWithArray")
public static void createUsersWithArrayInput( UserApi model, List user, Consumer<Throwable> onError) {
}
// Creates list of users with given input array
@OnReceive(method = "POST", data=List.class, url = "{url}/user/createWithList")
public static void createUsersWithListInput( UserApi model, List user, Consumer<Throwable> onError) {
}
// Delete user
@OnReceive(method = "DELETE", url = "{url}/user/{username}")
public static void deleteUser( UserApi model, Consumer<Throwable> onError) {
}
// Get user by user name
@OnReceive(method = "GET", url = "{url}/user/{username}")
public static void getUserByName( UserApi model, User result,Consumer< User> onSuccess, Consumer<Throwable> onError) {
}
// Logs user into the system
@OnReceive(method = "GET", url = "{url}/user/login")
public static void loginUser( UserApi model, User result,Consumer< User> onSuccess, Consumer<Throwable> onError) {
}
// Logs out current logged in user session
@OnReceive(method = "GET", url = "{url}/user/logout")
public static void logoutUser( UserApi model, Consumer<Throwable> onError) {
}
// Updated user
@OnReceive(method = "PUT", data=User.class, url = "{url}/user/{username}")
public static void updateUser( UserApi model, User user, Consumer<Throwable> onError) {
}
}

View File

@@ -1,20 +0,0 @@
package org.openapitools.client.model;
import java.util.List;
import net.java.html.json.ComputedProperty;
import net.java.html.json.Function;
import net.java.html.json.Model;
import net.java.html.json.ModelOperation;
import net.java.html.json.OnPropertyChange;
import net.java.html.json.OnReceive;
import net.java.html.json.Property;
@Model(className = "ApiResponse", targetId = "", properties = {
@Property(name = "code", type = int.class)
, @Property(name = "type", type = String.class)
, @Property(name = "message", type = String.class)
}
)
public class ApiResponseVMD{
}

View File

@@ -1,19 +0,0 @@
package org.openapitools.client.model;
import java.util.List;
import net.java.html.json.ComputedProperty;
import net.java.html.json.Function;
import net.java.html.json.Model;
import net.java.html.json.ModelOperation;
import net.java.html.json.OnPropertyChange;
import net.java.html.json.OnReceive;
import net.java.html.json.Property;
@Model(className = "Category", targetId = "", properties = {
@Property(name = "id", type = long.class)
, @Property(name = "name", type = String.class)
}
)
public class CategoryVMD{
}

View File

@@ -1,23 +0,0 @@
package org.openapitools.client.model;
import java.util.List;
import net.java.html.json.ComputedProperty;
import net.java.html.json.Function;
import net.java.html.json.Model;
import net.java.html.json.ModelOperation;
import net.java.html.json.OnPropertyChange;
import net.java.html.json.OnReceive;
import net.java.html.json.Property;
@Model(className = "Order", targetId = "", properties = {
@Property(name = "id", type = long.class)
, @Property(name = "petId", type = long.class)
, @Property(name = "quantity", type = int.class)
, @Property(name = "shipDate", type = long.class)
, @Property(name = "status", type = String.class)
, @Property(name = "complete", type = boolean.class)
}
)
public class OrderVMD{
}

View File

@@ -1,23 +0,0 @@
package org.openapitools.client.model;
import java.util.List;
import net.java.html.json.ComputedProperty;
import net.java.html.json.Function;
import net.java.html.json.Model;
import net.java.html.json.ModelOperation;
import net.java.html.json.OnPropertyChange;
import net.java.html.json.OnReceive;
import net.java.html.json.Property;
@Model(className = "Pet", targetId = "", properties = {
@Property(name = "id", type = long.class)
, @Property(name = "category", type = Category.class)
, @Property(name = "name", type = String.class)
, @Property(name = "photoUrls", type = String.class, array=true)
, @Property(name = "tags", type = Tag.class, array=true)
, @Property(name = "status", type = String.class)
}
)
public class PetVMD{
}

View File

@@ -1,19 +0,0 @@
package org.openapitools.client.model;
import java.util.List;
import net.java.html.json.ComputedProperty;
import net.java.html.json.Function;
import net.java.html.json.Model;
import net.java.html.json.ModelOperation;
import net.java.html.json.OnPropertyChange;
import net.java.html.json.OnReceive;
import net.java.html.json.Property;
@Model(className = "Tag", targetId = "", properties = {
@Property(name = "id", type = long.class)
, @Property(name = "name", type = String.class)
}
)
public class TagVMD{
}

View File

@@ -1,25 +0,0 @@
package org.openapitools.client.model;
import java.util.List;
import net.java.html.json.ComputedProperty;
import net.java.html.json.Function;
import net.java.html.json.Model;
import net.java.html.json.ModelOperation;
import net.java.html.json.OnPropertyChange;
import net.java.html.json.OnReceive;
import net.java.html.json.Property;
@Model(className = "User", targetId = "", properties = {
@Property(name = "id", type = long.class)
, @Property(name = "username", type = String.class)
, @Property(name = "firstName", type = String.class)
, @Property(name = "lastName", type = String.class)
, @Property(name = "email", type = String.class)
, @Property(name = "password", type = String.class)
, @Property(name = "phone", type = String.class)
, @Property(name = "userStatus", type = int.class)
}
)
public class UserVMD{
}

View File

@@ -0,0 +1,2 @@
_build/
rebar.lock

View File

@@ -1 +1 @@
3.3.0-SNAPSHOT
3.3.2-SNAPSHOT

View File

@@ -0,0 +1,46 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools</groupId>
<artifactId>ErlangProperClientTests</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>Erlang Proper Petstore Client</name>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>compile-test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>rebar3</executable>
<arguments>
<argument>compile</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -4,4 +4,4 @@
{shell, [{apps, [petstore]}]}.
{plugins, [rebar3_proper]}.
{plugins, [rebar3_proper]}.

View File

@@ -4,6 +4,8 @@
-export([petstore_api_response/0]).
-export([petstore_api_response/1]).
-export_type([petstore_api_response/0]).
-type petstore_api_response() ::
@@ -12,8 +14,14 @@
| {'message', binary() }
].
petstore_api_response() ->
[ {'code', integer() }
, {'type', binary() }
, {'message', binary() }
].
petstore_api_response([]).
petstore_api_response(Fields) ->
Default = [ {'code', integer() }
, {'type', binary() }
, {'message', binary() }
],
lists:ukeymerge(1, lists:sort(Fields), lists:sort(Default)).

Some files were not shown because too many files have changed in this diff Show More