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

REST API - date type mismatch #1276

Closed
ruckc opened this issue Nov 19, 2021 · 4 comments · Fixed by #3731
Closed

REST API - date type mismatch #1276

ruckc opened this issue Nov 19, 2021 · 4 comments · Fixed by #3731
Labels
api docs enhancement New feature or request p3 Nice-to-have features
Milestone

Comments

@ruckc
Copy link

ruckc commented Nov 19, 2021

Current Behavior:

The swagger.json documents ProjectMetrics firstOccurrence and lastOccurrence as string/date-time. The response payload is a unix timestamp in milliseconds since Jan 1 1970. This makes it difficult to autogenerate client code something like openapi-generator. This is likely due to the usage of the java.util.Date object instead of the newer JSR310 date types for JSON marshalling.

Expected Behavior:

It would be ideal if the REST API matched the response type.

Environment:

  • Dependency-Track Version: 4.3.6
  • Distribution: Docker
  • BOM Format & Version: N/A
  • Database Server: PostgreSQL
  • Browser: N/A
@ruckc ruckc changed the title REST API - type mismatch REST API - date type mismatch Nov 19, 2021
@stevespringett stevespringett added breaking change enhancement New feature or request p3 Nice-to-have features and removed in triage labels Nov 19, 2021
@JorisVanEijden
Copy link

Alternatively change the swagger,.json to say

"type" : "integer",
"format" : "int64"

in stead of

"type" : "string",
"format" : "date-time"

Obviously less preferable from a correctness standpoint, but it would not constitute a breaking change.

@taladar
Copy link

taladar commented Dec 16, 2022

I just ran into this issue too. Is there a reason this minor fix has not been implemented in over a year?

Also, the breaking change label is still wrong, at least for the solution that fixes swagger to reflect what the API actually does.

@danhallin
Copy link

As the output from http://{hostname}:{port}/api/swagger.json is not following the Swagger 2.0 specification:

https://swagger.io/specification/v2/
https://www.ietf.org/rfc/rfc3339.txt

This error should at least be mentioned in the documentation here:

https://docs.dependencytrack.org/integrations/rest-api/

nscuro added a commit to nscuro/dependency-track that referenced this issue May 18, 2024
Fields of type `Date` that are not explicitly serialized with `Iso8601DateSerializer` are automatically serialized as UNIX epoch timestamp in milliseconds. However the OpenAPI spec declared them to be of type `string` in `date-time` format, which is incorrect.

Instead of changing the field's actual type, causing a breaking change, provide a type hint to the OpenAPI generator.

Fixes DependencyTrack#1276
Fixes DependencyTrack#2591

Signed-off-by: nscuro <nscuro@protonmail.com>
@nscuro nscuro added this to the 4.12 milestone May 18, 2024
Copy link
Contributor

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 18, 2024
MM-msr pushed a commit to MM-msr/dependency-track that referenced this issue Jun 18, 2024
Fields of type `Date` that are not explicitly serialized with `Iso8601DateSerializer` are automatically serialized as UNIX epoch timestamp in milliseconds. However the OpenAPI spec declared them to be of type `string` in `date-time` format, which is incorrect.

Instead of changing the field's actual type, causing a breaking change, provide a type hint to the OpenAPI generator.

Fixes DependencyTrack#1276
Fixes DependencyTrack#2591

Signed-off-by: nscuro <nscuro@protonmail.com>
netomi pushed a commit to netomi/dependency-track that referenced this issue Aug 8, 2024
Fields of type `Date` that are not explicitly serialized with `Iso8601DateSerializer` are automatically serialized as UNIX epoch timestamp in milliseconds. However the OpenAPI spec declared them to be of type `string` in `date-time` format, which is incorrect.

Instead of changing the field's actual type, causing a breaking change, provide a type hint to the OpenAPI generator.

Fixes DependencyTrack#1276
Fixes DependencyTrack#2591

Signed-off-by: nscuro <nscuro@protonmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api docs enhancement New feature or request p3 Nice-to-have features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants