forked from swagger-api/swagger-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jaxrs jersey2 support (swagger-api#5058)
* [JAVA/] jaxrs/jersey2 (Issue: 4662) Made java8-date codegeneration to work with jersey2 * Ran shellscripts for jaxrs-jersey-petstore-server and java8-petstore-jersey2 to update petstore samples
- Loading branch information
Showing
5 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions
28
...swagger-codegen/src/main/resources/JavaJaxRS/libraries/jersey2/LocalDateProvider.mustache
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,28 @@ | ||
package {{apiPackage}}; | ||
|
||
import javax.ws.rs.ext.ParamConverter; | ||
import javax.ws.rs.ext.ParamConverterProvider; | ||
import javax.ws.rs.ext.Provider; | ||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Type; | ||
import java.time.LocalDate; | ||
|
||
@Provider | ||
public class LocalDateProvider implements ParamConverterProvider { | ||
public <T> ParamConverter<T> getConverter(Class<T> clazz, Type type, Annotation[] annotations) { | ||
if (clazz.getName().equals(LocalDate.class.getName())) { | ||
return new ParamConverter<T>() { | ||
@SuppressWarnings("unchecked") | ||
public T fromString(String value) { | ||
return value!=null ? (T) LocalDate.parse(value) : null; | ||
} | ||
|
||
public String toString(T bean) { | ||
return bean!=null ? bean.toString() : ""; | ||
} | ||
}; | ||
} | ||
return null; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...er-codegen/src/main/resources/JavaJaxRS/libraries/jersey2/OffsetDateTimeProvider.mustache
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,28 @@ | ||
package {{apiPackage}}; | ||
|
||
import javax.ws.rs.ext.ParamConverter; | ||
import javax.ws.rs.ext.ParamConverterProvider; | ||
import javax.ws.rs.ext.Provider; | ||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Type; | ||
import java.time.OffsetDateTime; | ||
|
||
@Provider | ||
public class OffsetDateTimeProvider implements ParamConverterProvider { | ||
public <T> ParamConverter<T> getConverter(Class<T> clazz, Type type, Annotation[] annotations) { | ||
if (clazz.getName().equals(OffsetDateTime.class.getName())) { | ||
return new ParamConverter<T>() { | ||
@SuppressWarnings("unchecked") | ||
public T fromString(String value) { | ||
return value != null ? (T) OffsetDateTime.parse(value) : null; | ||
} | ||
|
||
public String toString(T bean) { | ||
return bean != null ? bean.toString() : ""; | ||
} | ||
}; | ||
} | ||
return null; | ||
} | ||
} |
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 @@ | ||
Hello world! |