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

fix: use more accurate formats for byte, short, and char types #2128

Merged
merged 2 commits into from
Jan 6, 2025

Conversation

MikeEdgar
Copy link
Member

  • byte: format: int8
  • short: format: int16
  • char: format: char

See the format registry for reference: https://spec.openapis.org/registry/format/

Fixes #2124
Fixes #2126

@MikeEdgar MikeEdgar added this to the 4.0.6 milestone Jan 4, 2025
@MikeEdgar
Copy link
Member Author

@dhoffer, FYI. Let me know if this change matches your expectations.

@dhoffer
Copy link

dhoffer commented Jan 5, 2025

Hi @MikeEdgar

It still seems a little off:

@JsonView(Views.Abridged.class)
@Schema(description = "Relative velocity to skin line.", example = "1")
private short h29;

Results in:

"h29" : {
            "type" : "integer",
            "description" : "Relative velocity to skin line.",
            "example" : 1
          },

I think it should be:

"h29" : {
            "type" : "integer",
            "format" : "int16",
            "description" : "Relative velocity to skin line.",
            "example" : 1
          },

And

@JsonView(Views.Abridged.class)
@Schema(description = "Computed object length based upon HRR profile, in meters.", minimum = "0", maximum = "100", example="22")
private byte h30;

Results with:

"h30" : {
            "type" : "string",
            "format" : "byte",
            "description" : "Computed object length based upon HRR profile, in meters.",
            "maximum" : 100,
            "minimum" : 0,
            "example" : "22"
          },

And we think it should be:

"h30" : {
            "type" : "integer",
            "format" : "int8",
            "description" : "Computed object length based upon HRR profile, in meters.",
            "maximum" : 100,
            "minimum" : 0,
            "example" : "22"
          },

byte, short, int, long are all integers with different size specified in the format.

I'm using these dependencies that I built locally.

<dependency>
                <groupId>io.smallrye</groupId>
                <artifactId>smallrye-open-api-core</artifactId>
                <version>4.0.6-SNAPSHOT</version>
</dependency>
 dependency>
                <groupId>io.smallrye</groupId>
                <artifactId>smallrye-open-api-jaxrs</artifactId>
                <version>4.0.6-SNAPSHOT</version>
</dependency>

@MikeEdgar
Copy link
Member Author

@dhoffer, the snippets you gave as your expected results are what I see locally. Did you build main or this PR for your test?

@dhoffer
Copy link

dhoffer commented Jan 5, 2025

Hi @MikeEdgar my bad, yes I was on main. I guess I thought this was already merged to main but I see its not. I don't seem to have access to pull down your PR branch. Given your reply, I say this is ready for a merge. I will test as soon as I have access.

@MikeEdgar MikeEdgar enabled auto-merge (squash) January 6, 2025 12:21
@MikeEdgar MikeEdgar merged commit 5b2a911 into smallrye:main Jan 6, 2025
5 checks passed
@MikeEdgar MikeEdgar deleted the type-formats branch January 6, 2025 12:38
@dhoffer
Copy link

dhoffer commented Jan 6, 2025

Hi @MikeEdgar I have confirmed the 4.0.6-SNAPSHOT code fixes this and the other related issue. How soon could we get a release?

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

Successfully merging this pull request may close these issues.

Generated OpenAPI for Java byte is incorrect Generated results for Character Java type are invalid
3 participants