Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…rator into php-laravel
  • Loading branch information
renepardon committed Jul 18, 2018
2 parents 2a11fc4 + 1e59649 commit 7c0aa8c
Show file tree
Hide file tree
Showing 357 changed files with 622 additions and 1,391 deletions.
2 changes: 1 addition & 1 deletion CI/pom.xml.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<artifactId>openapi-generator-project</artifactId>
<packaging>pom</packaging>
<name>openapi-generator-project</name>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<url>https://github.com/openapi-tools/openapi-generator</url>
<scm>
<connection>scm:git:git@github.com:openapi-tools/openapi-generator.git</connection>
Expand Down
2 changes: 1 addition & 1 deletion CI/pom.xml.circleci
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<artifactId>openapi-generator-project</artifactId>
<packaging>pom</packaging>
<name>openapi-generator-project</name>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<url>https://github.com/openapitools/openapi-generator</url>
<scm>
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
Expand Down
2 changes: 1 addition & 1 deletion CI/pom.xml.circleci.java7
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<artifactId>openapi-generator-project</artifactId>
<packaging>pom</packaging>
<name>openapi-generator-project</name>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<url>https://github.com/openapitools/openapi-generator</url>
<scm>
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
Expand Down
2 changes: 1 addition & 1 deletion CI/pom.xml.ios
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<artifactId>openapi-generator-project</artifactId>
<packaging>pom</packaging>
<name>openapi-generator-project</name>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<url>https://github.com/openapitools/openapi-generator</url>
<scm>
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ OpenAPI Generator Version | Release Date | OpenAPI Spec compatibility | Notes
---------------------------- | ------------ | -------------------------- | -----
4.0.0 (upcoming major release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Major release with breaking changes (no fallback)
3.2.0 (upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.2.0-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release with breaking changes (with fallbacks)
3.1.1 (current master, upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.1.1-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
3.1.2-SNAPSHOT (current master, upcoming patch release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/3.1.2-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
[3.1.1](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.1.1) | 18.07.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
[3.1.0](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.1.0) | 06.07.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release with breaking changes (with fallbacks)
[3.0.3](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.3) | 27.06.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
[3.0.2](https://github.com/OpenAPITools/openapi-generator/releases/tag/v3.0.2) | 18.06.2018 | 1.0, 1.1, 1.2, 2.0, 3.0 | Bugfix release
Expand Down Expand Up @@ -144,16 +145,16 @@ See the different versions of the [openapi-generator-cli](https://mvnrepository.

If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):

JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.1.0/openapi-generator-cli-3.1.0.jar`
JAR location: `http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.1.1/openapi-generator-cli-3.1.1.jar`

For **Mac/Linux** users:
```sh
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.1.0/openapi-generator-cli-3.1.0.jar -O openapi-generator-cli.jar
wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.1.1/openapi-generator-cli-3.1.1.jar -O openapi-generator-cli.jar
```

For **Windows** users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g.
```
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.1.0/openapi-generator-cli-3.1.0.jar
Invoke-WebRequest -OutFile openapi-generator-cli.jar http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/3.1.1/openapi-generator-cli-3.1.1.jar
```

After downloading the JAR, run `java -jar openapi-generator-cli.jar help` to show the usage.
Expand Down Expand Up @@ -599,7 +600,7 @@ If you want to join the committee, please kindly apply by sending an email to te
| NodeJS/Javascript | @CodeNinjai (2017/07) @frol (2017/07) @cliffano (2017/07) |
| ObjC | |
| Perl | @wing328 (2017/07) |
| PHP | @jebentier (2017/07) @dkarlovi (2017/07) @mandrean (2017/08) @jfastnacht (2017/09) @ackintosh (2017/09) |
| PHP | @jebentier (2017/07) @dkarlovi (2017/07) @mandrean (2017/08) @jfastnacht (2017/09) @ackintosh (2017/09) @ybelenko (2018/07) |
| PowerShell | |
| Python | @taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11)|
| R | |
Expand Down
2 changes: 1 addition & 1 deletion bin/utils/ensure-up-to-date
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sleep 5
./bin/php-silex-petstore-server.sh > /dev/null 2>&1
./bin/php-symfony-petstore.sh > /dev/null 2>&1
./bin/php-lumen-petstore-server.sh > /dev/null 2>&1
./bin/php-slim-petstore-server.sh > /dev/null 2>&1
./bin/php-slim-server-petstore.sh > /dev/null 2>&1
./bin/php-ze-ph-petstore-server.sh > /dev/null 2>&1
./bin/openapi3/php-petstore.sh > /dev/null 2>&1
./bin/typescript-angular-petstore-all.sh > /dev/null 2>&1
Expand Down
4 changes: 2 additions & 2 deletions docs/migration-from-swagger-codegen.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ If your API client is using named parameters in the function call (e.g. Perl req

The following gnereators are not yet fully migrated and tested

- `rust-server`
- `apex`
- ~~rust-server~~ (migrated)
- `apex` (migration scheduled in Jul/Aug 2018)

and we welcome contributions from the community to help with the migration

Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-gradle-plugin/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "org.openapitools:openapi-generator-gradle-plugin:3.1.0"
classpath "org.openapitools:openapi-generator-gradle-plugin:3.1.1"
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-gradle-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
openApiGeneratorVersion=3.1.1-SNAPSHOT
openApiGeneratorVersion=3.1.2-SNAPSHOT

# BEGIN placeholders
# these are just placeholders to allow contributors to build directly
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-gradle-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ gradle buildGoSdk
The samples can be tested against other versions of the plugin using the `openApiGeneratorVersion` property. For example:

```bash
gradle -PopenApiGeneratorVersion=3.1.0 openApiValidate
gradle -PopenApiGeneratorVersion=3.1.1 openApiValidate
```
Original file line number Diff line number Diff line change
@@ -1 +1 @@
openApiGeneratorVersion=3.1.0
openApiGeneratorVersion=3.1.1
2 changes: 1 addition & 1 deletion modules/openapi-generator-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase)
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
<executions>
<execution>
<goals>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<artifactId>openapi-generator-maven-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-online/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM openjdk:8-jre-alpine

WORKDIR /generator

COPY target/openapi-generator-online-3.1.1-SNAPSHOT.jar /generator/openapi-generator-online.jar
COPY target/openapi-generator-online-3.1.2-SNAPSHOT.jar /generator/openapi-generator-online.jar

ENV GENERATOR_HOST=http://localhost

Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator-online/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<artifactId>openapi-generator-online</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/openapi-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public AbstractPhpCodegen() {
typeMapping.put("string", "string");
typeMapping.put("byte", "int");
typeMapping.put("boolean", "bool");
typeMapping.put("date", "\\DateTime");
typeMapping.put("Date", "\\DateTime");
typeMapping.put("DateTime", "\\DateTime");
typeMapping.put("file", "\\SplFileObject");
Expand Down Expand Up @@ -170,17 +171,25 @@ public void processOpts() {

if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) {
this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE));

// Update the invokerPackage for the default apiPackage and modelPackage
apiPackage = invokerPackage + "\\" + apiDirName;
modelPackage = invokerPackage + "\\" + modelDirName;
} else {
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
}

if (!additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);
if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) {
// Update model package to contain the specified model package name and the invoker package
modelPackage = invokerPackage + "\\" + (String) additionalProperties.get(CodegenConstants.MODEL_PACKAGE);
}
additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage);

if (!additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);
if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) {
// Update api package to contain the specified api package name and the invoker package
apiPackage = invokerPackage + "\\" + (String) additionalProperties.get(CodegenConstants.API_PACKAGE);
}
additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage);

// if (additionalProperties.containsKey(COMPOSER_PROJECT_NAME)) {
// this.setComposerProjectName((String) additionalProperties.get(COMPOSER_PROJECT_NAME));
Expand Down Expand Up @@ -329,7 +338,7 @@ public String getTypeDeclaration(Schema p) {
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = (Schema) p.getAdditionalProperties();
return getSchemaType(p) + "[string," + getTypeDeclaration(inner) + "]";
} else if (!StringUtils.isEmpty(p.get$ref())) { // model
} else if (StringUtils.isNotBlank(p.get$ref())) { // model
String type = super.getTypeDeclaration(p);
return (!languageSpecificPrimitives.contains(type))
? "\\" + modelPackage + "\\" + type : type;
Expand Down Expand Up @@ -542,11 +551,11 @@ public void setParameterExampleValue(CodegenParameter p) {
type = p.dataType;
}

if ("String".equalsIgnoreCase(type)) {
if ("String".equalsIgnoreCase(type) || p.isString) {
if (example == null) {
example = p.paramName + "_example";
example = "'" + p.paramName + "_example'";
}
example = "\"" + escapeText(example) + "\"";
example = escapeText(example);
} else if ("Integer".equals(type) || "int".equals(type)) {
if (example == null) {
example = "56";
Expand All @@ -559,21 +568,23 @@ public void setParameterExampleValue(CodegenParameter p) {
if (example == null) {
example = "True";
}
} else if ("\\SplFileObject".equalsIgnoreCase(type)) {
} else if ("\\SplFileObject".equalsIgnoreCase(type) || p.isFile) {
if (example == null) {
example = "/path/to/file";
example = "/path/to/file.txt";
}
example = "\"" + escapeText(example) + "\"";
} else if ("Date".equalsIgnoreCase(type)) {
} else if ("\\Date".equalsIgnoreCase(type)) {
if (example == null) {
example = "2013-10-20";
}
example = "new \\DateTime(\"" + escapeText(example) + "\")";
} else if ("DateTime".equalsIgnoreCase(type)) {
} else if ("\\DateTime".equalsIgnoreCase(type)) {
if (example == null) {
example = "2013-10-20T19:20:30+01:00";
}
example = "new \\DateTime(\"" + escapeText(example) + "\")";
} else if ("object".equals(type)) {
example = "new \\stdClass";
} else if (!languageSpecificPrimitives.contains(type)) {
// type is a model class, e.g. User
example = "new " + getTypeDeclaration(type) + "()";
Expand Down Expand Up @@ -631,8 +642,8 @@ public String toEnumVarName(String name, String datatype) {
enumName = enumName.replaceFirst("^_", "");
enumName = enumName.replaceFirst("_$", "");

if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
if (isReservedWord(enumName) || enumName.matches("\\d.*")) { // reserved word or starts with number
return escapeReservedWord(enumName);
} else {
return enumName;
}
Expand All @@ -642,6 +653,9 @@ public String toEnumVarName(String name, String datatype) {
public String toEnumName(CodegenProperty property) {
String enumName = underscore(toModelName(property.name)).toUpperCase();

// remove [] for array or map of enum
enumName = enumName.replace("[]", "");

if (enumName.matches("\\d.*")) { // starts with number
return "_" + enumName;
} else {
Expand All @@ -660,6 +674,8 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
// for API test method name
// e.g. public function test{{vendorExtensions.x-testOperationId}}()
op.vendorExtensions.put("x-testOperationId", camelize(op.operationId));
}
return objs;
Expand All @@ -673,7 +689,17 @@ public String escapeQuotationMark(String input) {

@Override
public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "");
return input.replace("*/", "*_/").replace("/*", "/_*");
}

@Override
public String escapeText(String input) {
if (input == null) {
return input;
}

// Trim the string to avoid leading and trailing spaces.
return super.escapeText(input).trim();
}

protected String extractSimpleName(String phpClassName) {
Expand Down
Loading

0 comments on commit 7c0aa8c

Please sign in to comment.