-
-
Notifications
You must be signed in to change notification settings - Fork 74
refactor: Remove lodash.get dependency #154
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
Conversation
Coverage Report
File Coverage
|
c739b9d
to
01354c9
Compare
a8143f1
to
1e37761
Compare
7423fa7
to
171cac0
Compare
* Removed duplicate definitions from `src/hydra/types.ts` and deleted `src/openapi3/types.ts`. * Added a single canonical `RequestInitExtended` interface in `src/types.ts`. * Updated all affected import paths across Hydra and OpenAPI3 modules. Signed-off-by: J3m5 <5523410+J3m5@users.noreply.github.com>
…stom guards * Introduce `src/openapi3/dereferencedOpenApiv3.ts`, providing fully-dereferenced versions of core OpenAPI 3 objects (Document, OperationObject, SchemaObject, etc.). * Refactor `handleJson.ts` to consume the new types: * Remove bespoke type-guard helpers (`isParameter`, `isSchema`, …). * Eliminate most explicit `as` casts and manual type-narrowing logic. * Simplify enum/array handling through shared helpers (`buildEnumObject`, `getArrayType`). Signed-off-by: J3m5 <5523410+J3m5@users.noreply.github.com>
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.
Pull Request Overview
This PR removes the lodash.get dependency by replacing its calls with native optional chaining, destructuring, and default values, centralizes the RequestInitExtended
type, and adds helper functions for enum and array handling.
- Replace all
lodash.get
usages with optional chaining and default values - Consolidate
RequestInitExtended
into a single definition insrc/types.ts
- Introduce
buildEnumObject
andgetArrayType
in the OpenAPI v3 handler
Reviewed Changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/types.ts | Add Nullable type and unified RequestInitExtended interface |
src/swagger/handleJson.ts | Remove lodash.get , use destructuring/optional chaining, update import |
src/openapi3/types.ts | Remove duplicate RequestInitExtended definition |
src/openapi3/parseOpenApi3Documentation.ts | Update import of RequestInitExtended |
src/openapi3/handleJson.ts | Replace lodash.get , add buildEnumObject /getArrayType , wrap parse |
src/openapi3/dereferencedOpenApiv3.ts | Add types for dereferenced OpenAPI v3 schemas |
src/hydra/types.ts | Remove duplicate RequestInitExtended definition |
src/hydra/parseHydraDocumentation.ts | Remove lodash.get , use optional chaining |
src/hydra/getParameters.ts | Update import of RequestInitExtended |
src/hydra/fetchResource.ts | Update type imports |
src/hydra/fetchJsonLd.ts | Update import of RequestInitExtended |
package.json | Remove lodash.get and its types |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (4)
src/swagger/handleJson.ts:10
- Provide a descriptive message when throwing errors instead of using an empty Error().
return url.slice(0, -1);
src/openapi3/handleJson.ts:49
- [nitpick] Add a JSDoc comment explaining the purpose, inputs, and outputs of
buildEnumObject
to improve readability.
function buildEnumObject(enumArray: SchemaObjectDereferenced["enum"]) {
src/swagger/handleJson.ts:46
- Include an informative message in this thrown Error to aid debugging and remove the // @todo placeholder.
throw new Error(); // @TODO
src/swagger/handleJson.ts:8
- [nitpick] The
removeTrailingSlash
function is duplicated insrc/openapi3/handleJson.ts
; consider extracting it into a shared utility.
export function removeTrailingSlash(url: string): string {
Eliminate the lodash.get dependency and replace its usage with optional chaining, default values and type narrowing.
close #146