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

fix: callback operation ids #262

Merged
merged 3 commits into from
Dec 21, 2023
Merged

fix: callback operation ids #262

merged 3 commits into from
Dec 21, 2023

Conversation

mallachari
Copy link
Contributor

Addresses: https://github.com/stoplightio/platform-internal/issues/18498

Motivation and Context

Callback ids are currently being generated based on operation method and path. This may lead to duplicated ids in case where one operation has more than one callbacks defined.

Description

Adds additional key property (callback name) when generating ids for callback nodes.

How Has This Been Tested?

Tests updated

Screenshot(s)/recordings(s)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

@@ -89,6 +89,7 @@ export const transformOasEndpointOperation: TranslateFunction<
parentId: serviceId,
method,
path: name,
key: key ?? 'unknown',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should we generate random string in that case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it would have to be something stable. i'm kind of thinking this should throw but @P0lip might have a suggestion

Copy link
Contributor

@P0lip P0lip Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can leave an empty key key ?? ''. That's what we do for schemas

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@@ -36,6 +36,7 @@ export interface ITransformEndpointOperationOpts<T extends Fragment> {
document: T;
name: string;
method: string;
key?: string;
Copy link
Contributor Author

@mallachari mallachari Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed because transformOas3Operation uses this type

@mallachari mallachari marked this pull request as ready for review December 20, 2023 20:38
@mallachari mallachari requested review from a team and daniel-white and removed request for a team December 20, 2023 20:38
httpCallbackOperation: (props: Context & { method: string; path: string }) => {
return join(['http_callback', props.parentId, props.method, props.path]);
httpCallbackOperation: (props: Context & { method: string; path: string; key: string }) => {
return join(['http_callback', props.parentId, props.method, props.path, props.key]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets flip this around so that its between parent and method

@mallachari mallachari merged commit 3414259 into master Dec 21, 2023
3 checks passed
@mallachari mallachari deleted the fix/callback-operation-id branch December 21, 2023 15:46
@stoplight-bot
Copy link
Collaborator

🎉 This PR is included in version 7.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants