- 
 
- 
  Notifications
 You must be signed in to change notification settings 
- Fork 77
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
 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1631843 to
 4a4f5ab  
 Compare
 
 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>
171cac0 to
 9c54332  
 Compare
 
 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.getusages with optional chaining and default values
- Consolidate RequestInitExtendedinto a single definition insrc/types.ts
- Introduce buildEnumObjectandgetArrayTypein 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 Nullabletype and unifiedRequestInitExtendedinterface | 
| src/swagger/handleJson.ts | Remove lodash.get, use destructuring/optional chaining, update import | 
| src/openapi3/types.ts | Remove duplicate RequestInitExtendeddefinition | 
| src/openapi3/parseOpenApi3Documentation.ts | Update import of RequestInitExtended | 
| src/openapi3/handleJson.ts | Replace lodash.get, addbuildEnumObject/getArrayType, wrap parse | 
| src/openapi3/dereferencedOpenApiv3.ts | Add types for dereferenced OpenAPI v3 schemas | 
| src/hydra/types.ts | Remove duplicate RequestInitExtendeddefinition | 
| 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.getand 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 buildEnumObjectto 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 removeTrailingSlashfunction is duplicated insrc/openapi3/handleJson.ts; consider extracting it into a shared utility.
export function removeTrailingSlash(url: string): string {
Uh oh!
There was an error while loading. Please reload this page.
Eliminate the lodash.get dependency and replace its usage with optional chaining, default values and type narrowing.
close #146