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

number enums generate non-compiling code #715

Open
Shohou opened this issue Apr 30, 2024 · 1 comment · May be fixed by #720
Open

number enums generate non-compiling code #715

Shohou opened this issue Apr 30, 2024 · 1 comment · May be fixed by #720

Comments

@Shohou
Copy link

Shohou commented Apr 30, 2024

Got to integration-tests/enum-property/src/main/openapi/enum-property.yaml. Change type for enum from string to number and enum values from 'text' to 1:

components:
  schemas:
    Echo:
      type: object
      properties:
        echoedMsgType:
          type: string
    Message:
      type: object
      required:
        - msgType
      properties:
        msgType:
          type: number    <---
          enum:
            - 1          <---

Compile it and check generated org.openapi.quarkus.enum_property_yaml.model.Message class. It will contain enum value -

@JsonIgnoreProperties(ignoreUnknown = true)
public class Message  {


    public enum MsgTypeEnum {
        NUMBER_1(BigDecimal.valueOf(new BigDecimal("1")));    // THIS IS NOT COMPILING

        // caching enum access
        private static final java.util.EnumSet<MsgTypeEnum> values = java.util.EnumSet.allOf(MsgTypeEnum.class);

        BigDecimal value;

BigDecimal.valueOf(new BigDecimal("1")) this part can not compile

@ricardozanini
Copy link
Member

Can you send a PR to fix this? Just change the pojo.qute template file to verify if the enum is a number and generate it correctly. What's the compilation error?

Shohou pushed a commit to Shohou/quarkus-openapi-generator that referenced this issue May 16, 2024
@Shohou Shohou linked a pull request May 16, 2024 that will close this issue
@hbelmiro hbelmiro linked a pull request May 16, 2024 that will close this issue
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 a pull request may close this issue.

2 participants