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

Feature Request/Discussion: Golang string types for discriminator #49

Open
delaneyj opened this issue May 12, 2022 · 0 comments
Open

Feature Request/Discussion: Golang string types for discriminator #49

delaneyj opened this issue May 12, 2022 · 0 comments

Comments

@delaneyj
Copy link

A definition of

 "foo": {
      "discriminator": "type",
      "mapping": {
        "a": {
          "properties": {}
        },
        "b": {
          "properties": {}
        },
        "c": {
          "properties": {}
        }
      }
    }

Generates a Go struct of

type Foo struct {
	Type string

	A FooA

	B FooB

	C FooC
}

Where it should be more acccurately be the same as an enum and look more like...

type FooTypeDiscriminator string

const (
	FooTypeDiscriminatorA FooTypeDiscriminator = "a"

	FooTypeDiscriminatorB FooTypeDiscriminator = "b"

	FooTypeDiscriminatorC FooTypeDiscriminator = "c"
)

type Foo struct {
	FooTypeDiscriminator string

	A FooA

	B FooB

	C FooC
}

This would improve auto-completion and validation.

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

1 participant