Skip to content

Commit

Permalink
fix(license_obligations): Add type field to response
Browse files Browse the repository at this point in the history
  • Loading branch information
deo002 committed Jun 7, 2024
1 parent 69c39d1 commit 7eaca0a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/laas/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,16 @@ const docTemplate = `{
"topic": {
"type": "string",
"example": "copyleft"
},
"type": {
"type": "string",
"enum": [
"obligation",
"restriction",
"risk",
"right"
],
"example": "obligation"
}
}
},
Expand Down
10 changes: 10 additions & 0 deletions cmd/laas/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,16 @@
"topic": {
"type": "string",
"example": "copyleft"
},
"type": {
"type": "string",
"enum": [
"obligation",
"restriction",
"risk",
"right"
],
"example": "obligation"
}
}
},
Expand Down
8 changes: 8 additions & 0 deletions cmd/laas/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,14 @@ definitions:
topic:
example: copyleft
type: string
type:
enum:
- obligation
- restriction
- risk
- right
example: obligation
type: string
type: object
models.ObligationPATCHRequestJSONSchema:
properties:
Expand Down
3 changes: 3 additions & 0 deletions pkg/api/obligationmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func GetObligationMapByTopic(c *gin.Context) {

resObMap = models.ObligationMapUser{
Topic: topic,
Type: obligation.Type,
Shortnames: shortnameList,
}

Expand Down Expand Up @@ -155,6 +156,7 @@ func GetObligationMapByLicense(c *gin.Context) {
return
}
resObMapList = append(resObMapList, models.ObligationMapUser{
Type: obligation.Type,
Topic: obligation.Topic,
Shortnames: []string{licenseShortName},
})
Expand Down Expand Up @@ -538,6 +540,7 @@ func createObligationMapUser(obligation models.Obligation, obMaps []models.Oblig
}
return &models.ObligationMapUser{
Topic: obligation.Topic,
Type: obligation.Type,
Shortnames: shortnameList,
}, nil
}
1 change: 1 addition & 0 deletions pkg/models/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ type ObligationMap struct {
// ObligationMapUser Structure with obligation topic and license shortname list, a simple representation for user.
type ObligationMapUser struct {
Topic string `json:"topic" example:"copyleft"`
Type string `json:"type" example:"obligation" enums:"obligation,restriction,risk,right"`
Shortnames []string `json:"shortnames" example:"GPL-2.0-only,GPL-2.0-or-later"`
}

Expand Down

0 comments on commit 7eaca0a

Please sign in to comment.