Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAPI suggests that "operationId" (or "operationref") is mandatory. #6326

Merged
merged 6 commits into from
Jul 11, 2024

Conversation

lemmy
Copy link
Contributor

@lemmy lemmy commented Jul 3, 2024

nt

@lemmy lemmy force-pushed the mku-OpenAPIOperationId branch 2 times, most recently from 5eab036 to 9eb0b4d Compare July 4, 2024 00:33
@achamayou
Copy link
Member

achamayou commented Jul 4, 2024

From https://swagger.io/specification/:

In the following description, if a field is not explicitly REQUIRED or described with a MUST or SHALL, it can be considered OPTIONAL.

The description for operationId is under https://swagger.io/specification/:

Unique string used to identify the operation. The id MUST be unique among all operations described in the API. The operationId value is case-sensitive. Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow common programming naming conventions.

There is no mention of REQUIRED, and although the unicity is a MUST, there is no explicit statement about existence. Issues on the OpenAPI repository (#1019, #1907) asking for it be made mandatory have been rejected, and clarify that it is not mandatory.

This next bit is my opinion: there is no valid reason to demand that someone manually writes an operationId, creating one from the path/verb is trivial to automate correctly. It is bizarre that the SDK generators are both demanding this manual de-normalisation while complaining about duplicates.

Anyway, there is clearly no downside to having this, thank you for adding it.

@achamayou
Copy link
Member

To fix the tests (I tried to do, but I can't seem to write to your fork), it is necessary to:

  1. rev up openapi_info.document_version in src/node/rpc/node_frontend.h, src/node/rpc/member_frontend.h and samples/app/logging/logging.cpp (I suggest +0.1.0 in this case, but any amount will work).
  2. re-build
  3. re-run the schema test ./tests.sh -VV -R schema which will produce the new OpenAPI schemas (it will fail, but that's ok)
  4. commit them

@lemmy

This comment was marked as resolved.

@achamayou

This comment was marked as resolved.

@lemmy
Copy link
Contributor Author

lemmy commented Jul 8, 2024

Using the verb concatenated with the camel-cased path appears to be a common default. For example, the verb delete combined with the path app/log/private/all becomes the operationId DeleteAppLogPrivateAll. Does the CCF codebase have a built-in function for converting a string to camel case?

@eddyashton
Copy link
Member

Does the CCF codebase have a built-in function for converting a string to camel case?

No, though it's easy enough to add. Proposed impl is here: #6349, let me know if that works for you and we'll get it merged.

lemmy and others added 4 commits July 10, 2024 10:34
… (or "operationref") is mandatory.

Signed-off-by: Markus Alexander Kuppe <[email protected]>
- Move http verb before path
- Handle path templates
- Camel-Case http path and verb

Signed-off-by: Markus Alexander Kuppe <[email protected]>
@lemmy lemmy marked this pull request as ready for review July 10, 2024 17:46
@lemmy lemmy requested a review from a team as a code owner July 10, 2024 17:46
@eddyashton eddyashton added this pull request to the merge queue Jul 11, 2024
Merged via the queue into microsoft:main with commit 79618c2 Jul 11, 2024
17 checks passed
@eddyashton eddyashton deleted the mku-OpenAPIOperationId branch July 11, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants