-
Notifications
You must be signed in to change notification settings - Fork 27
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: creation of a new .getOperationById()
method
#892
Conversation
packages/oas/test/index.test.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
best to look at this file with whitespace changes turned off 🙃
@@ -76,13 +76,13 @@ Because this library has full TypeScript types and docblocks this README is not | |||
<!-- prettier-ignore-start --> | |||
| Method | Description | | |||
| :--- | :--- | | |||
| `#dereference()` | Dereference the current OpenAPI definition. Note that this will ignore circular references. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed these #
to a .
to better indicate that they're instance methods, not static.
| `.findOperation()` | Discover an operation with the current OpenAPI definition that matches a given URL and HTTP method. | | ||
| `.findOperationWithoutMethod()` | Like `.findOperation()` but without supplying an HTTP method. | | ||
| `.getOperation()` | Same as `.findOperation()` but this returns an instance of the `Operation` class. | | ||
| `.getOperationById()` | Retrieve an operation in an OpenAPI definition by an `operationId`. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs for the new method ^
await circular.dereference(); | ||
|
||
const reduced = reducer(circular.api as any, { paths: { '/anything': ['get'] } }); | ||
expect(Object.keys(reduced.paths['/anything'])).toStrictEqual(['get', 'post']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
someday 😭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small typo otherwise LGTM!
await circular.dereference(); | ||
|
||
const reduced = reducer(circular.api as any, { paths: { '/anything': ['get'] } }); | ||
expect(Object.keys(reduced.paths['/anything'])).toStrictEqual(['get', 'post']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
someday 😭
Co-authored-by: Kanad Gupta <[email protected]>
🧰 Changes
This creates a new
.getOperationById()
method on the mainOas
instance that allows us to retrieve anOperation
orWebhook
instance by either theoperationId
that's set to the schema, or if that's missing then the default generated behavior fromOperation.getOperationId()
.I plan on using this within our main app to retrieve
path
andmethod
for an operation based on the data I have for it: just anoperationId
.🧬 QA & Testing
The tests I wrote have been sort of ported over from the
Operation.getOperationById()
tests but heavily reduced as I don't need to re-test that thing.