Skip to content

[JAVA] Incorrect display of date-time in UI #2991

Description

@pavel-sbor
Description

I have date-time field in my spec.

definitions:
  MDCTrace:
    title: MDC Trace definition
    type: object
    properties:
      expirationTime:
        type: string
        format: date-time
        readOnly: true

Although "expitationTime" has a date format in generated java code, it displays as a number on UI page:

Response Body:
[
  {
    "expirationTime": 1474344922000
  }
]
Swagger-codegen version

I use docker image for generation
https://github.com/mydock/swagger-codegen-prebuilt

Swagger declaration file content or url
swagger: '2.0'

# This is your document metadata
info:
  version: "0.1.0"
  title: 'TITLE'
  description: |
    Description.
  contact:
    name: API Support
    url: http://uri.ru/
    email: mail@mail.ru

produces:
  - application/json

definitions:
  MDCTrace:
    title: MDC Trace definition
    properties:
      expirationTime:
        type: string
        readOnly: true
paths:
  /mdc/traces:
    get:
      description: |
        Get MDC Traces definitions.
      tags:
      - traces
      operationId: getMDCTraces
      responses:
        200:
          description: |
            MDC Traces definitions.
          schema:
            title: ArrayOfMDCTaces
            type: array
            items:
              $ref: '#/definitions/MDCTrace'
        default:
          description: |
            Generic Error.
Command line used for generation

docker run --rm -t -v $(pwd):/code mydock/swagger-codegen-prebuilt generate -i /code/swagger.yaml -l spring-mvc -o /code/app

Steps to reproduce
  1. Generate code with spec
  2. Create in "/mdc/traces" method's handler (getMDCTraces()) instance of MDCTrace class.
  3. Return it as a list of MDCTraces
    return new ResponseEntity<List<MDCTrace>>(list, HttpStatus.OK);
  4. Make a query and look at expirationTime field
Related issues

not found

Suggest a Fix

I suppose, the problem in displaying on the web page, because before the line
return new ResponseEntity<List<MDCTrace>>(list, HttpStatus.OK);
expirationTime displayed as normal date in Java code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions