Skip to content

Commit 2562e53

Browse files
Improve creating a data source guide (#32)
* Minor fixes + update outdated screenshots * Add details on how to use Swagger UI for testing the data source * Update src/routes/guides/building-a-data-source/+page.svelte Co-authored-by: Janne Enberg <janne.enberg@lietu.net> * Update src/routes/guides/building-a-data-source/+page.svelte Co-authored-by: Janne Enberg <janne.enberg@lietu.net> * Update src/routes/guides/building-a-data-source/+page.svelte Co-authored-by: Janne Enberg <janne.enberg@lietu.net> * Run pre-commit * Reformat manually a bit Still passes pre-commit * Fix link --------- Co-authored-by: Janne Enberg <janne.enberg@lietu.net>
1 parent 1b42c2d commit 2562e53

15 files changed

Lines changed: 80 additions & 7 deletions

src/lib/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export function isInternalLink(url: string): boolean {
22
const docsAbsoluteUrl = url.startsWith("https://docs.ioxio.dev/")
3-
const relativeUrl = url.startsWith("/")
3+
const relativeUrl = url.startsWith("/") || url.startsWith("#")
44
return docsAbsoluteUrl || relativeUrl
55
}

src/routes/guides/building-a-data-source/+page.svelte

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
protocol.
3737
</li>
3838
<SectionTitle title="Choosing a data definition for your source" />
39-
<p>You can find the available <em>Data definitions</em> via menu.</p>
39+
<p>You can find the available <em>Data definitions</em> in the menu.</p>
4040
<GuideImage compact img={images.DEFINITIONS} />
4141
<p>
4242
If there is no definition for the type of data you want to provide, you can create your own
@@ -113,7 +113,7 @@
113113
Some dataspaces have moderated group creation. If the page has a notice saying so, and you are
114114
unable to create the group yourself, please follow the instructions visible in the page to get a
115115
group. Note, that if your organization already has a group, you will need to ask your group's
116-
administrator to invite you to the existing group.
116+
owner to invite you to the existing group.
117117
</p>
118118
<h3>Add your data source</h3>
119119
<p>
@@ -152,10 +152,6 @@
152152
<li>
153153
<b>No access control</b> - The dataspace will allow anyone to request data from the data source.
154154
</li>
155-
<li>
156-
<b>Self-managed API keys</b> - <em>X-API-Key</em> header will be required to be present, but its
157-
contents will not be verified by the dataspace.
158-
</li>
159155
<li>
160156
<b>Dataspace verified API tokens</b> - The <em>X-API-Key</em> header will be required and
161157
verified by the dataspace. Once you save the data source with this setting you can manage
@@ -184,6 +180,12 @@
184180
need to add your own group explicitly, but if you want to add other groups for testing purposes,
185181
- click <em>+ Add</em>, type in the name of the group, click <em>+ Add</em> again.
186182
</p>
183+
<p>
184+
To test your data source, you can either follow the more in-depth steps in the next
185+
<A href="#test-your-data-source">Test your data source</A> section or head to the
186+
<A href="#test-your-data-source-using-swagger-ui">Test your data source using Swagger UI</A> section
187+
a bit further down for a simpler and quicker approach.
188+
</p>
187189
<SectionTitle title="Test your data source" />
188190
<p>
189191
You should now be able to test your own data source by querying it through the product gateway.
@@ -247,6 +249,53 @@
247249
source edit page after a short while:
248250
</p>
249251
<GuideImage img={images.ERRORS} />
252+
253+
<SectionTitle title="Test your data source using Swagger UI" />
254+
<p>The quickest and easiest way to test your data source is using these steps with Swagger UI.</p>
255+
<p>
256+
From the edit data source view, you can quickly jump to the Access control keys for your source
257+
by pressing the key icon in the list of <em>Allowed groups</em> section.
258+
</p>
259+
<GuideImage img={images.ALLOWED_GROUPS_KEY} />
260+
<p>
261+
Alternatively you can open the <em>Access control keys</em> from the menu and open the details for
262+
your own source.
263+
</p>
264+
<p>
265+
On the View access control keys page press the <em>Generate API token</em> button. This will for
266+
convenience use one of the long-lived access control keys and generate a short lived API token (typically
267+
valid for about an hour) and display it to you for easier testing.
268+
</p>
269+
<GuideImage img={images.GENERATE_API_TOKEN_BUTTON} />
270+
<p>
271+
Copy the generated API token, make a note of the source value and open the <em>Swagger UI</em> link.
272+
</p>
273+
<GuideImage img={images.COPY_API_TOKEN_AND_OPEN_SWAGGER_UI} />
274+
<p>
275+
Press the <em>Try it out</em> button in Swagger UI.
276+
</p>
277+
<GuideImage img={images.SWAGGER_UI_TRY_IT_OUT} />
278+
<p>
279+
Enter the name of the source (the one you were requested earlier to make a note of) and paste in
280+
the API token you copied in the <em>x-api-key</em> field. Do any changes you want to the request
281+
body and press the
282+
<em>Execute</em> button to perform the request.
283+
</p>
284+
<GuideImage img={images.SWAGGER_UI_FILLED_IN_FORM} />
285+
<p>
286+
Swagger UI will in the <em>Responses</em> section show you the curl command corresponding to the
287+
request that it made and also show the status code and body of the response.
288+
</p>
289+
<GuideImage img={images.SWAGGER_UI_RESPONSE} />
290+
<p>
291+
Check the status and response is as you expect or in case of an error check the details in the
292+
error message. Please note that the API tokens are typically valid for only about an hour, so if
293+
you do a lot of testing you might encounter the
294+
<em>API token is not valid for this source or it has expired</em>
295+
message, which means you need to go back to the Access control keys page and generate a fresh one
296+
to use.
297+
</p>
298+
250299
<SectionTitle title="Publish the data source" />
251300
<p>
252301
When you've verified the data source works as intended you can publish the data source by

src/routes/guides/images.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
"src": "/guides/building-a-data-source/allowed_groups.png",
1515
"alt": "Allowed groups section in data source edit form"
1616
},
17+
"ALLOWED_GROUPS_KEY": {
18+
"src": "/guides/building-a-data-source/allowed_groups_key.png",
19+
"alt": "Allowed groups section in data source edit form with arrow pointing at the key icon."
20+
},
1721
"API_TOKEN": {
1822
"src": "/guides/building-a-data-source/api_token.png",
1923
"alt": "Access control keys of a data source"
@@ -41,6 +45,26 @@
4145
"SOURCE_ACCESS_CONTROL": {
4246
"src": "/guides/building-a-data-source/source_access_control.png",
4347
"alt": "Data source in the list of data sources with Dataspace verified API keys"
48+
},
49+
"GENERATE_API_TOKEN_BUTTON": {
50+
"src": "/guides/building-a-data-source/generate_api_token_button.png",
51+
"alt": "Generate API token button on the view access control keys page."
52+
},
53+
"COPY_API_TOKEN_AND_OPEN_SWAGGER_UI": {
54+
"src": "/guides/building-a-data-source/copy_api_token_and_open_swagger_ui.png",
55+
"alt": "Arrows pointing at the copy API token button, the source and the Swagger UI link."
56+
},
57+
"SWAGGER_UI_TRY_IT_OUT": {
58+
"src": "/guides/building-a-data-source/swagger_ui_try_it_out.png",
59+
"alt": "Arrow pointing at the Try it out button in Swagger UI."
60+
},
61+
"SWAGGER_UI_FILLED_IN_FORM": {
62+
"src": "/guides/building-a-data-source/swagger_ui_filled_in_form.png",
63+
"alt": "Swagger UI form with arrows pointing at the source and x-api-key input fields, as well as the Request body textarea and Execute button."
64+
},
65+
"SWAGGER_UI_RESPONSE": {
66+
"src": "/guides/building-a-data-source/swagger_ui_response.png",
67+
"alt": "Swagger UI Responses section showing the curl command and server response."
4468
}
4569
},
4670
"BUILD_APP": {
-34.8 KB
Loading
16.7 KB
Loading
-19.9 KB
Loading
21.9 KB
Loading
-18.3 KB
Loading
-9.15 KB
Loading
-20.5 KB
Loading

0 commit comments

Comments
 (0)