2
2
AllOfSchemaObject ,
3
3
BodyParameterObject ,
4
4
DefinitionsObject ,
5
+ Dictionary ,
5
6
NonArrayItemsObject ,
6
7
OperationObject ,
7
8
ParametersDefinitionsObject ,
@@ -59,15 +60,15 @@ const unless = (condition: boolean, a: string): string => (condition ? '' : a);
59
60
const when = ( condition : boolean , a : string ) : string => ( condition ? a : '' ) ;
60
61
61
62
interface Dependency {
62
- name : string ;
63
- path : string ;
63
+ readonly name : string ;
64
+ readonly path : string ;
64
65
}
65
66
66
67
interface SerializedType {
67
- type : string ;
68
- io : string ;
69
- dependencies : Dependency [ ] ;
70
- refs : string [ ] ;
68
+ readonly type : string ;
69
+ readonly io : string ;
70
+ readonly dependencies : Dependency [ ] ;
71
+ readonly refs : string [ ] ;
71
72
}
72
73
73
74
const serializedType = ( type : string , io : string , dependencies : Dependency [ ] , refs : string [ ] ) : SerializedType => ( {
@@ -78,7 +79,7 @@ const serializedType = (type: string, io: string, dependencies: Dependency[], re
78
79
} ) ;
79
80
80
81
interface SerializedParameter extends SerializedType {
81
- isRequired : boolean ;
82
+ readonly isRequired : boolean ;
82
83
}
83
84
const serializedParameter = (
84
85
type : string ,
@@ -94,7 +95,7 @@ const serializedParameter = (
94
95
refs,
95
96
} ) ;
96
97
interface SerializedPathParameter extends SerializedParameter {
97
- name : string ;
98
+ readonly name : string ;
98
99
}
99
100
const serializedPathParameter = (
100
101
name : string ,
@@ -204,7 +205,7 @@ const serializeDefinition = (name: string, definition: SchemaObject, cwd: string
204
205
) ;
205
206
} ;
206
207
207
- const serializePathGroup = ( name : string , group : Record < string , PathItemObject > , cwd : string ) : File => {
208
+ const serializePathGroup = ( name : string , group : Dictionary < PathItemObject > , cwd : string ) : File => {
208
209
const groupName = `${ name } Controller` ;
209
210
const serialized = foldSerialized (
210
211
serializeDictionary ( group , ( url , item ) => serializePath ( url , item , groupName , cwd ) ) ,
@@ -745,7 +746,7 @@ const serializeNonArrayItemsObject = (items: NonArrayItemsObject): SerializedTyp
745
746
}
746
747
} ;
747
748
748
- const serializeDictionary = < A , B > ( dictionary : Record < string , A > , serializeValue : ( name : string , value : A ) => B ) : B [ ] =>
749
+ const serializeDictionary = < A , B > ( dictionary : Dictionary < A > , serializeValue : ( name : string , value : A ) => B ) : B [ ] =>
749
750
Object . keys ( dictionary ) . map ( name => serializeValue ( name , dictionary [ name ] ) ) ;
750
751
751
752
const getIOName = ( name : string ) : string => `${ name } IO` ;
@@ -774,13 +775,13 @@ const client = `
774
775
import { left } from 'fp-ts/lib/Either';
775
776
776
777
export interface APIRequest {
777
- url: string;
778
- query?: object;
779
- body?: unknown;
778
+ readonly url: string;
779
+ readonly query?: object;
780
+ readonly body?: unknown;
780
781
};
781
782
782
783
export interface FullAPIRequest extends APIRequest {
783
- method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
784
+ readonly method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
784
785
};
785
786
786
787
export interface APIClient {
0 commit comments