Skip to content

Commit

Permalink
fix(generator-core): remove ReadonlyDeep type
Browse files Browse the repository at this point in the history
  • Loading branch information
Lodin committed Jan 22, 2025
1 parent 0bc0ee4 commit c7df876
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/ts/generator-core/src/Schema.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { OpenAPIV3 } from 'openapi-types';
import type { ReadonlyDeep, Simplify } from 'type-fest';

export type Nullified<T, K extends keyof T> = T & { [P in K]: undefined };

export type ReferenceSchema = ReadonlyDeep<OpenAPIV3.ReferenceObject>;
export type ArraySchema = ReadonlyDeep<OpenAPIV3.ArraySchemaObject>;
export type NonArraySchema = ReadonlyDeep<OpenAPIV3.NonArraySchemaObject>;
export type ReferenceSchema = OpenAPIV3.ReferenceObject;
export type ArraySchema = OpenAPIV3.ArraySchemaObject;
export type NonArraySchema = OpenAPIV3.NonArraySchemaObject;
export type RegularSchema = ArraySchema | NonArraySchema;

export type NullableSchema = Readonly<Required<Pick<RegularSchema, 'nullable'>>> & RegularSchema;
Expand All @@ -21,7 +20,7 @@ export type ComposedSchema =
| OneOfRuleComposedSchema;

export type NonComposedRegularSchema = Readonly<Nullified<RegularSchema, 'allOf' | 'anyOf' | 'oneOf'>> & RegularSchema;
export type NonComposedSchema = Simplify<NonComposedRegularSchema | ReferenceSchema>;
export type NonComposedSchema = NonComposedRegularSchema | ReferenceSchema;

export type BooleanSchema = NonComposedRegularSchema & Readonly<{ type: 'boolean' }>;
export type IntegerSchema = NonComposedRegularSchema & Readonly<{ type: 'integer' }>;
Expand Down Expand Up @@ -152,7 +151,7 @@ export function convertReferenceSchemaToPath(schema: ReferenceSchema): string {
}

export function resolveReference(
schemas: ReadonlyDeep<OpenAPIV3.ComponentsObject>['schemas'],
schemas: OpenAPIV3.ComponentsObject['schemas'],
{ $ref }: ReferenceSchema,
): Schema | undefined {
if (schemas) {
Expand Down

0 comments on commit c7df876

Please sign in to comment.