invopop / invopop/jsonschema

How to set $id for slices?

Open
#73 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
952
Forks
136
PR merge metrics
No merged PRs in 30d

Description

Hey everyone,

I tried to add an ID to a slice based schema type today but wasn't able to find out how to achieve this.
Minimal required steps are:
```go
r := new(jsonschema.Reflector)

schema := r.Reflect(&[]struct{}{})
json, _ := schema.MarshalJSON()
println(string(json))
```
the output is:
```json
{
"$schema":"https://json-schema.org/draft/2020-12/schema",
"items":{"properties":{},"additionalProperties":false,"type":"object"},
"type":"array"
}
```

Which options do I have to add an `$id` field here?

Thanks in advance 🙇

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.