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.
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 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
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 {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Eliminate the lodash.get dependency and replace its usage with optional chaining, default values and type narrowing.
close #146