Skip to content

Commit

Permalink
refactor(licenses): Add validation to license requests and code refactor
Browse files Browse the repository at this point in the history
Signed-off-by: deo002 <[email protected]>

fix(fix): Fix
  • Loading branch information
deo002 committed Sep 25, 2024
1 parent 8a98c86 commit e7a4827
Show file tree
Hide file tree
Showing 12 changed files with 684 additions and 1,245 deletions.
323 changes: 87 additions & 236 deletions cmd/laas/docs/docs.go

Large diffs are not rendered by default.

323 changes: 87 additions & 236 deletions cmd/laas/docs/swagger.json

Large diffs are not rendered by default.

229 changes: 63 additions & 166 deletions cmd/laas/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,60 +84,6 @@ definitions:
example: 200
type: integer
type: object
models.ExportLicenseDB:
properties:
external_ref:
$ref: '#/definitions/datatypes.JSONType-models_LicenseDBSchemaExtension'
marydone:
type: boolean
rf_FSFfree:
type: boolean
rf_Fedora:
type: string
rf_GPLv2compatible:
type: boolean
rf_GPLv3compatible:
type: boolean
rf_OSIapproved:
type: boolean
rf_active:
type: boolean
rf_add_date:
example: "2023-12-01T18:10:25.00+05:30"
type: string
rf_copyleft:
type: boolean
rf_detector_type:
example: 1
type: integer
rf_flag:
example: 1
type: integer
rf_fullname:
example: MIT License
type: string
rf_notes:
example: This license has been superseded.
type: string
rf_risk:
type: integer
rf_shortname:
example: MIT
type: string
rf_source:
type: string
rf_spdx_id:
example: MIT
type: string
rf_text:
example: MIT License Text here
type: string
rf_text_updatable:
type: boolean
rf_url:
example: https://opensource.org/licenses/MIT
type: string
type: object
models.ImportLicensesResponse:
properties:
data:
Expand Down Expand Up @@ -183,20 +129,23 @@ definitions:
type: boolean
rf_detector_type:
example: 1
maximum: 2
minimum: 0
type: integer
rf_flag:
example: 1
maximum: 2
minimum: 0
type: integer
rf_fullname:
example: MIT License
type: string
rf_id:
example: 123
type: integer
rf_notes:
example: This license has been superseded.
type: string
rf_risk:
maximum: 5
minimum: 0
type: integer
rf_shortname:
example: MIT
Expand All @@ -214,6 +163,11 @@ definitions:
rf_url:
example: https://opensource.org/licenses/MIT
type: string
required:
- rf_fullname
- rf_shortname
- rf_spdx_id
- rf_text
type: object
models.LicenseError:
properties:
Expand Down Expand Up @@ -266,81 +220,78 @@ definitions:
$ref: '#/definitions/models.LicenseMapShortnamesElement'
type: array
type: object
models.LicensePATCHRequestJSONSchema:
models.LicensePreviewResponse:
properties:
external_ref:
additionalProperties: true
type: object
marydone:
type: boolean
rf_FSFfree:
type: boolean
rf_Fedora:
type: string
rf_GPLv2compatible:
type: boolean
rf_GPLv3compatible:
type: boolean
rf_OSIapproved:
type: boolean
rf_active:
type: boolean
rf_copyleft:
type: boolean
rf_detector_type:
example: 1
type: integer
rf_flag:
example: 1
shortnames:
example:
- GPL-2.0-only
- GPL-2.0-or-later
items:
type: string
type: array
status:
example: 200
type: integer
rf_fullname:
example: MIT License
type: string
rf_notes:
example: This license has been superseded.
type: string
rf_risk:
example: 3
type: object
models.LicenseResponse:
properties:
data:
items:
$ref: '#/definitions/models.LicenseDB'
type: array
paginationmeta:
$ref: '#/definitions/models.PaginationMeta'
status:
example: 200
type: integer
rf_source:
type: string
rf_spdx_id:
example: MIT
type: string
rf_text:
example: MIT License Text here
type: string
rf_text_updatable:
type: boolean
rf_url:
example: https://opensource.org/licenses/MIT
type: string
type: object
models.LicensePOSTRequestJSONSchema:
models.LicenseShortnamesInput:
properties:
shortnames:
example:
- GPL-2.0-only
- GPL-2.0-or-later
items:
type: string
type: array
type: object
models.LicenseUpdateJSONSchema:
properties:
external_ref:
$ref: '#/definitions/datatypes.JSONType-models_LicenseDBSchemaExtension'
marydone:
example: false
type: boolean
rf_FSFfree:
example: false
type: boolean
rf_Fedora:
example: Fedora
type: string
rf_GPLv2compatible:
example: false
type: boolean
rf_GPLv3compatible:
example: false
type: boolean
rf_OSIapproved:
example: false
type: boolean
rf_active:
example: true
type: boolean
rf_copyleft:
example: false
type: boolean
rf_detector_type:
example: 1
maximum: 2
minimum: 0
type: integer
rf_flag:
example: 1
maximum: 2
minimum: 0
type: integer
rf_fullname:
example: MIT License
Expand All @@ -349,11 +300,12 @@ definitions:
example: This license has been superseded.
type: string
rf_risk:
example: 1
maximum: 5
minimum: 0
type: integer
rf_shortname:
example: MIT
type: string
rf_source:
example: Source
type: string
rf_spdx_id:
example: MIT
Expand All @@ -362,66 +314,11 @@ definitions:
example: MIT License Text here
type: string
rf_text_updatable:
example: false
type: boolean
rf_url:
example: https://opensource.org/licenses/MIT
type: string
required:
- external_ref
- marydone
- rf_FSFfree
- rf_Fedora
- rf_GPLv2compatible
- rf_GPLv3compatible
- rf_OSIapproved
- rf_active
- rf_copyleft
- rf_detector_type
- rf_flag
- rf_fullname
- rf_notes
- rf_risk
- rf_shortname
- rf_source
- rf_spdx_id
- rf_text
- rf_text_updatable
- rf_url
type: object
models.LicensePreviewResponse:
properties:
shortnames:
example:
- GPL-2.0-only
- GPL-2.0-or-later
items:
type: string
type: array
status:
example: 200
type: integer
type: object
models.LicenseResponse:
properties:
data:
items:
$ref: '#/definitions/models.LicenseDB'
type: array
paginationmeta:
$ref: '#/definitions/models.PaginationMeta'
status:
example: 200
type: integer
type: object
models.LicenseShortnamesInput:
properties:
shortnames:
example:
- GPL-2.0-only
- GPL-2.0-or-later
items:
type: string
type: array
type: object
models.Obligation:
properties:
Expand Down Expand Up @@ -1059,7 +956,7 @@ paths:
name: license
required: true
schema:
$ref: '#/definitions/models.LicensePOSTRequestJSONSchema'
$ref: '#/definitions/models.LicenseDB'
produces:
- application/json
responses:
Expand Down Expand Up @@ -1129,7 +1026,7 @@ paths:
name: license
required: true
schema:
$ref: '#/definitions/models.LicensePATCHRequestJSONSchema'
$ref: '#/definitions/models.LicenseUpdateJSONSchema'
produces:
- application/json
responses:
Expand Down Expand Up @@ -1169,7 +1066,7 @@ paths:
description: OK
schema:
items:
$ref: '#/definitions/models.ExportLicenseDB'
$ref: '#/definitions/models.LicenseDB'
type: array
"500":
description: Failed to fetch Licenses
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/gin-gonic/gin v1.9.1
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/joho/godotenv v1.5.1
github.com/stretchr/testify v1.8.3
github.com/stretchr/testify v1.9.0
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.0
github.com/swaggo/swag v1.16.2
Expand All @@ -31,15 +31,15 @@ require (
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/dave/jennifer v1.7.0
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/go-playground/validator/v10 v10.22.0
github.com/goccy/go-json v0.10.2 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
Expand All @@ -49,7 +49,7 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand Down
Loading

0 comments on commit e7a4827

Please sign in to comment.