Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A combination of java.sql.Date and DocumentationExample #1040

Closed
AlexandrSokolov opened this issue Jun 8, 2020 · 1 comment
Closed

A combination of java.sql.Date and DocumentationExample #1040

AlexandrSokolov opened this issue Jun 8, 2020 · 1 comment
Labels
Milestone

Comments

@AlexandrSokolov
Copy link

I've added the DocumentationExample annotation on 2 getters:

  public static final String DATETIME_VALUE = "2020-05-25'T'124:35:75'Z'";
  @DocumentationExample(value=DATETIME_VALUE, type=@TypeHint(java.sql.Date.class) )
  @Override
  public java.sql.Date getSqlDate() {
    return sqlDate != null ? (java.sql.Date) sqlDate.clone() : null;
  }
  @DocumentationExample(value=DATETIME_VALUE, type=@TypeHint(Date.class) )
  @Override
  public Date getJavaDate() {
    return javaDate != null ? (Date) javaDate.clone() : null;
  }

When swagger module is enabled it failed with the error:

[ERROR] Failed to execute goal com.webcohesion.enunciate:enunciate-maven-plugin:2.13.1:docs (default) on project some-project-rest-api: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('-' (code 45)): was expecting comma to separate Object entries
[ERROR] at [Source: (FileReader); line: 183, column: 30]

In the enunciate/docs/ui/swagger.json the DATETIME_VALUE (see example attribute) for java.util.Date is wrapped with double quotes and is a valid json string, but for java.sql.Date it is generated without double quotes and as a result we get this error. Here are two generated values for comparison:

            "javaDate" : {
            "example" : "2020-05-25'T'124:35:75'Z'",
            "readOnly" : false,
"description" : "",
"type" : "string",
"format" : "date-time"
            },
            "sqlDate" : {
            "example" : 2020-05-25'T'124:35:75'Z',
            "readOnly" : false,
"$ref" : "#/definitions/Date",
"description" : ""
            },
@stoicflame stoicflame added the bug label Jun 8, 2020
@stoicflame stoicflame added this to the 2.14.0 milestone Jun 8, 2020
@stoicflame
Copy link
Owner

Fixed in 2.13.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants