Skip to content

Commit

Permalink
update spring config to use java8 (#7308)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 authored Aug 28, 2020
1 parent 08fe44c commit 1f95199
Show file tree
Hide file tree
Showing 71 changed files with 973 additions and 2,068 deletions.
2 changes: 1 addition & 1 deletion bin/configs/spring-boot-delegate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ templateDir: modules/openapi-generator/src/main/resources/JavaSpring
additionalProperties:
artifactId: springboot-delegate
hideGenerationTimestamp: "true"
java8: "false"
java8: true
delegatePattern: "true"
2 changes: 1 addition & 1 deletion bin/configs/spring-mvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ library: spring-mvc
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
additionalProperties:
java8: "false"
java8: true
booleanGetterPrefix: get
artifactId: spring-mvc-server
hideGenerationTimestamp: "true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ src/main/java/org/openapitools/api/StoreApi.java
src/main/java/org/openapitools/api/StoreApiController.java
src/main/java/org/openapitools/api/UserApi.java
src/main/java/org/openapitools/api/UserApiController.java
src/main/java/org/openapitools/configuration/CustomInstantDeserializer.java
src/main/java/org/openapitools/configuration/HomeController.java
src/main/java/org/openapitools/configuration/OpenAPIDocumentationConfig.java
src/main/java/org/openapitools/configuration/OpenAPIUiConfiguration.java
Expand Down
8 changes: 4 additions & 4 deletions samples/server/petstore/spring-mvc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@
<version>${springfox-version}</version>
</dependency>
<dependency>
<groupId>com.github.joschi.jackson</groupId>
<artifactId>jackson-datatype-threetenbp</artifactId>
<version>${jackson-threetenbp-version}</version>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
Expand All @@ -152,7 +152,7 @@
</dependency>
</dependencies>
<properties>
<java.version>1.7</java.version>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<jetty-version>9.2.15.v20160210</jetty-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,28 @@

import org.openapitools.model.Client;
import io.swagger.annotations.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Api(value = "another-fake", description = "the another-fake API")
public interface AnotherFakeApi {

default Optional<NativeWebRequest> getRequest() {
return Optional.empty();
}

/**
* PATCH /another-fake/dummy : To test special tags
* To test special tags and operation ID starting with number
Expand All @@ -36,6 +44,18 @@ public interface AnotherFakeApi {
produces = { "application/json" },
consumes = { "application/json" }
)
ResponseEntity<Client> call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body);
default ResponseEntity<Client> call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
getRequest().ifPresent(request -> {
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
String exampleString = "{ \"client\" : \"client\" }";
ApiUtil.setExampleResponse(request, "application/json", exampleString);
break;
}
}
});
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);

}

}
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
package org.openapitools.api;

import org.openapitools.model.Client;
import io.swagger.annotations.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Controller
@RequestMapping("${openapi.openAPIPetstore.base-path:/}")
Expand All @@ -32,24 +16,9 @@ public AnotherFakeApiController(NativeWebRequest request) {
this.request = request;
}

/**
* PATCH /another-fake/dummy : To test special tags
* To test special tags and operation ID starting with number
*
* @param body client model (required)
* @return successful operation (status code 200)
* @see AnotherFakeApi#call123testSpecialTags
*/
public ResponseEntity<Client> call123testSpecialTags(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body) {
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
String exampleString = "{ \"client\" : \"client\" }";
ApiUtil.setExampleResponse(request, "application/json", exampleString);
break;
}
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);

@Override
public Optional<NativeWebRequest> getRequest() {
return Optional.ofNullable(request);
}

}
Loading

0 comments on commit 1f95199

Please sign in to comment.