-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Based on #2389 Featuring: - `Endpoint::deprecated()`, - `DependsOnMethod::deprecated()`, - `EndpointsFactory::build({ deprecated })` Deprecated route in the generated OpenAPI Documentation: ![2025-02-13_14-45-59](https://github.com/user-attachments/assets/c9b9a010-eb87-4922-9f46-d3fc992e30a5) Deprecated parameter in the OpenAPI Documentation: ![2025-02-13_14-46-30](https://github.com/user-attachments/assets/22000cf5-df73-4f84-8cb6-c94352018568)
- Loading branch information
Showing
34 changed files
with
546 additions
and
212 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,34 @@ | ||
import { keys, reject, equals } from "ramda"; | ||
import { AbstractEndpoint } from "./endpoint"; | ||
import { Method } from "./method"; | ||
import { Nesting } from "./nesting"; | ||
import { Routable } from "./routable"; | ||
|
||
export class DependsOnMethod extends Nesting { | ||
/** @desc [method, endpoint, siblingMethods] */ | ||
public readonly entries: ReadonlyArray<[Method, AbstractEndpoint, Method[]]>; | ||
export class DependsOnMethod extends Routable { | ||
readonly #endpoints: ConstructorParameters<typeof DependsOnMethod>[0]; | ||
|
||
constructor(endpoints: Partial<Record<Method, AbstractEndpoint>>) { | ||
super(); | ||
this.#endpoints = endpoints; | ||
} | ||
|
||
/** @desc [method, endpoint, siblingMethods] */ | ||
public get entries(): ReadonlyArray<[Method, AbstractEndpoint, Method[]]> { | ||
const entries: Array<(typeof this.entries)[number]> = []; | ||
const methods = keys(endpoints); // eslint-disable-line no-restricted-syntax -- liternal type required | ||
const methods = keys(this.#endpoints); // eslint-disable-line no-restricted-syntax -- literal type required | ||
for (const method of methods) { | ||
const endpoint = endpoints[method]; | ||
const endpoint = this.#endpoints[method]; | ||
if (endpoint) | ||
entries.push([method, endpoint, reject(equals(method), methods)]); | ||
} | ||
this.entries = Object.freeze(entries); | ||
return Object.freeze(entries); | ||
} | ||
|
||
public override deprecated() { | ||
const deprecatedEndpoints = Object.entries(this.#endpoints).reduce( | ||
(agg, [method, endpoint]) => | ||
Object.assign(agg, { [method]: endpoint.deprecated() }), | ||
{} as ConstructorParameters<typeof DependsOnMethod>[0], | ||
); | ||
return new DependsOnMethod(deprecatedEndpoints) as this; | ||
} | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.