You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/guides/add-new-provider.md
+3-6
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ This definition is later used by _Map_ documents that create a request/response
32
32
33
33
:::info Before you start
34
34
35
-
Please [check our registry for existing providers](./find-provider-by-name.md) before creating your own. Chances are the provider you're interested in was already defined by someone else.
35
+
Please [check our registry for existing providers](./find-provider-by-name.md) before creating your own. Chances are the provider you're interested in was already defined by someone else.
36
36
37
37
In that case you can skip this guide & simply [create a mapping for the capability using an existing provider](./map-capability-to-provider.md).
38
38
@@ -71,7 +71,6 @@ Running the above command creates a new JSON file at `<provider-name>.provider.j
71
71
72
72
To be able to call the provider's web services, you need to first define them. Each service points to a specific base URL and has an identifier that is unique within the provider document.
@@ -116,7 +115,7 @@ If the provider offers a public API that _does not_ require any authentication,
116
115
117
116
:::
118
117
119
-
Define the expected form of authentication using _security schemes_. The actual credentials, tokens or keys will be provided later in runtime by the consumer either directly or via environment variables. Currently 3 types of security schemes are supported:
118
+
Define the expected form of authentication using _security schemes_. The actual credentials, tokens or keys will be provided later in runtime by the consumer either directly or via environment variables. Currently 3 types of security schemes are supported:
120
119
121
120
-[Basic Auth](#basic-auth)
122
121
-[Bearer Token](#bearer-token)
@@ -143,7 +142,7 @@ Use the following scheme with an arbitrary ID which can be referenced later from
143
142
"id": "<scheme-id>",
144
143
"type": "http",
145
144
"scheme": "basic"
146
-
}
145
+
}
147
146
]
148
147
}
149
148
```
@@ -185,7 +184,6 @@ _Replace the security scheme `id` value in the example with your own ID. Provide
185
184
186
185
Use the following scheme with an arbitrary ID which can be referenced later from the mapping.
Copy file name to clipboardexpand all lines: docs/guides/create-new-capability.md
+4-6
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,7 @@ Use the `--help` flag for more options and examples:
57
57
```shell
58
58
superface create --help
59
59
```
60
+
60
61
:::
61
62
62
63
The CLI creates `use_case_name.supr` file in current directory and links to it from the `superface/super.json`.
@@ -150,7 +151,6 @@ If you prefer learning by example, you can check the source Comlink profile for
150
151
151
152
The use-case can be marked as `safe`, `unsafe` or `idempotent`. If the safety is not specified, the use-case is treated as `unsafe` by default.
152
153
153
-
154
154
`safe`
155
155
: The use-case doesn't change anything or doesn't perform any action. Generally reading operations can be considered safe, for example retrieving information about shipment or geocoding a postal address.
156
156
@@ -189,7 +189,7 @@ While the safety information is optional, it can be used by OneSDK to treat the
189
189
190
190
### Define Input Fields {#input}
191
191
192
-
To execute the use-case, you typically need to provide some input. For example to send a text message, you need at least a recipient's phone number and the message's contents.
192
+
To execute the use-case, you typically need to provide some input. For example to send a text message, you need at least a recipient's phone number and the message's contents.
193
193
194
194
In Comlink profile, the use-case's input is specified in the `input` block:
195
195
@@ -272,7 +272,7 @@ The first description in the profile should explain the overall purpose of the u
272
272
"""
273
273
Shipment information
274
274
275
-
Track your shipment. Get the latest information on your shipment status.
275
+
Track your shipment. Get the latest information on your shipment status.
276
276
"""
277
277
278
278
name = "delivery-tracking/shipment-info"
@@ -353,8 +353,7 @@ Object
353
353
: Corresponds to Object in JavaScript or Dictionary in Python.
354
354
: Uses curly brackets, e.g. `{myField number}` defines an object with single field of type number.
355
355
356
-
Objects are commonly used to define inputs, results, and errors:
357
-
356
+
Objects are commonly used to define inputs, results, and errors:
358
357
359
358
```hcl
360
359
usecase UseCaseName {
@@ -418,7 +417,6 @@ Note that marking the field as non-nullable doesn't make it required. To make th
418
417
419
418
In the above use-case the `trackingNumber` field is both required, and non-nullable:
_Replace the `<profile-name@version>` and `<provider-name>` in the command with the actual profile and provider you wish to create new Map for._
24
+
_Replace the `<profile-name@version>` and `<provider-name>` in the command with the actual profile and provider you wish to create new Map for._
25
25
26
26
Running the above command creates a new Comlink file and links the new map in your local `super.json` configuration file. The new empty map will look something like this:
27
27
@@ -35,7 +35,6 @@ Comment for the map to UseCaseName
35
35
map UseCaseName {} // UseCaseName will be different based on the actual use case in the profile
36
36
```
37
37
38
-
39
38
## Map use cases
40
39
41
40
Every profile defines one or more _use cases_. You need to map the use case interfaces to the concrete requests and results towards a provider. If you used CLI to bootstrap the map, it will have pre-defined empty mappings for every profile use case.
@@ -49,7 +48,7 @@ You can access these inputs via `input` object which is available _inside use ca
49
48
<details>
50
49
<summary>Example</summary>
51
50
52
-
Given the following use case definition in a profile:
51
+
Given the following use case definition in a profile:
53
52
54
53
```hcl title="profile.supr" {4-7}
55
54
...
@@ -68,7 +67,7 @@ usecase GetWeather {
68
67
...
69
68
```
70
69
71
-
These input props are accessible in the use case mapping.
70
+
These input props are accessible in the use case mapping.
72
71
73
72
```hcl title="profile.provider.suma" {4-6}
74
73
...
@@ -149,7 +148,7 @@ map UseCaseName {
149
148
}
150
149
```
151
150
152
-
_The above definition makes call to `/api/messages?from=...` with body of content type `application/json` including object with 2 parameters (`to` & `text`).<br />See [Comlink reference](https://superface.ai/docs/comlink/map#sec-HTTP-Request) for details on `request` block._
151
+
_The above definition makes call to `/api/messages?from=...` with body of content type `application/json` including object with 2 parameters (`to` & `text`).<br />See [Comlink reference](https://superface.ai/docs/comlink/map#sec-HTTP-Request) for details on `request` block._
153
152
154
153
### Handle server responses {#handle-response}
155
154
@@ -177,8 +176,9 @@ map UseCaseName {
177
176
```
178
177
179
178
_The above example definition:_
180
-
-_handles any response with status code `201` and `application/json` content type in success context,_
181
-
-_handles any response with status code `400` and `application/problem+json` content type in error context._
179
+
180
+
-_handles any response with status code `201` and `application/json` content type in success context,_
181
+
-_handles any response with status code `400` and `application/problem+json` content type in error context._
182
182
183
183
_Any other response won't be handled and will result in an unexpected error_.
184
184
@@ -245,8 +245,7 @@ map UseCaseName {
245
245
246
246
_The above definition maps the 2 expected result fields. One from the response's body, the other is loaded from headers and transformed with a simple Comlink expression.<br />See [Comlink reference](https://superface.ai/docs/comlink/map#sec-Map-Result) for detailed specification of `map result` statement._
247
247
248
-
249
-
:::note
248
+
:::note
250
249
251
250
`map result` is a regular Comlink statement; and as such can theoretically happen from anywhere inside the use case mapping, not necessarily from an inside of the response handler. An example of this would be a capability that doesn't need to call a remote server. However this is _very rare_ and the results are usually mapped from the HTTP responses so the example shows the most common place where the result mapping happens.
252
251
@@ -286,8 +285,7 @@ map UseCaseName {
286
285
287
286
_The above definition maps the 2 expected error fields when server responds with status `429 (Too Many Requests)`. One is hardcoded as it describes the error scenario, the other constructs a helpful message with a value from response headers using a simple Comlink expression.<br />See [Comlink reference](https://superface.ai/docs/comlink/map#sec-Map-Error) for detailed specification of `map error` statement._
288
287
289
-
290
-
:::note
288
+
:::note
291
289
292
290
`map error` is a regular Comlink statement; and as such can theoretically happen from anywhere inside the use case mapping, not necessarily from an inside of the response handler. Although the errors are usually mapped from the failed HTTP responses, sometimes you might want to map error from different places. _One example would be validating the inputs against some domain rule. In such case, you might want to map error (or; fail early) when invalid inputs were provided, even before making the request._
0 commit comments