-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bruno Lopes
committed
Mar 11, 2019
0 parents
commit ab42941
Showing
34 changed files
with
4,196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# IntelliJ | ||
.idea/ | ||
out/ | ||
|
||
# Editor-based Rest Client | ||
.idea/httpRequests | ||
### Java template | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# OpenAPI Generator for the minderaswift4generator library | ||
|
||
## Overview | ||
This is a boiler-plate project to generate your own project derived from an OpenAPI specification. | ||
Its goal is to get you started with the basic plumbing so you can put in your own logic. | ||
It won't work without your changes applied. | ||
|
||
## What's OpenAPI | ||
The goal of OpenAPI is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. | ||
When properly described with OpenAPI, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. | ||
Similar to what interfaces have done for lower-level programming, OpenAPI removes the guesswork in calling the service. | ||
|
||
Check out [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) for additional information about the OpenAPI project, including additional libraries with support for other languages and more. | ||
|
||
## How do I use this? | ||
At this point, you've likely generated a client setup. It will include something along these lines: | ||
|
||
``` | ||
. | ||
|- README.md // this file | ||
|- pom.xml // build script | ||
|-- src | ||
|--- main | ||
|---- java | ||
|----- com/github/Mindera.MinderaSwift4GeneratorGenerator.java // generator file | ||
|---- resources | ||
|----- minderaswift4generator // template files | ||
|----- META-INF | ||
|------ services | ||
|------- org.openapitools.codegen.CodegenConfig | ||
``` | ||
|
||
You _will_ need to make changes in at least the following: | ||
|
||
`MinderaSwift4GeneratorGenerator.java` | ||
|
||
Templates in this folder: | ||
|
||
`src/main/resources/minderaswift4generator` | ||
|
||
Once modified, you can run this: | ||
|
||
``` | ||
mvn package | ||
``` | ||
|
||
In your generator project. A single jar file will be produced in `target`. You can now use that with [OpenAPI Generator](https://openapi-generator.tech): | ||
|
||
For mac/linux: | ||
``` | ||
java -cp /path/to/openapi-generator-cli.jar:/path/to/your.jar org.openapitools.codegen.OpenAPIGenerator generate -g minderaswift4generator -i /path/to/openapi.yaml -o ./test | ||
``` | ||
(Do not forget to replace the values `/path/to/openapi-generator-cli.jar`, `/path/to/your.jar` and `/path/to/openapi.yaml` in the previous command) | ||
|
||
For Windows users, you will need to use `;` instead of `:` in the classpath, e.g. | ||
``` | ||
java -cp /path/to/openapi-generator-cli.jar;/path/to/your.jar org.openapitools.codegen.OpenAPIGenerator generate -g minderaswift4generator -i /path/to/openapi.yaml -o ./test | ||
``` | ||
|
||
Now your templates are available to the client generator and you can write output values | ||
|
||
## But how do I modify this? | ||
The `MinderaSwift4GeneratorGenerator.java` has comments in it--lots of comments. There is no good substitute | ||
for reading the code more, though. See how the `MinderaSwift4GeneratorGenerator` implements `CodegenConfig`. | ||
That class has the signature of all values that can be overridden. | ||
|
||
For the templates themselves, you have a number of values available to you for generation. | ||
You can execute the `java` command from above while passing different debug flags to show | ||
the object you have available during client generation: | ||
|
||
``` | ||
# The following additional debug options are available for all codegen targets: | ||
# -DdebugOpenAPI prints the OpenAPI Specification as interpreted by the codegen | ||
# -DdebugModels prints models passed to the template engine | ||
# -DdebugOperations prints operations passed to the template engine | ||
# -DdebugSupportingFiles prints additional data passed to the template engine | ||
java -DdebugOperations -cp /path/to/openapi-generator-cli.jar:/path/to/your.jar org.openapitools.codegen.OpenAPIGenerator generate -g minderaswift4generator -i /path/to/openapi.yaml -o ./test | ||
``` | ||
|
||
Will, for example, output the debug info for operations. | ||
You can use this info in the `api.mustache` file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> | ||
<output url="file://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" /> | ||
<excludeFolder url="file://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.openapitools:openapi-generator:3.3.4" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.swagger.core.v3:swagger-core:2.0.4" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.xml.bind:jaxb-api:2.3.0" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.5" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.5" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.5" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.5" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.swagger.core.v3:swagger-annotations:2.0.4" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.swagger.core.v3:swagger-models:2.0.4" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.swagger.parser.v3:swagger-parser:2.0.4" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.swagger.parser.v3:swagger-parser-v2-converter:2.0.4" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.swagger:swagger-parser:1.0.38" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.swagger:swagger-core:1.5.21" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.swagger:swagger-models:1.5.21" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.swagger:swagger-annotations:1.5.21" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.swagger:swagger-compat-spec-parser:1.0.38" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.java-json-tools:json-schema-validator:2.2.8" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.java-json-tools:json-schema-core:1.2.8" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mozilla:rhino:1.7R4" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.fge:uri-template:0.9" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.mail:mailapi:1.4.3" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.activation:activation:1.1" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: joda-time:joda-time:2.9.7" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.libphonenumber:libphonenumber:8.0.0" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.jopt-simple:jopt-simple:5.0.3" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.fge:json-patch:1.6" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.fge:jackson-coreutils:1.6" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.fge:msg-simple:1.1" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.fge:btf:1.2" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpcore:4.4.4" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-logging:commons-logging:1.2" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.9" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.swagger.parser.v3:swagger-parser-core:2.0.4" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.swagger.parser.v3:swagger-parser-v3:2.0.4" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.samskivert:jmustache:1.14" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-io:commons-io:2.4" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-ext:1.7.12" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: ch.qos.cal10n:cal10n-api:0.8.1" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.12" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-lang3:3.4" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-cli:commons-cli:1.2" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:26.0-jre" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.checkerframework:checker-qual:2.5.2" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.errorprone:error_prone_annotations:2.1.3" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.atlassian.commonmark:commonmark:0.11.0" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.openapitools:openapi-generator:tests:3.3.4" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.testng:testng:6.9.6" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: com.google.inject:guice:no_aop:4.0" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: javax.inject:javax.inject:1" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: aopalliance:aopalliance:1.0" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.beanshell:bsh:2.0b4" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.apache.ant:ant:1.7.0" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.apache.ant:ant-launcher:1.7.0" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: com.beust:jcommander:1.48" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.15" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.10" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.jmockit:jmockit:1.43" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.github.mindera</groupId> | ||
<artifactId>mindera-openapi-generator</artifactId> | ||
<packaging>jar</packaging> | ||
<name>mindera-openapi-generator</name> | ||
<version>1.0.0</version> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-enforcer-plugin</artifactId> | ||
<version>3.0.0-M1</version> | ||
<executions> | ||
<execution> | ||
<id>enforce-maven</id> | ||
<goals> | ||
<goal>enforce</goal> | ||
</goals> | ||
<configuration> | ||
<rules> | ||
<requireMavenVersion> | ||
<version>2.2.0</version> | ||
</requireMavenVersion> | ||
</rules> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.12</version> | ||
<configuration> | ||
<systemProperties> | ||
<property> | ||
<name>loggerPath</name> | ||
<value>conf/log4j.properties</value> | ||
</property> | ||
</systemProperties> | ||
<argLine>-Xms512m -Xmx1500m</argLine> | ||
<parallel>methods</parallel> | ||
<forkMode>pertest</forkMode> | ||
</configuration> | ||
</plugin> | ||
|
||
<!-- attach test jar --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.2</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>jar</goal> | ||
<goal>test-jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<version>3.0.0</version> | ||
<executions> | ||
<execution> | ||
<id>add_sources</id> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>add-source</goal> | ||
</goals> | ||
<configuration> | ||
<sources> | ||
<source> | ||
src/main/java</source> | ||
</sources> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>add_test_sources</id> | ||
<phase>generate-test-sources</phase> | ||
<goals> | ||
<goal>add-test-source</goal> | ||
</goals> | ||
<configuration> | ||
<sources> | ||
<source> | ||
src/test/java</source> | ||
</sources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.6.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.openapitools</groupId> | ||
<artifactId>openapi-generator</artifactId> | ||
<version>${openapi-generator-version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openapitools</groupId> | ||
<artifactId>openapi-generator</artifactId> | ||
<version>${openapi-generator-version}</version> | ||
<classifier>tests</classifier> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>${testng-version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jmockit</groupId> | ||
<artifactId>jmockit</artifactId> | ||
<version>${jmockit-version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<properties> | ||
<jmockit-version>1.43</jmockit-version> | ||
<testng-version>6.9.6</testng-version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<openapi-generator-version>3.3.4</openapi-generator-version> | ||
<maven-plugin-version>1.0.0</maven-plugin-version> | ||
<junit-version>4.8.1</junit-version> | ||
</properties> | ||
</project> |
Oops, something went wrong.