Skip to content

Commit

Permalink
Generate java spring OAS2 (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmini authored Apr 24, 2018
1 parent e0b0248 commit 949ef44
Show file tree
Hide file tree
Showing 200 changed files with 2,640 additions and 2,254 deletions.
2 changes: 1 addition & 1 deletion bin/spring-delegate-j8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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"
ags="$@ generate -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot-delegate-j8 -DdelegatePattern=true,hideGenerationTimestamp=true,java8=true"
ags="$@ generate --artifact-id springboot-delegate-j8 -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot-delegate-j8 -DdelegatePattern=true,hideGenerationTimestamp=true,java8=true"

echo "Removing files and folders under samples/server/petstore/springboot-delegate-j8/src/main"
rm -rf samples/server/petstore/springboot-delegate-j8/src/main
Expand Down
2 changes: 1 addition & 1 deletion bin/spring-delegate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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"
ags="$@ generate -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot-delegate -DdelegatePattern=true,hideGenerationTimestamp=true"
ags="$@ generate --artifact-id springboot-delegate -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot-delegate -DdelegatePattern=true,hideGenerationTimestamp=true"

echo "Removing files and folders under samples/server/petstore/springboot-delegate/src/main"
rm -rf samples/server/petstore/springboot-delegate/src/main
Expand Down
2 changes: 1 addition & 1 deletion bin/spring-stubs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ 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 -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l spring -o samples/client/petstore/spring-stubs -DinterfaceOnly=true,singleContentTypes=true,hideGenerationTimestamp=true"
ags="$@ generate --artifact-id spring-stubs -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l spring -o samples/client/petstore/spring-stubs -DinterfaceOnly=true,singleContentTypes=true,hideGenerationTimestamp=true"

java $JAVA_OPTS -jar $executable $ags
2 changes: 1 addition & 1 deletion bin/springboot-petstore-server-implicitHeaders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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"
ags="$@ generate -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -c bin/springboot-petstore-server-implicitHeaders.json -o samples/server/petstore/springboot-implicitHeaders -DhideGenerationTimestamp=true"
ags="$@ generate --artifact-id springboot-implicitHeaders -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -c bin/springboot-petstore-server-implicitHeaders.json -o samples/server/petstore/springboot-implicitHeaders -DhideGenerationTimestamp=true"

echo "Removing files and folders under samples/server/petstore/springboot-implicitHeaders/src/main"
rm -rf samples/server/petstore/springboot-implicitHeaders/src/main
Expand Down
2 changes: 1 addition & 1 deletion bin/springboot-petstore-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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"
ags="generate -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot -DhideGenerationTimestamp=true $@"
ags="generate --artifact-id springboot -t modules/openapi-generator/src/main/resources/JavaSpring -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l spring -o samples/server/petstore/springboot -DhideGenerationTimestamp=true $@"

echo "Removing files and folders under samples/server/petstore/springboot/src/main"
rm -rf samples/server/petstore/springboot/src/main
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# 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 Swagger Codgen to ignore just this file by uncommenting the following line:
# 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 (*):
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.0-SNAPSHOT
3.0.0-SNAPSHOT
10 changes: 5 additions & 5 deletions samples/client/petstore/spring-cloud/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# swagger-petstore-spring-cloud
# petstore-spring-cloud

## Requirements

Expand Down Expand Up @@ -26,8 +26,8 @@ Add this dependency to your project's POM:

```xml
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-petstore-spring-cloud</artifactId>
<groupId>org.openapitools</groupId>
<artifactId>petstore-spring-cloud</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
Expand All @@ -38,7 +38,7 @@ Add this dependency to your project's POM:
Add this dependency to your project's build file:

```groovy
compile "io.swagger:swagger-petstore-spring-cloud:1.0.0"
compile "org.openapitools:petstore-spring-cloud:1.0.0"
```

### Others
Expand All @@ -49,5 +49,5 @@ mvn package

Then manually install the following JARs:

* target/swagger-petstore-spring-cloud-1.0.0.jar
* target/petstore-spring-cloud-1.0.0.jar
* target/lib/*.jar
6 changes: 3 additions & 3 deletions samples/client/petstore/spring-cloud/pom.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<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>io.swagger</groupId>
<artifactId>swagger-petstore-spring-cloud</artifactId>
<groupId>org.openapitools</groupId>
<artifactId>petstore-spring-cloud</artifactId>
<packaging>jar</packaging>
<name>swagger-petstore-spring-cloud</name>
<name>petstore-spring-cloud</name>
<version>1.0.0</version>
<properties>
<java.version>1.7</java.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.4.0-SNAPSHOT).
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
Expand Down Expand Up @@ -36,10 +36,9 @@ public interface PetApi {
@ApiResponses(value = {
@ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "/pet",
produces = "application/json",
consumes = "application/json",
method = RequestMethod.POST)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet);


@ApiOperation(value = "Deletes a pet", nickname = "deletePet", notes = "", authorizations = {
Expand All @@ -51,7 +50,6 @@ public interface PetApi {
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid pet value") })
@RequestMapping(value = "/pet/{petId}",
produces = "application/json",
method = RequestMethod.DELETE)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey);

Expand Down Expand Up @@ -110,10 +108,9 @@ public interface PetApi {
@ApiResponse(code = 404, message = "Pet not found"),
@ApiResponse(code = 405, message = "Validation exception") })
@RequestMapping(value = "/pet",
produces = "application/json",
consumes = "application/json",
method = RequestMethod.PUT)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet body);
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody Pet pet);


@ApiOperation(value = "Updates a pet in the store with form data", nickname = "updatePetWithForm", notes = "", authorizations = {
Expand All @@ -125,7 +122,6 @@ public interface PetApi {
@ApiResponses(value = {
@ApiResponse(code = 405, message = "Invalid input") })
@RequestMapping(value = "/pet/{petId}",
produces = "application/json",
consumes = "application/x-www-form-urlencoded",
method = RequestMethod.POST)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathVariable("petId") Long petId,@ApiParam(value = "Updated name of the pet" ) @RequestParam(value="name", required=false) String name,@ApiParam(value = "Updated status of the pet" ) @RequestParam(value="status", required=false) String status);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.4.0-SNAPSHOT).
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
Expand Down Expand Up @@ -31,7 +31,6 @@ public interface StoreApi {
@ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "Order not found") })
@RequestMapping(value = "/store/order/{orderId}",
produces = "application/json",
method = RequestMethod.DELETE)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathVariable("orderId") String orderId);

Expand All @@ -55,7 +54,7 @@ public interface StoreApi {
@RequestMapping(value = "/store/order/{orderId}",
produces = "application/json",
method = RequestMethod.GET)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Order>> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathVariable("orderId") Long orderId);
com.netflix.hystrix.HystrixCommand<ResponseEntity<Order>> getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched",required=true, allowableValues = "") @PathVariable("orderId") Long orderId);


@ApiOperation(value = "Place an order for a pet", nickname = "placeOrder", notes = "", response = Order.class, tags={ "store", })
Expand All @@ -65,6 +64,6 @@ public interface StoreApi {
@RequestMapping(value = "/store/order",
produces = "application/json",
method = RequestMethod.POST)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Order>> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order body);
com.netflix.hystrix.HystrixCommand<ResponseEntity<Order>> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody Order order);

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.4.0-SNAPSHOT).
* NOTE: This class is auto generated by the swagger code generator program (3.0.0-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
Expand Down Expand Up @@ -30,35 +30,31 @@ public interface UserApi {
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") })
@RequestMapping(value = "/user",
produces = "application/json",
method = RequestMethod.POST)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User body);
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody User user);


@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithArrayInput", notes = "", tags={ "user", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") })
@RequestMapping(value = "/user/createWithArray",
produces = "application/json",
method = RequestMethod.POST)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body);
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user);


@ApiOperation(value = "Creates list of users with given input array", nickname = "createUsersWithListInput", notes = "", tags={ "user", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") })
@RequestMapping(value = "/user/createWithList",
produces = "application/json",
method = RequestMethod.POST)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> body);
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody List<User> user);


@ApiOperation(value = "Delete user", nickname = "deleteUser", notes = "This can only be done by the logged in user.", tags={ "user", })
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid username supplied"),
@ApiResponse(code = 404, message = "User not found") })
@RequestMapping(value = "/user/{username}",
produces = "application/json",
method = RequestMethod.DELETE)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathVariable("username") String username);

Expand Down Expand Up @@ -88,7 +84,6 @@ public interface UserApi {
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") })
@RequestMapping(value = "/user/logout",
produces = "application/json",
method = RequestMethod.GET)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> logoutUser();

Expand All @@ -98,8 +93,7 @@ public interface UserApi {
@ApiResponse(code = 400, message = "Invalid user supplied"),
@ApiResponse(code = 404, message = "User not found") })
@RequestMapping(value = "/user/{username}",
produces = "application/json",
method = RequestMethod.PUT)
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User body);
com.netflix.hystrix.HystrixCommand<ResponseEntity<Void>> updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathVariable("username") String username,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody User user);

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# 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 Swagger Codgen to ignore just this file by uncommenting the following line:
# 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 (*):
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.0-SNAPSHOT
3.0.0-SNAPSHOT
28 changes: 11 additions & 17 deletions samples/client/petstore/spring-stubs/pom.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<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>io.swagger</groupId>
<artifactId>swagger-spring</artifactId>
<groupId>org.openapitools</groupId>
<artifactId>spring-stubs</artifactId>
<packaging>jar</packaging>
<name>swagger-spring</name>
<name>spring-stubs</name>
<version>1.0.0</version>
<properties>
<java.version>1.7</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<springfox-version>2.6.1</springfox-version>
<springfox-version>2.7.0</springfox-version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.7.RELEASE</version>
<version>1.5.9.RELEASE</version>
</parent>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
Expand All @@ -27,7 +27,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!--SpringFox dependencies -->
<dependency>
Expand All @@ -42,19 +41,14 @@
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<groupId>com.github.joschi.jackson</groupId>
<artifactId>jackson-datatype-threetenbp</artifactId>
<version>2.6.4</version>
</dependency>
<!-- Bean Validation API support -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit 949ef44

Please sign in to comment.