1
1
package com .algolia .codegen ;
2
2
3
- import java .util .List ;
4
-
5
- import org .openapitools .codegen .CodegenOperation ;
6
- import org .openapitools .codegen .languages .TypeScriptNodeClientCodegen ;
3
+ import io .swagger .v3 .oas .models .Operation ;
7
4
import io .swagger .v3 .oas .models .media .Schema ;
8
5
import io .swagger .v3 .oas .models .parameters .Parameter ;
9
- import io .swagger .v3 .oas .models .Operation ;
10
6
import io .swagger .v3 .oas .models .servers .Server ;
7
+ import java .util .List ;
8
+ import org .openapitools .codegen .CodegenOperation ;
9
+ import org .openapitools .codegen .languages .TypeScriptNodeClientCodegen ;
11
10
12
11
public class AlgoliaJavascriptGenerator extends TypeScriptNodeClientCodegen {
12
+
13
13
@ Override
14
14
public String getName () {
15
15
return "algolia-javascript" ;
16
16
}
17
17
18
18
@ Override
19
- public CodegenOperation fromOperation (String path , String httpMethod , Operation operation , List <Server > servers ) {
20
- return Utils .specifyCustomRequest (super .fromOperation (path , httpMethod , operation , servers ));
19
+ public CodegenOperation fromOperation (
20
+ String path ,
21
+ String httpMethod ,
22
+ Operation operation ,
23
+ List <Server > servers
24
+ ) {
25
+ return Utils .specifyCustomRequest (
26
+ super .fromOperation (path , httpMethod , operation , servers )
27
+ );
21
28
}
22
29
23
30
@ Override
@@ -27,4 +34,13 @@ protected String getParameterDataType(Parameter parameter, Schema p) {
27
34
// we use replace because there might be more to this type, like '| undefined'
28
35
return type .replace ("{ [key: string]: object; }" , "Record<string, any>" );
29
36
}
37
+
38
+ @ Override
39
+ public String toInstantiationType (Schema schema ) {
40
+ String type = super .toInstantiationType (schema );
41
+
42
+ // Same as the `getParameterDataType` but for the models, the generator
43
+ // consider `object` as a fit all which is wrong in TypeScript
44
+ return type .replace ("null<String, object>" , "Record<string, any>" );
45
+ }
30
46
}
0 commit comments