camaraproject / Commonalities

Repository to describe, develop, document and test the common guidelines and assets for CAMARA APIs
Apache License 2.0
9 stars 24 forks source link

Linting rules problem with Traffic Influence API #161

Closed FabrizioMoggio closed 3 months ago

FabrizioMoggio commented 4 months ago

Problem description Using Spectral over the TI API a non correct error is returned.

https://github.com/camaraproject/EdgeCloud/issues/191#issuecomment-1956675044

Expected action Correction of: https://github.com/camaraproject/Commonalities/blob/main/artifacts/linting_rules/.spectral.yml. Section starting on raw 103: "camara-http-methods:"

Additional context According to my understanding, the tool doesn't recognize some methods as GET, PATCH and DELETE. Even if they actually are GET, PATCH and DELETE. I suppose the reason is that in the TI API, we defined "parameters" as child of "paths" rather than child of the "methods". Our implementation is correct according to the OpenAPI Specifications (https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#path-item-object). We have used the "parameters" description as child of "path". With our solution we avoid duplicating the parameter definition for the different methods (Get, Patch and Delete). With the suggested approach we should define the same parameter three times in the code with the risk of code misalignment.

Reference in the TI API: raw 2012 https://github.com/camaraproject/EdgeCloud/blob/32c7ca4faf54fc14fa510c1212f34a0f43a42bfd/code/API_definitions/Traffic%20Influence/Traffic_Influence.yaml

rartych commented 4 months ago

Thank you @FabrizioMoggio for pointing this out with detailed context. The rule "camara-http-methods" should be corrected with "parameters" field in the Path Item object.