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

feat: pass the Operation object to methodNameBuilder #696

Merged
merged 5 commits into from
Jun 24, 2024

Conversation

anchan828
Copy link
Contributor

Closes #695

Copy link

stackblitz bot commented Jun 19, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

changeset-bot bot commented Jun 19, 2024

🦋 Changeset detected

Latest commit: 4efe4a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hey-api/openapi-ts Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jun 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hey-api-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2024 2:54pm

Comment on lines 128 to 140
* Customise the method name of methods within the service
*/
methodNameBuilder?: (service: string, operationId: string) => string;
* Customise the method name of methods within the service. By default, operationName is used.
*/
methodNameBuilder?: (
service: string,
/**
* Method name used by default.
*/
operationName: string,
/**
* The operationId from OpenAPI specification.
*/
operationId: string | null,
) => string;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If possible, I would like to pass an object to the methodNameBuilder, but for backward compatibility, I have added an additional argument.

I think this is the ideal style:

methodNameBuilder?: (
  service: string,
  operation: {
    name: string,
    id: string | null,
  }
) => string;

or

methodNameBuilder?: (
  args: {
    service: string,
    operationName: string,
    operationId: string | null,
  }
) => string;

Copy link
Member

Choose a reason for hiding this comment

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

Can you pass a single operation object here? We'll write migration notes, it's not hard to migrate

@@ -42,6 +42,7 @@ export const getOperation = ({
deprecated: op.deprecated === true,
description: op.description || null,
errors: [],
id: op.operationId || null,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added id property to Operation

@anchan828 anchan828 changed the title feat: add operationId to methodNameBuilder feat: add raw operationId to methodNameBuilder Jun 19, 2024
Copy link
Member

@mrlubos mrlubos left a comment

Choose a reason for hiding this comment

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

Let's pass a whole object!

@anchan828 anchan828 changed the title feat: add raw operationId to methodNameBuilder feat: pass the Operation object to methodNameBuilder Jun 19, 2024
@anchan828
Copy link
Contributor Author

anchan828 commented Jun 19, 2024

Hi @mrlubos, Is this all right? 0e99675

@anchan828 anchan828 requested a review from mrlubos June 19, 2024 13:22
Copy link
Member

@mrlubos mrlubos left a comment

Choose a reason for hiding this comment

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

Yup, nice one! I'll need to write migration docs separately

Copy link

codecov bot commented Jun 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.23%. Comparing base (a9dfda0) to head (4efe4a3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #696      +/-   ##
==========================================
+ Coverage   70.89%   74.23%   +3.33%     
==========================================
  Files          76       76              
  Lines        7984     7990       +6     
  Branches      696      752      +56     
==========================================
+ Hits         5660     5931     +271     
+ Misses       2321     2056     -265     
  Partials        3        3              
Flag Coverage Δ
unittests 74.23% <100.00%> (+3.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mrlubos mrlubos merged commit 41cca18 into hey-api:main Jun 24, 2024
16 checks passed
@github-actions github-actions bot mentioned this pull request Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using Operation object with the methodNameGenarator
2 participants