Could we be consistent naming fields of Entities? #428
carlosthe19916
started this conversation in
General
Replies: 1 comment 1 reply
-
|
Judging by the URLs I would say you get What worries me a bit is the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
GET /api/v1/packagethen I get:{ "items": [ { "uuid": "f7d25fe0-2f5c-5feb-854f-762b7ecd6527", "purl": "pkg://npm/[email protected]", "base": { "uuid": "41de79a7-d36e-57e2-83ab-984875221b35", "purl": "pkg://npm/highlight-words-core" }, "version": { "uuid": "f7d25fe0-2f5c-5feb-854f-762b7ecd6527", "purl": "pkg://npm/[email protected]", "version": "1.2.0" } } ], "total": 14054 }GET /api/v1/sbom/{key}/packagesI get:{ "items": [ { "id": "SPDXRef-008b7ce8-0a74-4140-9625-93645d154c3f", "name": "python-syspurpose", "purl": [ "pkg://rpm/redhat/[email protected]_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
ADTO 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 thingBeta Was this translation helpful? Give feedback.
All reactions