Skip to content

Fine-grained nullish inference #63

@seiyab

Description

@seiyab

Is your feature request related to a problem? Please describe.
I want to control whether a slice field is nullable or not. JSONSCHEMAGODEBUG environment variable might help but I still feel inconvenient:

  • Not build-time configuration
    • It can cause mismatch between dev and prod
  • Less configurable
    • It is all or nothing. Can't control for each schema.

Describe the solution you'd like

// Approach 1: tag
type A struct {
  Things []int `jsonschemanull:"false"`
}

// Approach 2: option
For[MyType](&ForOption{
  Null: true, // we should consider more understandable name
})

Describe alternatives you've considered
N/A

Additional context
I want to utilze it to generate schema and pass it to a library. But the library we use doesn't support ["null", "array"] as of now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions