-
Notifications
You must be signed in to change notification settings - Fork 47
Could we be consistent naming fields of Entities? #428
-
- If I hit
GET /api/v1/packagethen I get:
{
"items": [
{
"uuid": "f7d25fe0-2f5c-5feb-854f-762b7ecd6527",
"purl": "pkg://npm/highlight-words-core@1.2.0",
"base": {
"uuid": "41de79a7-d36e-57e2-83ab-984875221b35",
"purl": "pkg://npm/highlight-words-core"
},
"version": {
"uuid": "f7d25fe0-2f5c-5feb-854f-762b7ecd6527",
"purl": "pkg://npm/highlight-words-core@1.2.0",
"version": "1.2.0"
}
}
],
"total": 14054
}- If I hit
GET /api/v1/sbom/{key}/packagesI get:
{
"items": [
{
"id": "SPDXRef-008b7ce8-0a74-4140-9625-93645d154c3f",
"name": "python-syspurpose",
"purl": [
"pkg://rpm/redhat/python-syspurpose@1.24.51-1.el7_9?arch=s390x"
]
},
],
"total": 445
}Both endpoints are supposed to give me PACKAGES yet both endpoints are not returning the same data (DTO structure)
An A DTO model should have the exact same fields everywhere it appears.
-
If we call something
A, thenAshould have the same fields everywhere. If not, perhaps we should make a distinction in naming entities and instead ofA, we needAandBfor naming entities. -
If we were modeling a
PersonDTO that hasname,surname. Then I expect aPersonto have exactly those fields everywhere regardless of where it comes from. It is hard to deal with situations where if i hit an endpoint the person hasnameandsurnameand if I hit another different endpoint the person hasfirstname,secondname. -
In the case of the packages above. If you think that technically it is correct to return different bodies for packages endpoints then I think we should reconsider our naming and instead of
GET /api/v1/packageandGET /api/v1/sbom/{key}/packageswe have something likeGET /api/v1/purlsandGET /api/v1/sbom/{key}/package-names. My point is, we can not call 2 things with the same name, and have different DTOs for the same thing
Note: this also makes the remember the discussion about naming
Advisory[severity]in one endpoint while we haveAdvisory[average_severy]in another endpoints. Perhaps, only one of them should be namedAdvisory, and the other entity is could be renamed asRecommending(just random name). I hope I explained my point
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
Judging by the URLs I would say you get package and sbom/{key}/package. Translating into "packages" and "packages of an sbom". Which are two different things. And yes, naming is hard.
What worries me a bit is the package vs packages. As that feels like a pattern we should keep aligned.
Beta Was this translation helpful? Give feedback.
All reactions
-
I've been sticking to singulars, to avoid english weird plurals. Cacti, octopode, deer, fish.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 2