Documentation
¶
Overview ¶
Package jsonapi is the licensing client's private JSON:API transport: the document envelope, request encoding, and response decoding into the client's typed structs. It is intentionally small — only what the Keygen licensing endpoints emit and consume.
Index ¶
Constants ¶
const ContentType = "application/vnd.api+json"
ContentType is the JSON:API media type Keygen speaks.
Variables ¶
This section is empty.
Functions ¶
func DecodeAttributes ¶
DecodeAttributes decodes a resource's attributes into target.
Types ¶
type Body ¶
type Body struct {
Type string
ID string
Attributes any
Relationships map[string]Relationship
Meta any
}
Body is a request body under construction: a single resource with attributes, relationships, and an optional top-level meta object.
type Document ¶
type Document struct {
Data json.RawMessage `json:"data,omitempty"`
Meta json.RawMessage `json:"meta,omitempty"`
Included []Resource `json:"included,omitempty"`
Errors []Error `json:"errors,omitempty"`
}
Document is the JSON:API envelope: single or collection data, meta, included resources, and errors.
func (Document) DecodeMeta ¶
DecodeMeta decodes the document's meta object into target.
type Error ¶
type Error struct {
Title string `json:"title,omitempty"`
Detail string `json:"detail,omitempty"`
Code string `json:"code,omitempty"`
Source Source `json:"source,omitempty"`
}
Error is one member of a JSON:API errors array.
type Identifier ¶
Identifier is a resource object identifier: {type, id}.
type Relationship ¶
type Relationship struct {
Data any `json:"data,omitempty"`
}
Relationship is a JSON:API relationship object. Data is polymorphic on the wire (null, a single identifier, or an array with embedded attributes), so it is typed as any on the encode side and re-decoded through RelID on the read side.
type Resource ¶
type Resource struct {
ID string `json:"id"`
Type string `json:"type"`
Attributes json.RawMessage `json:"attributes,omitempty"`
Relationships map[string]Relationship `json:"relationships,omitempty"`
}
Resource is a JSON:API resource object. Attributes stay raw so each caller decodes them into its own typed struct.