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

@discriminatorKey doesn't work on case objects in ADTs #293

Open
gabrieljones opened this issue Jan 12, 2023 · 4 comments
Open

@discriminatorKey doesn't work on case objects in ADTs #293

gabrieljones opened this issue Jan 12, 2023 · 4 comments
Assignees
Labels

Comments

@gabrieljones
Copy link

Describe the bug

To Reproduce

@discriminator("type", phantom = true)
sealed trait Command

object Command {
  @discriminatorKey("m") //WORKS
  case class Move(meters: Int) extends Command
  @discriminatorKey("r") // WORKS
  case class Rotate(degrees: Int) extends Command
  @discriminatorKey("j") // DOES NOT WORK - IGNORED
  case object Jump extends Command
}

Expected behavior

        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "type": {
              "enum": [
                "j"
              ]
            }
          },
          "required": [
            "type"
          ]
        }

Actual results

        {
          "type": "string",
          "enum": [
            "Jump"
          ]
        },

Versions:

  • jsonschema version 0.7.9
  • scala version 2.13.10
@gabrieljones
Copy link
Author

this may be a dupe of #291

@gabrieljones
Copy link
Author

gabrieljones commented Jan 13, 2023

Is there already a feature request related to producing a const instead of a single value enum on the descriminator?

@andyglow
Copy link
Owner

nope, I don't think so. Please file a new one

@gabrieljones
Copy link
Author

nope, I don't think so. Please file a new one

#294

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

No branches or pull requests

2 participants