@@ -5,31 +5,14 @@ import { OpenAPIV3, OpenAPI } from "openapi-types";
5
5
import { ConfigToType , DataSourcePlugin } from "openblocks-sdk/dataSource" ;
6
6
import { runOpenApi } from "../openApi" ;
7
7
import { parseOpenApi , ParseOpenApiOptions } from "../openApi/parse" ;
8
+ import { readFileSync } from "fs" ;
9
+ import { parse } from "yaml" ;
8
10
9
- const spec = readYaml ( path . join ( __dirname , "./stripe.spec.yaml" ) ) ;
11
+ const yamlContent = readFileSync ( path . join ( __dirname , "./stripe.spec.yaml" ) , "utf-8" ) ;
10
12
11
13
const dataSourceConfig = {
12
14
type : "dataSource" ,
13
15
params : [
14
- {
15
- type : "groupTitle" ,
16
- key : "basicAuth" ,
17
- label : "HTTP Basic Auth" ,
18
- } ,
19
- {
20
- type : "textInput" ,
21
- key : "basicAuth.username" ,
22
- label : "Username" ,
23
- tooltip : "Basic auth username" ,
24
- placeholder : "<Basic Auth Username>" ,
25
- } ,
26
- {
27
- type : "password" ,
28
- key : "basicAuth.password" ,
29
- label : "Password" ,
30
- tooltip : "Basic auth password" ,
31
- placeholder : "<Basic Auth Password>" ,
32
- } ,
33
16
{
34
17
type : "groupTitle" ,
35
18
key : "bearerAuth" ,
@@ -38,9 +21,9 @@ const dataSourceConfig = {
38
21
{
39
22
type : "password" ,
40
23
key : "bearerAuth.value" ,
41
- label : "Token " ,
42
- tooltip : "Bearer HTTP authentication. Allowed headers-- Authorization: Bearer <api_key> " ,
43
- placeholder : "Bearer HTTP authentication. Allowed headers-- Authorization: Bearer <api_key >" ,
24
+ label : "Secret Key " ,
25
+ tooltip : "You can gen a Secret Key [here](https://dashboard.stripe.com/test/apikeys) " ,
26
+ placeholder : "<Secret Key >" ,
44
27
} ,
45
28
] ,
46
29
} as const ;
@@ -60,12 +43,13 @@ const stripePlugin: DataSourcePlugin<any, DataSourceConfigType> = {
60
43
category : "api" ,
61
44
dataSourceConfig,
62
45
queryConfig : async ( ) => {
63
- const { actions, categories } = await parseOpenApi ( spec , parseOptions ) ;
46
+ const spec = parse ( yamlContent ) ;
47
+ const { actions, categories } = await parseOpenApi ( spec as OpenAPI . Document , parseOptions ) ;
64
48
return {
65
49
type : "query" ,
66
50
label : "Action" ,
67
51
categories : {
68
- label : "Category " ,
52
+ label : "Resources " ,
69
53
items : categories ,
70
54
} ,
71
55
actions,
@@ -77,6 +61,9 @@ const stripePlugin: DataSourcePlugin<any, DataSourceConfigType> = {
77
61
serverURL : "" ,
78
62
dynamicParamsConfig : dataSourceConfig ,
79
63
} ;
64
+ // always use a new spec object
65
+ // because of this bug: https://github.com/APIDevTools/json-schema-ref-parser/issues/271
66
+ const spec = parse ( yamlContent ) ;
80
67
return runOpenApi ( actionData , runApiDsConfig , spec as OpenAPIV3 . Document ) ;
81
68
} ,
82
69
} ;
0 commit comments