swagger.yaml :: How to generate properties with “Long” data type and “Timestamp” datatype?
up vote
2
down vote
favorite
I am using swagger-codegen-maven-plugin
to generate Java classes based on swagger.yaml
spec.
I have added a property phoneNum
in the swagger.yaml
as below:
phoneNum:
type: number
I am expecting it generate the property with Integer
or Long
datatype.
But it got generated as BigDecimal phoneNum;
As per the swagger docs, it was mentioned to use format: int64
phoneNum:
type: number
format: int64
But still, it ends up generating private BigDecimal phoneNum;
If anyone of you have faced similar issue and have a workaround, please share it here.
Thank you.
java swagger swagger-codegen swagger-editor
New contributor
add a comment |
up vote
2
down vote
favorite
I am using swagger-codegen-maven-plugin
to generate Java classes based on swagger.yaml
spec.
I have added a property phoneNum
in the swagger.yaml
as below:
phoneNum:
type: number
I am expecting it generate the property with Integer
or Long
datatype.
But it got generated as BigDecimal phoneNum;
As per the swagger docs, it was mentioned to use format: int64
phoneNum:
type: number
format: int64
But still, it ends up generating private BigDecimal phoneNum;
If anyone of you have faced similar issue and have a workaround, please share it here.
Thank you.
java swagger swagger-codegen swagger-editor
New contributor
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I am using swagger-codegen-maven-plugin
to generate Java classes based on swagger.yaml
spec.
I have added a property phoneNum
in the swagger.yaml
as below:
phoneNum:
type: number
I am expecting it generate the property with Integer
or Long
datatype.
But it got generated as BigDecimal phoneNum;
As per the swagger docs, it was mentioned to use format: int64
phoneNum:
type: number
format: int64
But still, it ends up generating private BigDecimal phoneNum;
If anyone of you have faced similar issue and have a workaround, please share it here.
Thank you.
java swagger swagger-codegen swagger-editor
New contributor
I am using swagger-codegen-maven-plugin
to generate Java classes based on swagger.yaml
spec.
I have added a property phoneNum
in the swagger.yaml
as below:
phoneNum:
type: number
I am expecting it generate the property with Integer
or Long
datatype.
But it got generated as BigDecimal phoneNum;
As per the swagger docs, it was mentioned to use format: int64
phoneNum:
type: number
format: int64
But still, it ends up generating private BigDecimal phoneNum;
If anyone of you have faced similar issue and have a workaround, please share it here.
Thank you.
java swagger swagger-codegen swagger-editor
java swagger swagger-codegen swagger-editor
New contributor
New contributor
New contributor
asked 2 days ago
snmaddula
917
917
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
In order to generate a Long
property you have to use integer
as type and int64
as format
phoneNum:
type: integer
format: int64
Looking at AbstractJavaCodegen I think there is no way to generate a Timestamp
property.
The only available types are:
org.threeten.bp.LocalDate
org.threeten.bp.OffsetDateTime
org.joda.time.LocalDate
org.joda.time.DateTime
java.time.LocalDate
java.time.LocalDateTime
java.time.OffsetDateTime
java.util.Date
Here's a way to convert OffsetDateTime to Timestamp
OffsetDateTime dateTime = OffsetDateTime.now();
Timestamp timestamp = Timestamp.valueOf(dateTime.atZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
In order to generate a Long
property you have to use integer
as type and int64
as format
phoneNum:
type: integer
format: int64
Looking at AbstractJavaCodegen I think there is no way to generate a Timestamp
property.
The only available types are:
org.threeten.bp.LocalDate
org.threeten.bp.OffsetDateTime
org.joda.time.LocalDate
org.joda.time.DateTime
java.time.LocalDate
java.time.LocalDateTime
java.time.OffsetDateTime
java.util.Date
Here's a way to convert OffsetDateTime to Timestamp
OffsetDateTime dateTime = OffsetDateTime.now();
Timestamp timestamp = Timestamp.valueOf(dateTime.atZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
add a comment |
up vote
1
down vote
accepted
In order to generate a Long
property you have to use integer
as type and int64
as format
phoneNum:
type: integer
format: int64
Looking at AbstractJavaCodegen I think there is no way to generate a Timestamp
property.
The only available types are:
org.threeten.bp.LocalDate
org.threeten.bp.OffsetDateTime
org.joda.time.LocalDate
org.joda.time.DateTime
java.time.LocalDate
java.time.LocalDateTime
java.time.OffsetDateTime
java.util.Date
Here's a way to convert OffsetDateTime to Timestamp
OffsetDateTime dateTime = OffsetDateTime.now();
Timestamp timestamp = Timestamp.valueOf(dateTime.atZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
In order to generate a Long
property you have to use integer
as type and int64
as format
phoneNum:
type: integer
format: int64
Looking at AbstractJavaCodegen I think there is no way to generate a Timestamp
property.
The only available types are:
org.threeten.bp.LocalDate
org.threeten.bp.OffsetDateTime
org.joda.time.LocalDate
org.joda.time.DateTime
java.time.LocalDate
java.time.LocalDateTime
java.time.OffsetDateTime
java.util.Date
Here's a way to convert OffsetDateTime to Timestamp
OffsetDateTime dateTime = OffsetDateTime.now();
Timestamp timestamp = Timestamp.valueOf(dateTime.atZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
In order to generate a Long
property you have to use integer
as type and int64
as format
phoneNum:
type: integer
format: int64
Looking at AbstractJavaCodegen I think there is no way to generate a Timestamp
property.
The only available types are:
org.threeten.bp.LocalDate
org.threeten.bp.OffsetDateTime
org.joda.time.LocalDate
org.joda.time.DateTime
java.time.LocalDate
java.time.LocalDateTime
java.time.OffsetDateTime
java.util.Date
Here's a way to convert OffsetDateTime to Timestamp
OffsetDateTime dateTime = OffsetDateTime.now();
Timestamp timestamp = Timestamp.valueOf(dateTime.atZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
answered yesterday
Ruben DG
37328
37328
add a comment |
add a comment |
snmaddula is a new contributor. Be nice, and check out our Code of Conduct.
snmaddula is a new contributor. Be nice, and check out our Code of Conduct.
snmaddula is a new contributor. Be nice, and check out our Code of Conduct.
snmaddula is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235812%2fswagger-yaml-how-to-generate-properties-with-long-data-type-and-timestamp%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password