Skip to content

Commit

Permalink
Include the object id in schema
Browse files Browse the repository at this point in the history
Signed-off-by: Keshav Priyadarshi <[email protected]>
  • Loading branch information
keshav-space committed Jul 11, 2024
1 parent bc8e854 commit 2c08b79
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 6 deletions.
11 changes: 5 additions & 6 deletions fedcode/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ class Repository(ModelSchema):
"""
class Meta:
model = models.Repository
exclude = ["id", "admin"]
exclude = ["admin"]


class Vulnerability(ModelSchema):
repo: Repository

class Meta:
model = models.Vulnerability
exclude = ["id"]

fields = "__all__"

class Reputation(ModelSchema):
"""
Expand All @@ -43,7 +42,7 @@ class Reputation(ModelSchema):
"""
class Meta:
model = models.Reputation
fields = ["voter", "positive"]
fields = ["object_id", "voter", "positive"]


class Note(ModelSchema):
Expand All @@ -59,7 +58,7 @@ class Note(ModelSchema):

class Meta:
model = models.Note
exclude = ["id"]
fields = "__all__"


Note.model_rebuild()
Expand All @@ -74,4 +73,4 @@ class Package(ModelSchema):

class Meta:
model = models.Package
exclude = ["id", "service"]
exclude = ["service"]
39 changes: 39 additions & 0 deletions schemas/package.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
"reply_to": {
"$ref": "#/$defs/Note"
},
"id": {
"anyOf": [
{
"format": "uuid",
"type": "string"
},
{
"type": "null"
}
],
"description": "The object's unique global identifier",
"title": "Id"
},
"acct": {
"maxLength": 200,
"title": "Acct",
Expand Down Expand Up @@ -99,6 +112,19 @@
"Reputation": {
"description": "https://www.w3.org/TR/activitystreams-vocabulary/#dfn-like\nhttps://www.w3.org/ns/activitystreams#Dislike",
"properties": {
"object_id": {
"anyOf": [
{
"format": "uuid",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Object Id"
},
"voter": {
"description": "security@vcio",
"maxLength": 100,
Expand Down Expand Up @@ -145,6 +171,19 @@
"title": "Local",
"type": "boolean"
},
"id": {
"anyOf": [
{
"format": "uuid",
"type": "string"
},
{
"type": "null"
}
],
"description": "The object's unique global identifier",
"title": "Id"
},
"purl": {
"description": "PURL (no version) ex: @pkg:maven/org.apache.logging",
"maxLength": 300,
Expand Down
27 changes: 27 additions & 0 deletions schemas/vulnerability.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@
"Repository": {
"description": "A git repository used as a backing storage for Package and vulnerability data",
"properties": {
"id": {
"anyOf": [
{
"format": "uuid",
"type": "string"
},
{
"type": "null"
}
],
"description": "The object's unique global identifier",
"title": "Id"
},
"url": {
"description": "Git Repository url ex: https://github.com/nexB/vulnerablecode-data",
"title": "Url",
Expand Down Expand Up @@ -72,6 +85,20 @@
"repo": {
"$ref": "#/$defs/Repository"
},
"id": {
"anyOf": [
{
"maxLength": 20,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Unique identifier for a vulnerability in the external representation. It is prefixed with VCID-",
"title": "Id"
},
"remote_url": {
"anyOf": [
{
Expand Down

0 comments on commit 2c08b79

Please sign in to comment.