Skip to content

Commit

Permalink
feat(obligation): category field added in obligation get, post, patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourav Bhowmik committed Oct 17, 2024
1 parent 4eee53c commit f63fa1e
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 106 deletions.
77 changes: 38 additions & 39 deletions cmd/laas/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,18 @@ const docTemplate = `{
"active": {
"type": "boolean"
},
"category": {
"type": "string",
"enum": [
"Distribution",
"Patent",
"Internal",
"Contractual",
"Export Control",
"General"
],
"example": "Distribution"
},
"classification": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -2325,50 +2337,13 @@ const docTemplate = `{
}
},
"models.ObligationPATCHRequestJSONSchema": {
"type": "object",
"properties": {
"active": {
"type": "boolean",
"example": true
},
"classification": {
"type": "string",
"enum": [
"green",
"white",
"yellow",
"red"
]
},
"comment": {
"type": "string",
"example": "This is a comment."
},
"modifications": {
"type": "boolean"
},
"text": {
"type": "string",
"example": "Source code be made available when distributing the software."
},
"text_updatable": {
"type": "boolean"
},
"type": {
"type": "string",
"enum": [
"obligation",
"restriction",
"risk",
"right"
]
}
}
"type": "object"
},
"models.ObligationPOSTRequestJSONSchema": {
"type": "object",
"required": [
"active",
"category",
"classification",
"comment",
"modifications",
Expand All @@ -2382,6 +2357,18 @@ const docTemplate = `{
"type": "boolean",
"example": true
},
"category": {
"type": "string",
"enum": [
"Distribution",
"Patent",
"Internal",
"Contractual",
"Export Control",
"General"
],
"example": "Distribution"
},
"classification": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -2477,6 +2464,18 @@ const docTemplate = `{
}
}
},
"models.OptionalData-string": {
"type": "object",
"properties": {
"isDefined": {
"description": "This is set to true if corresponding key is present in json object",
"type": "boolean"
},
"value": {
"type": "string"
}
}
},
"models.PaginationMeta": {
"type": "object",
"properties": {
Expand Down
77 changes: 38 additions & 39 deletions cmd/laas/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2134,6 +2134,18 @@
"active": {
"type": "boolean"
},
"category": {
"type": "string",
"enum": [
"Distribution",
"Patent",
"Internal",
"Contractual",
"Export Control",
"General"
],
"example": "Distribution"
},
"classification": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -2318,50 +2330,13 @@
}
},
"models.ObligationPATCHRequestJSONSchema": {
"type": "object",
"properties": {
"active": {
"type": "boolean",
"example": true
},
"classification": {
"type": "string",
"enum": [
"green",
"white",
"yellow",
"red"
]
},
"comment": {
"type": "string",
"example": "This is a comment."
},
"modifications": {
"type": "boolean"
},
"text": {
"type": "string",
"example": "Source code be made available when distributing the software."
},
"text_updatable": {
"type": "boolean"
},
"type": {
"type": "string",
"enum": [
"obligation",
"restriction",
"risk",
"right"
]
}
}
"type": "object"
},
"models.ObligationPOSTRequestJSONSchema": {
"type": "object",
"required": [
"active",
"category",
"classification",
"comment",
"modifications",
Expand All @@ -2375,6 +2350,18 @@
"type": "boolean",
"example": true
},
"category": {
"type": "string",
"enum": [
"Distribution",
"Patent",
"Internal",
"Contractual",
"Export Control",
"General"
],
"example": "Distribution"
},
"classification": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -2470,6 +2457,18 @@
}
}
},
"models.OptionalData-string": {
"type": "object",
"properties": {
"isDefined": {
"description": "This is set to true if corresponding key is present in json object",
"type": "boolean"
},
"value": {
"type": "string"
}
}
},
"models.PaginationMeta": {
"type": "object",
"properties": {
Expand Down
57 changes: 29 additions & 28 deletions cmd/laas/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ definitions:
properties:
active:
type: boolean
category:
enum:
- Distribution
- Patent
- Internal
- Contractual
- Export Control
- General
example: Distribution
type: string
classification:
enum:
- green
Expand Down Expand Up @@ -460,40 +470,22 @@ definitions:
type: string
type: object
models.ObligationPATCHRequestJSONSchema:
properties:
active:
example: true
type: boolean
classification:
enum:
- green
- white
- yellow
- red
type: string
comment:
example: This is a comment.
type: string
modifications:
type: boolean
text:
example: Source code be made available when distributing the software.
type: string
text_updatable:
type: boolean
type:
enum:
- obligation
- restriction
- risk
- right
type: string
type: object
models.ObligationPOSTRequestJSONSchema:
properties:
active:
example: true
type: boolean
category:
enum:
- Distribution
- Patent
- Internal
- Contractual
- Export Control
- General
example: Distribution
type: string
classification:
enum:
- green
Expand Down Expand Up @@ -527,6 +519,7 @@ definitions:
type: string
required:
- active
- category
- classification
- comment
- modifications
Expand Down Expand Up @@ -570,6 +563,14 @@ definitions:
example: 200
type: integer
type: object
models.OptionalData-string:
properties:
isDefined:
description: This is set to true if corresponding key is present in json object
type: boolean
value:
type: string
type: object
models.PaginationMeta:
properties:
limit:
Expand Down
3 changes: 3 additions & 0 deletions pkg/models/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ type Obligation struct {
Active bool `json:"active"`
TextUpdatable bool `json:"text_updatable" example:"true"`
Md5 string `gorm:"unique" json:"-"`
Category string `json:"category" enums:"Distribution,Patent,Internal,Contractual,Export Control,General" example:"Distribution"`
}

// ObligationPreview is just the Type and Topic of Obligation
Expand All @@ -307,6 +308,7 @@ type ObligationPOSTRequestJSONSchema struct {
Comment string `json:"comment" binding:"required"`
Shortnames []string `json:"shortnames" binding:"required" example:"GPL-2.0-only,GPL-2.0-or-later"`
Active bool `json:"active" binding:"required" example:"true"`
Category string `json:"category" enums:"Distribution,Patent,Internal,Contractual,Export Control,General" binding:"required" example:"Distribution"`
}

// ObligationPATCHRequestJSONSchema represents the data format of PATCH request for obligation
Expand All @@ -318,6 +320,7 @@ type ObligationPATCHRequestJSONSchema struct {
Comment OptionalData[string] `json:"comment" swaggertype:"string" example:"This is a comment."`
Active OptionalData[bool] `json:"active" swaggertype:"boolean" example:"true"`
TextUpdatable OptionalData[bool] `json:"text_updatable" swaggertype:"boolean"`
Category OptionalData[string] `json:"category" enums:"Distribution,Patent,Internal,Contractual,Export Control,General" binding:"required" example:"Distribution"`
}

// ObligationResponse represents the response format for obligation data.
Expand Down

0 comments on commit f63fa1e

Please sign in to comment.