Skip to content

Commit 59dbcab

Browse files
committed
chore: fix wordings
1 parent c5c7ea1 commit 59dbcab

2 files changed

Lines changed: 49 additions & 47 deletions

File tree

packages/doc/docs/references/api-schema.mdx

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# API Schema
22

3-
API Schema is a definition file for creating each Data API endpoint. When using VulcanSQL, you not only write SQL Query files to get results from the data source, but also need to write the API Schema, or no API created.
3+
The API Schema is a configuration file for each Data API endpoint.
44

55
## API Schema Structure
66

7-
Below is a API schema structure example, the API schema uses YAML format to define it:
7+
Below is an example of the API schema structure, and the API schema uses the YAML format:
88

99
```yaml
1010
urlPath: /users/:id
@@ -19,15 +19,14 @@ profiles:
1919
- pg # replace this with your profile name
2020
```
2121
22-
VulcanSQL will read the API Schema and know what the SQL files mapping it, then auto-generated APIs that map to the user-written SQL files.
23-
24-
Below is the introduction of each field in the structure.
22+
Here is the introduction of each field in the API Schema.
2523
2624
## API Schema Fields
2725
2826
### `urlPath` Field
2927

30-
This is the Data API endpoint URL path. you could add the path parameter hereby `:[param-name]`, format, but when you add the path parameter, the `feildName` should also have the path parameter, and `fieldIn` should be `path`, if you forgot, VulcanSQL will auto-generated it to make it work.
28+
This is the Data API endpoint URL path. You could add the path parameter here using the `:[param-name]` format.
29+
If you forgot to add the `fieldName` and `filedIn` only if it's not `header`, VulcanSQL will auto generate it to make it work.
3130

3231
```yaml
3332
urlPath: /users/:id
@@ -39,11 +38,11 @@ request:
3938

4039
After API is generated, VulcanSQL will add a prefix `/api` to distinguish Data API endpoints and other Non-Data API endpoints. For the above sample, the request url eventually should be `/api/users/:id`.
4140

42-
If you don't set urlPath, VulcanSQL uses your API Schema filename as the url, e.g. API schema filename is `user.yaml`, then the urlPath will be `/user`.
41+
If you don't set the `urlPath`, VulcanSQL uses your API Schema filepath as the url, e.g. API schema filepath is `new/user.yaml`, then the urlPath will be `/new/user`.
4342

4443
### `templateSource` Field
4544

46-
The`templateSource` field could let VulcanSQL know what the SQL file this API will like to map for querying it and response data. It should be SQL filename ( not need file extension ).
45+
The `templateSource` field is the mapping to the name of the respective SQL file.
4746

4847
```yaml
4948
- sqls
@@ -58,10 +57,11 @@ templateSource: user
5857

5958
### `request` Fields
6059

61-
The `request` define what the request parameters would like to send with the API request, if you would like to have parameters to send the request, you should define the parameter with at least `fieldName`, `fieldIn` two fields.
60+
The `request` fields define what are the request parameters sent with the API request.
61+
If you would like to send a request with a parameter, you should define the parameter with at least `fieldName` and `fieldIn` fields.
6262

63-
- `fieldName` - The field name of the parameter of the API request, but the parameter field is optional, so you could send the request with the parameter optional. However, if your parameter is a path parameter e.g: `/users/:id`, then VulcanSQL will make the path parameter **required**.
64-
- `fieldIn` - Where the parameter field is put in with the API request. It could be `path`, `query`, and `header`. If the `fieldIn` is the `path`, then you should also define the path parameter in `urlPath` . below is the sample:
63+
- `fieldName` - The field name of the parameter of the API request. If it's a query parameter, it is optional by default. However, if your parameter is a path parameter e.g: `/users/:id`, then VulcanSQL will make the path parameter **required**.
64+
- `fieldIn` - Where is the parameter field put within the API request. It could be `path`, `query`, and `header`. If the `fieldIn` is the `path`, then you should also define the path parameter in `urlPath`. Here is the sample:
6565

6666
```yaml
6767
urlPath: users
@@ -73,30 +73,30 @@ The `request` define what the request parameters would like to send with the API
7373
fieldIn: query
7474
```
7575

76-
The request could be below 4 cases:
76+
The requests could be 4 cases shown below:
7777

7878
```bash
7979
/api/users
8080
/api/users?gender=male
8181
/api/users?age=18
8282
/api/users?gender=male&age=18
83-
8483
```
8584

86-
- `type` - The `type` could let VulcanSQL know the data is what type for handing it. The type could be `string`, `number`, and `boolean`.
87-
If not set the field, the default is `string` type. But don't worry, in most time, the driver is smart enough to handle parameter types, so it might take more effect on validators.
88-
- `description` - The `description` field is an optional value too, but if you add the `description`, then it could make the API document could display the description to make the users know what the request field is.
89-
- `validators` - The `validators` field is an array type to make the request parameter field have some validator to check the value format. E.g If your parameter field should be required, then set the `requried` in validators could make VulcanSQL check the parameter must be required. VulcanSQL provides some built-in validators for you, you could see the [API Validation](../develop/validator) to know the detail.
85+
- `type` - It means the request parameter data type. It could be `string`, `number`, or `boolean`, and the default is `string` type.
86+
- `description` - It's optional. If you add the `description` text, it'll be shown on the API documentation and the API catalog. It's more user friendly for users.
87+
- `validators` - The `validators` field is an array type. It's used for validating request parameters.
88+
For example, if your parameter field is required, then the `required` value should be filled in. VulcanSQL also provides some built-in validators for you,
89+
you could see the [API Validation](../develop/validator) for further details.
9090

9191
### `sample` fields
9292

9393
The `sample` fields are optional fields, if you don't set them, then the API document will show the response fields in the API endpoint introduction. VulcanSQL will use `sample` fields to send a query for sampling and get the result column with the field type for generating the information in the API documentation.
9494

9595
If you would like to set it, you should provide these fields:
9696

97-
- `parameters` - The `parameters` could let you set the sampling data for the SQL query needed, for example, if your API needs to send the request with `gender` and `age`, then you should send the field in the `sample` fields:
97+
- `parameters` - The parameters of API requests for querying sampling data.
9898

99-
- `profiles`: The `profiles` indicate the data source you would like to use for querying the sample data result.
99+
- `profile`: The `profile` indicates the data source you would like to use for querying the sample data.
100100

101101
```yaml
102102
urlPath: users/:id
@@ -114,17 +114,18 @@ profiles:
114114
```
115115

116116
:::info
117-
For the more detail of using `sample` field, please see [API Document](../develop/api-doc#setting-sampler).
117+
For further details of using the `sample` field, please check out the section of [API Document](../develop/api-doc#setting-sampler) documentation.
118118

119119
:::
120120

121-
### `profiles` field / `profile` field
121+
### `profiles` / `profile` field
122122

123-
The `profiles` / `profile` indicated which data sources the API will use to query the data result.
123+
The `profiles` / `profile` indicate what data sources the APIs use to query the data.
124124

125-
The `profiles` field take precedence over the `profile` field when both existed.
125+
The `profiles` field takes precedence over the `profile` field when both existed.
126126

127-
When you use the `profile`, it means the API endpoint will query the data from the data source, and each data source could set the [Authorization](../data-privacy/authz) to specify who ( users ) have permission to send the query by the Data API.
127+
When you use the `profile`, it means the API endpoint will query the data from the data source.
128+
You could set the [Authorization](../data-privacy/authz) for each data source to specify who has the permission to query data from APIs.
128129

129130
```yaml
130131
urlPath: user/:id
@@ -134,9 +135,9 @@ request: ...
134135
profile: pg
135136
```
136137

137-
Like the above example, if today user3 would like to query the API, it has no authorization to the get result.
138+
Like the above example, if user3 would like to query data from APIs, he doesn't have the permission to the get data.
138139

139-
When using the `profiles`, it could support multiple data sources like the below examples:
140+
If you specify the `profiles` field, it could support multiple data sources like the below example:
140141

141142
```yaml
142143
urlPath: user/:id
@@ -149,11 +150,9 @@ profile:
149150
- duckdb
150151
```
151152

152-
With the above example, user3 can use only `duckdb` profile to send queries.
153-
154-
This feature could make the user could use the sample SQL query but control the permission to make different use querying the data from different data sources.
153+
With the above example, user3 can only use the `duckdb` profile to send API requests.
155154

156155
:::caution
157-
You should make sure the `pg` and `duckdb` profiles have been properly configured for your project, please check [Data Source Profile](./data-source-profile) for further information.
156+
You should make sure the `pg` and `duckdb` profiles have been properly configured for your project, please check out [Data Source Profile](./data-source-profile) for further information.
158157

159158
:::
Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Data Source Profile
22

3-
When sending an API request to query the data through SQL file logistic, also should check the data source ( e.g: Database, Warehouse ) has connected, so VulcanSQL needs you to define the Data Source Profile.
3+
This file defines data source connection information.
44

55
## Define profile in independent YAML files
66

7-
You could create independent YAML files to define data sources and set the filePath in the `profiles` options of the project config:
7+
You could create independent YAML files to define data sources and set the filePath in the `profiles` option in the project config(`vulcan.yaml`):
88

99
```yaml
1010
# pg-profile.yaml
1111
- name: pg
12-
type: postgres
12+
type: pg
1313
allow: '*'
1414
connection:
1515
host: example.com
@@ -20,32 +20,35 @@ You could create independent YAML files to define data sources and set the fileP
2020

2121
------------------------------------
2222
# duck-profile.yaml
23-
name: duck
24-
type: duckdb
25-
connection:
26-
persistent-path: ./test-data/moma.db
27-
log-queries: true
28-
log-parameters: true
29-
allow: '*'
23+
- name: duckdb
24+
type: duckdb
25+
connection:
26+
persistent-path: ./test-data/moma.db
27+
log-queries: true
28+
log-parameters: true
29+
allow: '*'
3030

3131
-------------------------
3232
# vulcan.yaml (project config)
3333
extensions:
34-
postgres: '@vulcan-sql/extension-driver-duckdb'
34+
pg: '@vulcan-sql/extension-driver-pg'
3535
duckdb: '@vulcan-sql/extension-driver-duckdb'
3636

3737
profiles:
3838
- ./pg-profile.yaml
3939
- ./duck-profile.yaml
4040
```
4141
42-
You should make sure you have installed the data source driver package and declared the module name under the `extensions` of the project config.
42+
You should make sure you have installed the required data source driver package and
43+
declared the module name under the `extensions` in the project config(`vulcan.yaml`).
4344

4445
## Profile fields
4546

46-
In. this Profile, we should give these fields:
47+
These fields are needed to be filled in:
4748

48-
- `name` - The `name` is the data source name for recognizing so that [API Schema](./api-schema) could set the name to know where the data source the API request queries the result from. Like above `duckdb-profile.yaml` example, the name is `duck`, so you could set the `duck` in `profiles` / `profile` in the API Schema to specify what data source the query is from.
49-
- `type` - It's a data source type, each data source type uses the `module-name` under the `extensions` config to be the `type` for recognizing, the above sample you could see.
50-
- `connection` - The needed information to make the connection built, you should check what the connection fields need in each external extension of the data, e.g: [@vulcan-sql/extension-driver-pg](https://www.npmjs.com/package/@vulcan-sql/extension-driver-pg) npm.
51-
- `allow` - The `allow` field could make our Data API could query the data result from different data sources according to whether the user has permission or not. The [API Schema](./api-schema) `profiles` / `profile` fields have shown some examples. For the `allow` configuration rule, you could see the [Authorization](../data-privacy/authz) for introducing detail.
49+
- `name` - This data source name should match with the value in the `profiles`/`profile` field according to [API Schema](./api-schema).
50+
- `type` - It's the data source from the extension package name, such as `@vulcan-sql/extension-driver-[data source]`.
51+
- `connection` - The information needed to connect to the data source, and you should check what connection fields are needed in each external extension, e.g: [@vulcan-sql/extension-driver-pg](https://www.npmjs.com/package/@vulcan-sql/extension-driver-pg).
52+
- `allow` - This allows VulcanSQL to be able to query data from different data sources according to autorization rules.
53+
There are some examples in the section of `profiles` / `profile` fields in [API Schema](./api-schema).
54+
You could check out the [Authorization](../data-privacy/authz) to understand more about the `allow` configuration.

0 commit comments

Comments
 (0)