mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-10 10:56:09 +00:00
[Java] Threetenbp dates support (#4029)
* [feign] add threetenbp support for feign clients * [okhttp] add threetenbp support for okhttp clients * [jersey] add threetenbp support for jersey clients * [retrofit2] add threetenbp support for retrofit2 clients * [spring] add threetenbp support for spring generators * add a workaround in tests for a bug in the petstore The petstore doesn't manage fractional digits of dates correctly when there are less than 3
This commit is contained in:
committed by
wing328
parent
c1e6f00242
commit
70d93883cf
@@ -93,6 +93,12 @@
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>${springfox-version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
@@ -126,8 +132,8 @@
|
||||
<slf4j-version>1.7.21</slf4j-version>
|
||||
<junit-version>4.12</junit-version>
|
||||
<servlet-api-version>2.5</servlet-api-version>
|
||||
<springfox-version>2.4.0</springfox-version>
|
||||
<jackson-version>2.4.5</jackson-version>
|
||||
<springfox-version>2.6.0</springfox-version>
|
||||
<jackson-version>2.6.4</jackson-version>
|
||||
<spring-version>4.2.5.RELEASE</spring-version>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
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.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
||||
@Api(value = "fake_classname_test", description = "the fake_classname_test API")
|
||||
public interface FakeClassnameTestApi {
|
||||
|
||||
@ApiOperation(value = "To test class name in snake case", notes = "", response = Client.class, tags={ "fake_classname_tags 123#$%^", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Client.class) })
|
||||
@RequestMapping(value = "/fake_classname_test",
|
||||
produces = { "application/json" },
|
||||
consumes = { "application/json" },
|
||||
method = RequestMethod.PATCH)
|
||||
default CompletableFuture<ResponseEntity<Client>> testClassname(@ApiParam(value = "client model" ,required=true ) @RequestBody Client body) {
|
||||
// do some magic!
|
||||
return CompletableFuture.completedFuture(new ResponseEntity<Client>(HttpStatus.OK));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
|
||||
|
||||
@Controller
|
||||
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
|
||||
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
|
||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
|
||||
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
|
||||
.dateFormat( new RFC3339DateFormat())
|
||||
.dateFormat(new RFC3339DateFormat())
|
||||
.build();
|
||||
converters.add(new MappingJackson2HttpMessageConverter(objectMapper));
|
||||
super.configureMessageConverters(converters);
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* FormatTest
|
||||
@@ -48,7 +49,7 @@ public class FormatTest {
|
||||
private OffsetDateTime dateTime = null;
|
||||
|
||||
@JsonProperty("uuid")
|
||||
private String uuid = null;
|
||||
private UUID uuid = null;
|
||||
|
||||
@JsonProperty("password")
|
||||
private String password = null;
|
||||
@@ -261,7 +262,7 @@ public class FormatTest {
|
||||
this.dateTime = dateTime;
|
||||
}
|
||||
|
||||
public FormatTest uuid(String uuid) {
|
||||
public FormatTest uuid(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
return this;
|
||||
}
|
||||
@@ -271,11 +272,11 @@ public class FormatTest {
|
||||
* @return uuid
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public String getUuid() {
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
public void setUuid(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.time.OffsetDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* MixedPropertiesAndAdditionalPropertiesClass
|
||||
@@ -17,7 +18,7 @@ import java.util.Map;
|
||||
|
||||
public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
@JsonProperty("uuid")
|
||||
private String uuid = null;
|
||||
private UUID uuid = null;
|
||||
|
||||
@JsonProperty("dateTime")
|
||||
private OffsetDateTime dateTime = null;
|
||||
@@ -25,7 +26,7 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
@JsonProperty("map")
|
||||
private Map<String, Animal> map = new HashMap<String, Animal>();
|
||||
|
||||
public MixedPropertiesAndAdditionalPropertiesClass uuid(String uuid) {
|
||||
public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
return this;
|
||||
}
|
||||
@@ -35,11 +36,11 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
* @return uuid
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public String getUuid() {
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
public void setUuid(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user