google / google/jsonschema-go

Fine-grained nullish inference

Open
#63 0 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
478
Forks
37
PR merge metrics
No merged PRs in 30d

Description

**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**
```go
// 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.