Skip to content

Commit

Permalink
Notice having JSON:API non-compliance in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
violog committed Jul 5, 2024
1 parent 2e26286 commit 554f77d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 55 deletions.
4 changes: 4 additions & 0 deletions docs/spec/components/schemas/EventStaticMeta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ type: object
description: |
Primary event metadata in plain JSON. This is a template
to be filled by `dynamic` when it's present.
This structure is also reused as request body to event type creation and update.
required:
- name
- reward
Expand Down Expand Up @@ -66,6 +68,8 @@ properties:
If event is disabled, it doesn't matter if it's expired or not started:
it has `disabled` flag.
Do not specify this field on creation: this structure is reused for request body too.
enum:
- active
- not_started
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ patch:
description: |
Update an existing event type. Requires **admin** role in JWT.
**All attributes** are updated, ensure to pass every existing field too.
Although this is not JSON:API compliant, it is much easier to work with
in Go, because differentiating between `{}` and `{"field": null}`
requires custom unmarshalling implementation.
operationId: updateEventType
requestBody:
required: true
Expand Down
1 change: 1 addition & 0 deletions internal/service/requests/create_event_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func NewCreateEventType(r *http.Request) (req resources.EventTypeResponse, err e
"data/attributes/frequency": val.Validate(attr.Frequency, val.Required, val.In(models.Unlimited)),
"data/attributes/logo": val.Validate(attr.Logo, is.URL),
"data/attributes/name": val.Validate(attr.Name, val.Required, val.In(req.Data.ID)),
"data/attributes/flag": val.Validate(attr.Flag, val.Empty),
"data/attributes/qr_code_value": val.Validate(attr.QrCodeValue, val.Required),
"data/attributes/reward": val.Validate(attr.Reward, val.Required, val.Min(1)),
"data/attributes/short_description": val.Validate(attr.ShortDescription, val.Required),
Expand Down
4 changes: 2 additions & 2 deletions resources/model_event_static_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package resources

import "time"

// Primary event metadata in plain JSON. This is a template to be filled by `dynamic` when it's present.
// Primary event metadata in plain JSON. This is a template to be filled by `dynamic` when it's present. This structure is also reused as request body to event type creation and update.
type EventStaticMeta struct {
// Page where you can fulfill the event
ActionUrl *string `json:"action_url,omitempty"`
Expand All @@ -17,7 +17,7 @@ type EventStaticMeta struct {
Disabled bool `json:"disabled"`
// General event expiration date (UTC RFC3339)
ExpiresAt *time.Time `json:"expires_at,omitempty"`
// Event configuration flag: - active: Events can be opened, fulfilled, claimed - not_started: Event are not available yet, see `starts_at` - expired: Event is not available, as it has already expired, see `expires_at` - disabled: Event is disabled in the system If event is disabled, it doesn't matter if it's expired or not started: it has `disabled` flag.
// Event configuration flag: - active: Events can be opened, fulfilled, claimed - not_started: Event are not available yet, see `starts_at` - expired: Event is not available, as it has already expired, see `expires_at` - disabled: Event is disabled in the system If event is disabled, it doesn't matter if it's expired or not started: it has `disabled` flag. Do not specify this field on creation: this structure is reused for request body too.
Flag string `json:"flag"`
// Event frequency, which means how often you can fulfill certain task and claim the reward.
Frequency string `json:"frequency"`
Expand Down
43 changes: 0 additions & 43 deletions resources/model_passport_event_state.go

This file was deleted.

10 changes: 0 additions & 10 deletions resources/model_passport_event_state_attributes.go

This file was deleted.

0 comments on commit 554f77d

Please sign in to comment.