Skip to content

Commit

Permalink
Fix swagger docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kate Döen committed Sep 16, 2021
1 parent 3c07a58 commit b430ce1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
23 changes: 13 additions & 10 deletions schema/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,22 @@ func (h *Handler) getByID(w http.ResponseWriter, r *http.Request, ps httprouter.
}
}

// Raw JSON Schema list
// Raw identity Schema list
//
// swagger:model JSONSchemas
type JSONSchemas []identitySchema
// swagger:model IdentitySchemas
type IdentitySchemas []identitySchema

// swagger:model identitySchema
type identitySchema struct {
ID string `json:"id"`
// The ID of the Identity JSON Schema
ID string `json:"id"`
// The actual Identity JSON Schema
Schema json.RawMessage `json:"schema"`
}

// nolint:deadcode,unused
// swagger:parameters getJsonSchemas
type getJsonSchemas struct {
// swagger:parameters listIdentitySchemas
type listIdentitySchemas struct {
// Items per Page
//
// This is the number of items per page.
Expand All @@ -134,25 +137,25 @@ type getJsonSchemas struct {
Page int `json:"page"`
}

// swagger:route GET /schemas v0alpha1 getJsonSchemas
// swagger:route GET /schemas v0alpha2 listIdentitySchemas
//
// Get all JSON Schemas
// Get all Identity Schemas
//
// Produces:
// - application/json
//
// Schemes: http, https
//
// Responses:
// 200: JSONSchemas
// 200: IdentitySchemas
// 500: jsonError
func (h *Handler) getAll(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
page, itemsPerPage := x.ParsePagination(r)

schemas := h.r.IdentityTraitsSchemas(r.Context()).List(page, itemsPerPage)
total := h.r.IdentityTraitsSchemas(r.Context()).Total()

var ss JSONSchemas
var ss IdentitySchemas

for _, schema := range schemas {
s, err := h.r.IdentityTraitsSchemas(r.Context()).GetByID(schema.ID)
Expand Down
4 changes: 2 additions & 2 deletions schema/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestHandler(t *testing.T) {

body := getFromTSPaginated(0, 2, http.StatusOK)

var result schema.JSONSchemas
var result schema.IdentitySchemas
require.NoError(t, json.Unmarshal(body, &result))

ids_orig := []string{}
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestHandler(t *testing.T) {

body1, body2 := getFromTSPaginated(0, 1, http.StatusOK), getFromTSPaginated(1, 1, http.StatusOK)

var result1, result2 schema.JSONSchemas
var result1, result2 schema.IdentitySchemas
require.NoError(t, json.Unmarshal(body1, &result1))
require.NoError(t, json.Unmarshal(body2, &result2))

Expand Down

0 comments on commit b430ce1

Please sign in to comment.