diff --git a/cmd/laas/docs/docs.go b/cmd/laas/docs/docs.go index 423080f..c94903b 100644 --- a/cmd/laas/docs/docs.go +++ b/cmd/laas/docs/docs.go @@ -394,12 +394,12 @@ const docTemplate = `{ }, { "enum": [ - "rf_spdx_id", - "rf_shortname", - "rf_fullname" + "spdx_id", + "shortname", + "fullname" ], "type": "string", - "default": "rf_shortname", + "default": "shortname", "description": "Sort by field", "name": "sort_by", "in": "query" @@ -1772,7 +1772,7 @@ const docTemplate = `{ }, "field": { "type": "string", - "example": "rf_text" + "example": "text" }, "id": { "type": "integer", @@ -1837,87 +1837,87 @@ const docTemplate = `{ "models.LicenseDB": { "type": "object", "required": [ - "rf_fullname", - "rf_shortname", - "rf_spdx_id", - "rf_text" + "fullname", + "shortname", + "spdx_id", + "text" ], "properties": { - "external_ref": { - "$ref": "#/definitions/datatypes.JSONType-models_LicenseDBSchemaExtension" - }, - "marydone": { + "FSFfree": { "type": "boolean" }, - "rf_FSFfree": { - "type": "boolean" - }, - "rf_Fedora": { + "Fedora": { "type": "string" }, - "rf_GPLv2compatible": { + "GPLv2compatible": { "type": "boolean" }, - "rf_GPLv3compatible": { + "GPLv3compatible": { "type": "boolean" }, - "rf_OSIapproved": { + "OSIapproved": { "type": "boolean" }, - "rf_active": { + "active": { "type": "boolean" }, - "rf_add_date": { + "add_date": { "type": "string", "example": "2023-12-01T18:10:25.00+05:30" }, - "rf_copyleft": { + "copyleft": { "type": "boolean" }, - "rf_detector_type": { + "detector_type": { "type": "integer", "maximum": 2, "minimum": 0, "example": 1 }, - "rf_flag": { + "external_ref": { + "$ref": "#/definitions/datatypes.JSONType-models_LicenseDBSchemaExtension" + }, + "flag": { "type": "integer", "maximum": 2, "minimum": 0, "example": 1 }, - "rf_fullname": { + "fullname": { "type": "string", "example": "MIT License" }, - "rf_notes": { + "marydone": { + "type": "boolean" + }, + "notes": { "type": "string", "example": "This license has been superseded." }, - "rf_risk": { + "risk": { "type": "integer", "maximum": 5, "minimum": 0 }, - "rf_shortname": { + "shortname": { "type": "string", "example": "MIT" }, - "rf_source": { + "source": { "type": "string" }, - "rf_spdx_id": { + "spdx_id": { "type": "string", "example": "MIT" }, - "rf_text": { + "text": { "type": "string", "example": "MIT License Text here" }, - "rf_text_updatable": { + "text_updatable": { "type": "boolean" }, - "rf_url": { + "url": { "type": "string", "example": "https://opensource.org/licenses/MIT" } @@ -2052,84 +2052,84 @@ const docTemplate = `{ "models.LicenseUpdateJSONSchema": { "type": "object", "properties": { - "external_ref": { - "$ref": "#/definitions/datatypes.JSONType-models_LicenseDBSchemaExtension" - }, - "marydone": { - "type": "boolean", - "example": false - }, - "rf_FSFfree": { + "FSFfree": { "type": "boolean", "example": false }, - "rf_Fedora": { + "Fedora": { "type": "string", "example": "Fedora" }, - "rf_GPLv2compatible": { + "GPLv2compatible": { "type": "boolean", "example": false }, - "rf_GPLv3compatible": { + "GPLv3compatible": { "type": "boolean", "example": false }, - "rf_OSIapproved": { + "OSIapproved": { "type": "boolean", "example": false }, - "rf_active": { + "active": { "type": "boolean", "example": true }, - "rf_copyleft": { + "copyleft": { "type": "boolean", "example": false }, - "rf_detector_type": { + "detector_type": { "type": "integer", "maximum": 2, "minimum": 0, "example": 1 }, - "rf_flag": { + "external_ref": { + "$ref": "#/definitions/datatypes.JSONType-models_LicenseDBSchemaExtension" + }, + "flag": { "type": "integer", "maximum": 2, "minimum": 0, "example": 1 }, - "rf_fullname": { + "fullname": { "type": "string", "example": "MIT License" }, - "rf_notes": { + "marydone": { + "type": "boolean", + "example": false + }, + "notes": { "type": "string", "example": "This license has been superseded." }, - "rf_risk": { + "risk": { "type": "integer", "maximum": 5, "minimum": 0, "example": 1 }, - "rf_source": { + "source": { "type": "string", "example": "Source" }, - "rf_spdx_id": { + "spdx_id": { "type": "string", "example": "MIT" }, - "rf_text": { + "text": { "type": "string", "example": "MIT License Text here" }, - "rf_text_updatable": { + "text_updatable": { "type": "boolean", "example": false }, - "rf_url": { + "url": { "type": "string", "example": "https://opensource.org/licenses/MIT" } @@ -2515,7 +2515,7 @@ const docTemplate = `{ "properties": { "field": { "type": "string", - "example": "rf_text" + "example": "text" }, "search": { "type": "string", diff --git a/cmd/laas/docs/swagger.json b/cmd/laas/docs/swagger.json index e4cd619..e02fecb 100644 --- a/cmd/laas/docs/swagger.json +++ b/cmd/laas/docs/swagger.json @@ -387,12 +387,12 @@ }, { "enum": [ - "rf_spdx_id", - "rf_shortname", - "rf_fullname" + "spdx_id", + "shortname", + "fullname" ], "type": "string", - "default": "rf_shortname", + "default": "shortname", "description": "Sort by field", "name": "sort_by", "in": "query" @@ -1765,7 +1765,7 @@ }, "field": { "type": "string", - "example": "rf_text" + "example": "text" }, "id": { "type": "integer", @@ -1830,87 +1830,87 @@ "models.LicenseDB": { "type": "object", "required": [ - "rf_fullname", - "rf_shortname", - "rf_spdx_id", - "rf_text" + "fullname", + "shortname", + "spdx_id", + "text" ], "properties": { - "external_ref": { - "$ref": "#/definitions/datatypes.JSONType-models_LicenseDBSchemaExtension" - }, - "marydone": { + "FSFfree": { "type": "boolean" }, - "rf_FSFfree": { - "type": "boolean" - }, - "rf_Fedora": { + "Fedora": { "type": "string" }, - "rf_GPLv2compatible": { + "GPLv2compatible": { "type": "boolean" }, - "rf_GPLv3compatible": { + "GPLv3compatible": { "type": "boolean" }, - "rf_OSIapproved": { + "OSIapproved": { "type": "boolean" }, - "rf_active": { + "active": { "type": "boolean" }, - "rf_add_date": { + "add_date": { "type": "string", "example": "2023-12-01T18:10:25.00+05:30" }, - "rf_copyleft": { + "copyleft": { "type": "boolean" }, - "rf_detector_type": { + "detector_type": { "type": "integer", "maximum": 2, "minimum": 0, "example": 1 }, - "rf_flag": { + "external_ref": { + "$ref": "#/definitions/datatypes.JSONType-models_LicenseDBSchemaExtension" + }, + "flag": { "type": "integer", "maximum": 2, "minimum": 0, "example": 1 }, - "rf_fullname": { + "fullname": { "type": "string", "example": "MIT License" }, - "rf_notes": { + "marydone": { + "type": "boolean" + }, + "notes": { "type": "string", "example": "This license has been superseded." }, - "rf_risk": { + "risk": { "type": "integer", "maximum": 5, "minimum": 0 }, - "rf_shortname": { + "shortname": { "type": "string", "example": "MIT" }, - "rf_source": { + "source": { "type": "string" }, - "rf_spdx_id": { + "spdx_id": { "type": "string", "example": "MIT" }, - "rf_text": { + "text": { "type": "string", "example": "MIT License Text here" }, - "rf_text_updatable": { + "text_updatable": { "type": "boolean" }, - "rf_url": { + "url": { "type": "string", "example": "https://opensource.org/licenses/MIT" } @@ -2045,84 +2045,84 @@ "models.LicenseUpdateJSONSchema": { "type": "object", "properties": { - "external_ref": { - "$ref": "#/definitions/datatypes.JSONType-models_LicenseDBSchemaExtension" - }, - "marydone": { - "type": "boolean", - "example": false - }, - "rf_FSFfree": { + "FSFfree": { "type": "boolean", "example": false }, - "rf_Fedora": { + "Fedora": { "type": "string", "example": "Fedora" }, - "rf_GPLv2compatible": { + "GPLv2compatible": { "type": "boolean", "example": false }, - "rf_GPLv3compatible": { + "GPLv3compatible": { "type": "boolean", "example": false }, - "rf_OSIapproved": { + "OSIapproved": { "type": "boolean", "example": false }, - "rf_active": { + "active": { "type": "boolean", "example": true }, - "rf_copyleft": { + "copyleft": { "type": "boolean", "example": false }, - "rf_detector_type": { + "detector_type": { "type": "integer", "maximum": 2, "minimum": 0, "example": 1 }, - "rf_flag": { + "external_ref": { + "$ref": "#/definitions/datatypes.JSONType-models_LicenseDBSchemaExtension" + }, + "flag": { "type": "integer", "maximum": 2, "minimum": 0, "example": 1 }, - "rf_fullname": { + "fullname": { "type": "string", "example": "MIT License" }, - "rf_notes": { + "marydone": { + "type": "boolean", + "example": false + }, + "notes": { "type": "string", "example": "This license has been superseded." }, - "rf_risk": { + "risk": { "type": "integer", "maximum": 5, "minimum": 0, "example": 1 }, - "rf_source": { + "source": { "type": "string", "example": "Source" }, - "rf_spdx_id": { + "spdx_id": { "type": "string", "example": "MIT" }, - "rf_text": { + "text": { "type": "string", "example": "MIT License Text here" }, - "rf_text_updatable": { + "text_updatable": { "type": "boolean", "example": false }, - "rf_url": { + "url": { "type": "string", "example": "https://opensource.org/licenses/MIT" } @@ -2508,7 +2508,7 @@ "properties": { "field": { "type": "string", - "example": "rf_text" + "example": "text" }, "search": { "type": "string", diff --git a/cmd/laas/docs/swagger.yaml b/cmd/laas/docs/swagger.yaml index 224be34..967cf06 100644 --- a/cmd/laas/docs/swagger.yaml +++ b/cmd/laas/docs/swagger.yaml @@ -60,7 +60,7 @@ definitions: example: 456 type: integer field: - example: rf_text + example: text type: string id: example: 789 @@ -106,68 +106,68 @@ definitions: type: object models.LicenseDB: properties: - external_ref: - $ref: '#/definitions/datatypes.JSONType-models_LicenseDBSchemaExtension' - marydone: - type: boolean - rf_FSFfree: + FSFfree: type: boolean - rf_Fedora: + Fedora: type: string - rf_GPLv2compatible: + GPLv2compatible: type: boolean - rf_GPLv3compatible: + GPLv3compatible: type: boolean - rf_OSIapproved: + OSIapproved: type: boolean - rf_active: + active: type: boolean - rf_add_date: + add_date: example: "2023-12-01T18:10:25.00+05:30" type: string - rf_copyleft: + copyleft: type: boolean - rf_detector_type: + detector_type: example: 1 maximum: 2 minimum: 0 type: integer - rf_flag: + external_ref: + $ref: '#/definitions/datatypes.JSONType-models_LicenseDBSchemaExtension' + flag: example: 1 maximum: 2 minimum: 0 type: integer - rf_fullname: + fullname: example: MIT License type: string - rf_notes: + marydone: + type: boolean + notes: example: This license has been superseded. type: string - rf_risk: + risk: maximum: 5 minimum: 0 type: integer - rf_shortname: + shortname: example: MIT type: string - rf_source: + source: type: string - rf_spdx_id: + spdx_id: example: MIT type: string - rf_text: + text: example: MIT License Text here type: string - rf_text_updatable: + text_updatable: type: boolean - rf_url: + url: example: https://opensource.org/licenses/MIT type: string required: - - rf_fullname - - rf_shortname - - rf_spdx_id - - rf_text + - fullname + - shortname + - spdx_id + - text type: object models.LicenseError: properties: @@ -257,66 +257,66 @@ definitions: type: object models.LicenseUpdateJSONSchema: properties: - external_ref: - $ref: '#/definitions/datatypes.JSONType-models_LicenseDBSchemaExtension' - marydone: + FSFfree: example: false type: boolean - rf_FSFfree: - example: false - type: boolean - rf_Fedora: + Fedora: example: Fedora type: string - rf_GPLv2compatible: + GPLv2compatible: example: false type: boolean - rf_GPLv3compatible: + GPLv3compatible: example: false type: boolean - rf_OSIapproved: + OSIapproved: example: false type: boolean - rf_active: + active: example: true type: boolean - rf_copyleft: + copyleft: example: false type: boolean - rf_detector_type: + detector_type: example: 1 maximum: 2 minimum: 0 type: integer - rf_flag: + external_ref: + $ref: '#/definitions/datatypes.JSONType-models_LicenseDBSchemaExtension' + flag: example: 1 maximum: 2 minimum: 0 type: integer - rf_fullname: + fullname: example: MIT License type: string - rf_notes: + marydone: + example: false + type: boolean + notes: example: This license has been superseded. type: string - rf_risk: + risk: example: 1 maximum: 5 minimum: 0 type: integer - rf_source: + source: example: Source type: string - rf_spdx_id: + spdx_id: example: MIT type: string - rf_text: + text: example: MIT License Text here type: string - rf_text_updatable: + text_updatable: example: false type: boolean - rf_url: + url: example: https://opensource.org/licenses/MIT type: string type: object @@ -594,7 +594,7 @@ definitions: models.SearchLicense: properties: field: - example: rf_text + example: text type: string search: enum: @@ -911,12 +911,12 @@ paths: in: query name: externalRef type: string - - default: rf_shortname + - default: shortname description: Sort by field enum: - - rf_spdx_id - - rf_shortname - - rf_fullname + - spdx_id + - shortname + - fullname in: query name: sort_by type: string diff --git a/pkg/api/licenses.go b/pkg/api/licenses.go index ba93978..7551fb7 100644 --- a/pkg/api/licenses.go +++ b/pkg/api/licenses.go @@ -49,8 +49,8 @@ import ( // @Param page query int false "Page number" // @Param limit query int false "Limit of responses per page" // @Param externalRef query string false "External reference parameters" -// @Param sort_by query string false "Sort by field" Enums(rf_spdx_id, rf_shortname, rf_fullname) default(rf_shortname) -// @Param order_by query string false "Asc or desc ordering" Enums(asc, desc) default(asc) +// @Param sort_by query string false "Sort by field" Enums(spdx_id, shortname, fullname) default(shortname) +// @Param order_by query string false "Asc or desc ordering" Enums(asc, desc) default(asc) // @Success 200 {object} models.LicenseResponse "Filtered licenses" // @Failure 400 {object} models.LicenseError "Invalid value" // @Security ApiKeyAuth || {} @@ -170,8 +170,8 @@ func FilterLicense(c *gin.Context) { sortBy := c.Query("sort_by") orderBy := c.Query("order_by") queryOrderString := "" - if sortBy != "" && (sortBy == "rf_spdx_id" || sortBy == "rf_shortname" || sortBy == "rf_fullname") { - queryOrderString += sortBy + if sortBy != "" && (sortBy == "spdx_id" || sortBy == "shortname" || sortBy == "fullname") { + queryOrderString += "rf_" + sortBy } else { queryOrderString += "rf_shortname" } @@ -412,12 +412,12 @@ func UpdateLicense(c *gin.Context) { er := models.LicenseError{ Status: http.StatusBadRequest, Message: "Text is not updatable", - Error: "Field `rf_text_updatable` needs to be true to update the text", + Error: "Field `text_updatable` needs to be true to update the text", Path: c.Request.URL.Path, Timestamp: time.Now().Format(time.RFC3339), } c.JSON(http.StatusBadRequest, er) - return errors.New("field `rf_text_updatable` needs to be true to update the text") + return errors.New("field `text_updatable` needs to be true to update the text") } // Update flag to indicate the license text was updated. @@ -767,6 +767,8 @@ func SearchInLicense(c *gin.Context) { return } + input.Field = "rf_" + input.Field + var license []models.LicenseDB query := db.DB.Model(&license) diff --git a/pkg/models/types.go b/pkg/models/types.go index 8312a64..717662c 100644 --- a/pkg/models/types.go +++ b/pkg/models/types.go @@ -19,50 +19,50 @@ import ( // It provides structured storage for license-related information. type LicenseDB struct { Id int64 `json:"-" gorm:"primary_key;column:rf_id" example:"123"` - Shortname *string `json:"rf_shortname" gorm:"unique;not null;column:rf_shortname" validate:"required" example:"MIT"` - Fullname *string `json:"rf_fullname" gorm:"column:rf_fullname;not null" validate:"required" example:"MIT License"` - Text *string `json:"rf_text" gorm:"column:rf_text;not null" validate:"required" example:"MIT License Text here"` - Url *string `json:"rf_url" gorm:"column:rf_url;default:'';not null" example:"https://opensource.org/licenses/MIT"` - AddDate time.Time `json:"rf_add_date" gorm:"default:CURRENT_TIMESTAMP;column:rf_add_date" example:"2023-12-01T18:10:25.00+05:30"` - Copyleft *bool `json:"rf_copyleft" gorm:"column:rf_copyleft;not null;default:false"` - FSFfree *bool `json:"rf_FSFfree" gorm:"column:rf_FSFfree;not null;default:false"` - OSIapproved *bool `json:"rf_OSIapproved" gorm:"column:rf_OSIapproved;not null;default:false"` - GPLv2compatible *bool `json:"rf_GPLv2compatible" gorm:"column:rf_GPLv2compatible;not null;default:false"` - GPLv3compatible *bool `json:"rf_GPLv3compatible" gorm:"column:rf_GPLv3compatible;not null;default:false"` - Notes *string `json:"rf_notes" gorm:"column:rf_notes;not null;default:''" example:"This license has been superseded."` - Fedora *string `json:"rf_Fedora" gorm:"column:rf_Fedora;not null;default:''"` - TextUpdatable *bool `json:"rf_text_updatable" gorm:"column:rf_text_updatable;not null;default:false"` - DetectorType *int64 `json:"rf_detector_type" gorm:"column:rf_detector_type;not null;default:1" validate:"omitempty,min=0,max=2" example:"1"` - Active *bool `json:"rf_active" gorm:"column:rf_active;not null;default:true"` - Source *string `json:"rf_source" gorm:"column:rf_source;not null;default:''"` - SpdxId *string `json:"rf_spdx_id" gorm:"column:rf_spdx_id;not null" validate:"required" example:"MIT"` - Risk *int64 `json:"rf_risk" gorm:"column:rf_risk;not null;default:0" validate:"omitempty,min=0,max=5"` - Flag *int64 `json:"rf_flag" gorm:"default:1;column:rf_flag;not null;default:0" validate:"omitempty,min=0,max=2" example:"1"` + Shortname *string `json:"shortname" gorm:"unique;not null;column:rf_shortname" validate:"required" example:"MIT"` + Fullname *string `json:"fullname" gorm:"column:rf_fullname;not null" validate:"required" example:"MIT License"` + Text *string `json:"text" gorm:"column:rf_text;not null" validate:"required" example:"MIT License Text here"` + Url *string `json:"url" gorm:"column:rf_url;default:'';not null" example:"https://opensource.org/licenses/MIT"` + AddDate time.Time `json:"add_date" gorm:"default:CURRENT_TIMESTAMP;column:rf_add_date" example:"2023-12-01T18:10:25.00+05:30"` + Copyleft *bool `json:"copyleft" gorm:"column:rf_copyleft;not null;default:false"` + FSFfree *bool `json:"FSFfree" gorm:"column:rf_FSFfree;not null;default:false"` + OSIapproved *bool `json:"OSIapproved" gorm:"column:rf_OSIapproved;not null;default:false"` + GPLv2compatible *bool `json:"GPLv2compatible" gorm:"column:rf_GPLv2compatible;not null;default:false"` + GPLv3compatible *bool `json:"GPLv3compatible" gorm:"column:rf_GPLv3compatible;not null;default:false"` + Notes *string `json:"notes" gorm:"column:rf_notes;not null;default:''" example:"This license has been superseded."` + Fedora *string `json:"Fedora" gorm:"column:rf_Fedora;not null;default:''"` + TextUpdatable *bool `json:"text_updatable" gorm:"column:rf_text_updatable;not null;default:false"` + DetectorType *int64 `json:"detector_type" gorm:"column:rf_detector_type;not null;default:1" validate:"omitempty,min=0,max=2" example:"1"` + Active *bool `json:"active" gorm:"column:rf_active;not null;default:true"` + Source *string `json:"source" gorm:"column:rf_source;not null;default:''"` + SpdxId *string `json:"spdx_id" gorm:"column:rf_spdx_id;not null" validate:"required" example:"MIT"` + Risk *int64 `json:"risk" gorm:"column:rf_risk;not null;default:0" validate:"omitempty,min=0,max=5"` + Flag *int64 `json:"flag" gorm:"default:1;column:rf_flag;not null;default:0" validate:"omitempty,min=0,max=2" example:"1"` Marydone *bool `json:"marydone" gorm:"column:marydone;not null;default:false"` ExternalRef datatypes.JSONType[LicenseDBSchemaExtension] `json:"external_ref"` } func (l *LicenseDB) BeforeSave(tx *gorm.DB) (err error) { if l.Shortname != nil && *l.Shortname == "" { - return errors.New("rf_shortname cannot be an empty string") + return errors.New("shortname cannot be an empty string") } if l.Fullname != nil && *l.Fullname == "" { - return errors.New("rf_fullname cannot be an empty string") + return errors.New("fullname cannot be an empty string") } if l.Text != nil && *l.Text == "" { - return errors.New("rf_text cannot be an empty string") + return errors.New("text cannot be an empty string") } if l.SpdxId != nil && *l.SpdxId == "" { - return errors.New("rf_spdx_id cannot be an empty string") + return errors.New("spdx_id cannot be an empty string") } if l.Risk != nil && (*l.Risk < 0 && *l.Risk > 5) { - return errors.New("rf_risk can have values from 0 to 5 only") + return errors.New("risk can have values from 0 to 5 only") } if l.Flag != nil && (*l.Flag < 0 || *l.Flag > 2) { - return errors.New("rf_flag can have values from 0 to 2 only") + return errors.New("flag can have values from 0 to 2 only") } if l.DetectorType != nil && (*l.DetectorType < 0 || *l.DetectorType > 2) { - return errors.New("rf_detector_type can have values from 0 to 2 only") + return errors.New("detector_type can have values from 0 to 2 only") } return } @@ -71,24 +71,24 @@ func (l *LicenseDB) BeforeSave(tx *gorm.DB) (err error) { type LicenseUpdateJSONSchema struct { Id int64 `json:"-" example:"123"` Shortname *string `json:"-" example:"MIT"` - Fullname *string `json:"rf_fullname" example:"MIT License"` - Text *string `json:"rf_text" example:"MIT License Text here"` - Url *string `json:"rf_url" example:"https://opensource.org/licenses/MIT"` + Fullname *string `json:"fullname" example:"MIT License"` + Text *string `json:"text" example:"MIT License Text here"` + Url *string `json:"url" example:"https://opensource.org/licenses/MIT"` AddDate time.Time `json:"-" example:"2023-12-01T18:10:25.00+05:30"` - Copyleft *bool `json:"rf_copyleft" example:"false"` - FSFfree *bool `json:"rf_FSFfree" example:"false"` - OSIapproved *bool `json:"rf_OSIapproved" example:"false"` - GPLv2compatible *bool `json:"rf_GPLv2compatible" example:"false"` - GPLv3compatible *bool `json:"rf_GPLv3compatible" example:"false"` - Notes *string `json:"rf_notes" example:"This license has been superseded."` - Fedora *string `json:"rf_Fedora" example:"Fedora"` - TextUpdatable *bool `json:"rf_text_updatable" example:"false"` - DetectorType *int64 `json:"rf_detector_type" validate:"omitempty,min=0,max=2" example:"1"` - Active *bool `json:"rf_active" example:"true"` - Source *string `json:"rf_source" example:"Source"` - SpdxId *string `json:"rf_spdx_id" example:"MIT"` - Risk *int64 `json:"rf_risk" validate:"omitempty,min=0,max=5" example:"1"` - Flag *int64 `json:"rf_flag" validate:"omitempty,min=0,max=2" example:"1"` + Copyleft *bool `json:"copyleft" example:"false"` + FSFfree *bool `json:"FSFfree" example:"false"` + OSIapproved *bool `json:"OSIapproved" example:"false"` + GPLv2compatible *bool `json:"GPLv2compatible" example:"false"` + GPLv3compatible *bool `json:"GPLv3compatible" example:"false"` + Notes *string `json:"notes" example:"This license has been superseded."` + Fedora *string `json:"Fedora" example:"Fedora"` + TextUpdatable *bool `json:"text_updatable" example:"false"` + DetectorType *int64 `json:"detector_type" validate:"omitempty,min=0,max=2" example:"1"` + Active *bool `json:"active" example:"true"` + Source *string `json:"source" example:"Source"` + SpdxId *string `json:"spdx_id" example:"MIT"` + Risk *int64 `json:"risk" validate:"omitempty,min=0,max=5" example:"1"` + Flag *int64 `json:"flag" validate:"omitempty,min=0,max=2" example:"1"` Marydone *bool `json:"marydone" example:"false"` ExternalRef datatypes.JSONType[LicenseDBSchemaExtension] `json:"external_ref"` } @@ -229,7 +229,7 @@ type UserResponse struct { // SearchLicense struct represents the input needed to search in a license. type SearchLicense struct { - Field string `json:"field" binding:"required" example:"rf_text"` + Field string `json:"field" binding:"required" example:"text"` SearchTerm string `json:"search_term" binding:"required" example:"MIT License"` Search string `json:"search" enums:"fuzzy,full_text_search"` } @@ -250,7 +250,7 @@ type Audit struct { // ChangeLog struct represents a change entity with certain attributes and properties type ChangeLog struct { Id int64 `json:"id" gorm:"primary_key" example:"789"` - Field string `json:"field" example:"rf_text"` + Field string `json:"field" example:"text"` UpdatedValue *string `json:"updated_value" example:"New license text"` OldValue *string `json:"old_value" example:"Old license text"` AuditId int64 `json:"audit_id" example:"456"` diff --git a/pkg/utils/util.go b/pkg/utils/util.go index 4afb3b2..ea43ba6 100644 --- a/pkg/utils/util.go +++ b/pkg/utils/util.go @@ -247,7 +247,7 @@ func InsertOrUpdateLicenseOnImport(tx *gorm.DB, license *models.LicenseDB, exter } if *newLicense.Flag == 2 { - message = "all fields except rf_text were updated. rf_text was updated manually and cannot be overwritten in an import." + message = "all fields except text were updated. text was updated manually and cannot be overwritten in an import." importStatus = IMPORT_LICENSE_UPDATED_EXCEPT_TEXT // error is not returned here as it will rollback the transaction } else {