generated from stijnvanhulle/template
-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add checks namespace for all if statements in TypeScript(exten…
…ds x)
- Loading branch information
1 parent
358de1f
commit 68cd9c3
Showing
9 changed files
with
272 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// based on https://github.com/ardatan/feTS/tree/master | ||
|
||
export type { Infer } from './infer.ts' | ||
export type { MethodMap, PathMap, StatusMap } from './mappers.ts' | ||
export type { Model } from './model.ts' | ||
export type { Parse } from './parse.ts' | ||
export type { RequestParams } from './requestParams.ts' | ||
export type { Response } from './response.ts' |
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,30 +1,38 @@ | ||
/* eslint-disable @typescript-eslint/no-namespace */ | ||
import type { | ||
FromSchema, | ||
JSONSchema, | ||
} from 'json-schema-to-ts' | ||
import type { OASDocument } from 'oas/rmoas.types' | ||
|
||
export type Model< | ||
TOAS extends OASDocument, | ||
TName extends TOAS extends { | ||
namespace Checks { | ||
export type ModelWithSchemas = { | ||
components: { | ||
schemas: Record<string, JSONSchema> | ||
} | ||
} ? keyof TOAS['components']['schemas'] | ||
: TOAS extends { | ||
definitions: Record<string, JSONSchema> | ||
} ? keyof TOAS['definitions'] | ||
: never, | ||
> = TOAS extends { | ||
components: { | ||
schemas: { | ||
[TModelName in TName]: JSONSchema | ||
} | ||
export type ModelWithSchemasNamed<TName extends string | number | symbol> = { | ||
components: { | ||
schemas: { | ||
[TModelName in TName]: JSONSchema | ||
} | ||
} | ||
} | ||
} ? FromSchema<TOAS['components']['schemas'][TName]> | ||
: TOAS extends { | ||
export type ModelWithDefinitions = { | ||
definitions: Record<string, JSONSchema> | ||
} | ||
export type ModelWithDefinitionsNamed<TName extends string | number | symbol = never> = { | ||
definitions: { | ||
[TModelName in TName]: JSONSchema | ||
} | ||
} ? FromSchema<TOAS['definitions'][TName]> | ||
} | ||
} | ||
|
||
export type Model< | ||
TOAS extends OASDocument, | ||
TName extends TOAS extends Checks.ModelWithSchemas ? keyof TOAS['components']['schemas'] | ||
: TOAS extends Checks.ModelWithDefinitions ? keyof TOAS['definitions'] | ||
: never, | ||
> = TOAS extends Checks.ModelWithSchemasNamed<TName> ? FromSchema<TOAS['components']['schemas'][TName]> | ||
: TOAS extends Checks.ModelWithDefinitionsNamed<TName> ? FromSchema<TOAS['definitions'][TName]> | ||
: never |
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
Oops, something went wrong.