dateformat templates added
This commit is contained in:
parent
a97be8fd65
commit
fcc3cc5bdd
|
|
@ -4,9 +4,10 @@
|
|||
package {{ packageName }}.api
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude
|
||||
import com.fasterxml.jackson.annotation.JsonFormat
|
||||
|
||||
import java.math.BigDecimal
|
||||
import org.joda.time.DateTime //TODO update
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
{%- if (description is not empty) %}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
{%- import '../../utils.twig' as utils -%}
|
||||
|
||||
{%- for field in fields %}
|
||||
{{ utils.writeInclusionAnnotation(field.nullable, field.optional) }}{%- if includeVal %}val {% endif %}{{ field.name }}: {{ utils.formatValueType(field.type.type, field.nullable, field.optional) }}{{ utils.writeNullCheckMark(field.nullable, field.optional) }} {%- if (not (loop.last)) or (addCommaAtTheEnd)%}, {% endif %}
|
||||
{%- if field.type.type.baseTypeName == "DateTime" %}
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssX", timezone = "UTC") //TODO use field format
|
||||
{%- endif %}
|
||||
{%- if field.nullable %}
|
||||
@JsonInclude(JsonInclude.Include.ALWAYS)
|
||||
{%- elseif field.optional %}
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
{%- endif %}
|
||||
{% if includeVal %}val {% endif %}{{ field.name }}: {{ utils.formatValueType(field.type.type, field.nullable, field.optional) }}{{ utils.writeNullCheckMark(field.nullable, field.optional) }} {%- if (not (loop.last)) or (addCommaAtTheEnd)%}, {% endif %}
|
||||
{%- endfor -%}
|
||||
|
|
@ -16,10 +16,18 @@
|
|||
{%- endif -%}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro includeDateFormat(valueType) %}
|
||||
{%- if valueType.baseTypeName == "DateTime" -%}
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ssX", timezone = "UTC")
|
||||
{%- endif -%}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro formatValueType(valueType, nullable, optional) %}
|
||||
{% import _self as self %}
|
||||
{%- if valueType.baseTypeName == "Bool" -%}
|
||||
Boolean
|
||||
{%- elseif valueType.baseTypeName == "DateTime" -%}
|
||||
ZonedDateTime
|
||||
{%- elseif valueType.baseTypeName == "Decimal" -%}
|
||||
BigDecimal
|
||||
{%- elseif valueType.baseTypeName == "Map" -%}
|
||||
|
|
|
|||
Loading…
Reference in New Issue