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

Duplicate enum names in Java output. #129

Closed
NightlyNexus opened this issue Mar 15, 2018 · 0 comments
Closed

Duplicate enum names in Java output. #129

NightlyNexus opened this issue Mar 15, 2018 · 0 comments

Comments

@NightlyNexus
Copy link

{
  "id": "message.json",
  "title": "message",
  "description" : "Schema definition of message",
  "$schema": "http://json-schema.org/schema#",
  "type": "object",
  "properties": {
    "text" : { "type": "string" },
    "foo" : {
      "type" : "string",
      "enum": [
        { "default" : "none", "description" : "none" },
        { "default" : "foo1", "description" : "foo1" },
        { "default" : "foo2", "description" : "foo2" }
      ],
      "default" : "none"
    },
    "bar" : {
      "type": "string",
      "enum": [
        { "default" : "none", "description" : "none" },
        { "default" : "bar1", "description" : "bar1" },
        { "default" : "bar2", "description" : "bar2" },
      ],
      "default" : "none"
    }
  },
  "required": []
}

generates

public abstract class Message {
  public static final String NONE = "none";
  public static final String BAR1 = "bar1";
  public static final String BAR2 = "bar2";
  @StringDef({NONE, BAR1, BAR2})
  @Retention(RetentionPolicy.SOURCE)
  public @interface MessageBar {}
  public static final String NONE = "none";
  public static final String FOO1 = "foo1";
  public static final String FOO2 = "foo2";
  @StringDef({NONE, FOO1, FOO2})
  @Retention(RetentionPolicy.SOURCE)
  public @interface MessageFoo {}
  ...
}

This is illegal because NONE is defined twice in the Message class.

It'd be nice to generate qualified names like the following.

@StringDef({NONE, BAR1, BAR2})
@Retention(SOURCE)
public @interface MessageBar {
  String NONE = "none";
  String BAR1 = "bar1";
  String BAR2 = "bar2";
}
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

No branches or pull requests

2 participants