forked from swagger-api/swagger-codegen-generators
-
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.
Merge pull request swagger-api#517 from crazyk2/local_date_issues
Local date issues
- Loading branch information
Showing
16 changed files
with
137 additions
and
82 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
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
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
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
8 changes: 4 additions & 4 deletions
8
src/main/resources/handlebars/kotlin-client/enum_class.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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/** | ||
* {{{description}}} | ||
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^@last}},{{/@last}}{{/enumVars}}{{/allowableValues}} | ||
*/ | ||
* {{{description}}} | ||
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^@last}},{{/@last}}{{/enumVars}}{{/allowableValues}} | ||
*/ | ||
enum class {{classname}}(val value: {{dataType}}){ | ||
{{#allowableValues}}{{#enumVars}} | ||
{{&name}}({{{value}}}){{^@last}},{{/@last}}{{#@last}};{{/@last}} | ||
{{/enumVars}}{{/allowableValues}} | ||
} | ||
} |
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
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
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
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
24 changes: 24 additions & 0 deletions
24
src/main/resources/handlebars/kotlin-client/infrastructure/LocalDateAdapter.kt.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,24 @@ | ||
package {{packageName}}.infrastructure | ||
|
||
import com.squareup.moshi.FromJson | ||
import com.squareup.moshi.ToJson | ||
{{^threetenbp}} | ||
import java.time.LocalDate | ||
import java.time.format.DateTimeFormatter | ||
{{/threetenbp}} | ||
{{#threetenbp}} | ||
import org.threeten.bp.LocalDate | ||
import org.threeten.bp.format.DateTimeFormatter | ||
{{/threetenbp}} | ||
|
||
class LocalDateAdapter { | ||
@ToJson | ||
fun toJson(value: LocalDate): String { | ||
return DateTimeFormatter.ISO_LOCAL_DATE.format(value) | ||
} | ||
|
||
@FromJson | ||
fun fromJson(value: String): LocalDate { | ||
return LocalDate.parse(value, DateTimeFormatter.ISO_LOCAL_DATE_TIME) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/resources/handlebars/kotlin-client/infrastructure/LocalDateTimeAdapter.kt.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,25 @@ | ||
package {{packageName}}.infrastructure | ||
|
||
import com.squareup.moshi.FromJson | ||
import com.squareup.moshi.ToJson | ||
{{^threetenbp}} | ||
import java.time.LocalDateTime | ||
import java.time.format.DateTimeFormatter | ||
{{/threetenbp}} | ||
{{#threetenbp}} | ||
import org.threeten.bp.LocalDateTime | ||
import org.threeten.bp.format.DateTimeFormatter | ||
{{/threetenbp}} | ||
|
||
class LocalDateTimeAdapter { | ||
@ToJson | ||
fun toJson(value: LocalDateTime): String { | ||
return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(value) | ||
} | ||
|
||
@FromJson | ||
fun fromJson(value: String): LocalDateTime { | ||
return LocalDateTime.parse(value, DateTimeFormatter.ISO_LOCAL_DATE_TIME) | ||
} | ||
|
||
} |
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
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
10 changes: 6 additions & 4 deletions
10
src/main/resources/handlebars/kotlin-client/infrastructure/Serializer.kt.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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
package {{packageName}}.infrastructure | ||
|
||
import com.squareup.moshi.KotlinJsonAdapterFactory | ||
import com.squareup.moshi.Moshi | ||
import com.squareup.moshi.Rfc3339DateJsonAdapter | ||
import java.util.* | ||
import com.squareup.moshi.adapters.Rfc3339DateJsonAdapter | ||
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory | ||
import java.util.Date | ||
|
||
object Serializer { | ||
@JvmStatic | ||
val moshi: Moshi = Moshi.Builder() | ||
.add(KotlinJsonAdapterFactory()) | ||
.add(Date::class.java, Rfc3339DateJsonAdapter().nullSafe()) | ||
.add(LocalDateTimeAdapter()) | ||
.add(LocalDateAdapter()) | ||
.build() | ||
} | ||
} |
20 changes: 10 additions & 10 deletions
20
src/main/resources/handlebars/kotlin-client/licenseInfo.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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
/** | ||
* {{{appName}}} | ||
* {{{appDescription}}} | ||
* | ||
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}} | ||
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator program. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
* {{{appName}}} | ||
* {{{appDescription}}} | ||
* | ||
* {{#version}}OpenAPI spec version: {{{version}}}{{/version}} | ||
* {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator program. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ |
Oops, something went wrong.