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

Wrong java.time.Instant properties schema #812

Closed
hrensgory opened this issue Jun 1, 2021 · 8 comments
Closed

Wrong java.time.Instant properties schema #812

hrensgory opened this issue Jun 1, 2021 · 8 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists
Milestone

Comments

@hrensgory
Copy link

hrensgory commented Jun 1, 2021

Hi,

I have a problem with java.time.Instant properties representation in OpenAPI, generated by smallrye-open-api

Environment: Quarkus 1.13.6, Kotlin 1.4.32

Data class:

@Schema(description = "Quark")
data class Quark (
val name: String? = null,
val description: String? = null,
@Schema(description = "created date", type = SchemaType.STRING, format = "date-time")
val createdDate: Instant
)

JSON output from service looks ok:

{

"name": "Charm",
"description": "The charm quark, charmed quark or c quark (from its symbol, c) is the third most massive of all quarks, a type of elementary particle.",
"createdDate": "2021-06-01T16:52:52.837152100Z"

}

Expected schema is something like this:

Quark:
  description: Quark
  type: object
  properties:
    createdDate:
      type: string
      format: "date-time"
    description:
      type: string
    name:
      type: string

Real schema, generated at http://localhost:8080/openapi is much more verbose:

Instant:
  type: object
  properties:
    nanos:
      format: int32
      type: integer
    seconds:
      format: int64
      type: integer
    epochSecond:
      format: int64
      type: integer
    nano:
      format: int32
      type: integer
Quark:
  description: Quark
  type: object
  properties:
    createdDate:
      $ref: '#/components/schemas/Instant'
    description:
      type: string
    name:
      type: string

please suggest how to get rid of unnecessary (and wrong ) "Instant" object.
Minimal reproduced attached - code-with-quarkus.zip

Thanks in advance.

@MikeEdgar
Copy link
Member

@phillip-kruger - this is fixed on 2.0.x but not yet released.

@hrensgory
Copy link
Author

@MikeEdgar - thanks for the answer!

BTW, I found the workaround:

@field: Schema(
description = "created date",
type = SchemaType.STRING,
implementation = String::class,
format = "date-time"
)
val createdDate

works fine for me.

@MikeEdgar MikeEdgar added bug Something isn't working duplicate This issue or pull request already exists labels Jun 1, 2021
@MikeEdgar MikeEdgar added this to the 2.0.27 milestone Jun 1, 2021
@MikeEdgar
Copy link
Member

@hrensgory, I am marking this a duplicate of #769, fixed by #771 (yet to be released). @phillip-kruger, it might make sense to do another release from 2.0.x for the downstream projects that are still supporting MP OpenAPI 1.1. wdyt?

@phillip-kruger
Copy link
Member

We can do that. I'll do a release now. @hrensgory Quarkus 2 is nearly out, and the issue is fixed there. Try with CR2 to confirm.

@phillip-kruger
Copy link
Member

Closing here (to do the release)

@hrensgory
Copy link
Author

We can do that. I'll do a release now. @hrensgory Quarkus 2 is nearly out, and the issue is fixed there. Try with CR2 to confirm.

CR2 works like a charm. Thank you, @phillip-kruger

@phillip-kruger
Copy link
Member

Ok great, are you ok to wait for Quarkus 2, or should we backport ?

@hrensgory
Copy link
Author

We're ok to wait. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants