Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.

Commit 401b720

Browse files
committed
OpenAPI JSON and YAML per dynamic entity
1 parent c1f2b02 commit 401b720

3 files changed

Lines changed: 103 additions & 45 deletions

File tree

src/routes/(protected)/dynamic-entities/system/[id]/+page.svelte

Lines changed: 81 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -236,44 +236,50 @@
236236
</svg>
237237
Manage Data (CRUD)
238238
</a>
239-
<button
240-
type="button"
241-
onclick={exportDefinition}
242-
class="inline-flex items-center rounded-lg border border-green-300 bg-white px-4 py-2 text-sm font-medium text-green-700 hover:bg-green-50 dark:border-green-600 dark:bg-gray-800 dark:text-green-400 dark:hover:bg-green-900/20"
243-
title="Copy definition to clipboard"
239+
<a
240+
href="/dynamic-entities/system/openapi-json?tags={entityName}"
241+
target="_blank"
242+
rel="noopener noreferrer"
243+
class="inline-flex items-center rounded-lg border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"
244+
title="View OpenAPI JSON"
244245
>
245-
{#if exportCopied}
246-
<svg
247-
class="mr-2 h-4 w-4"
248-
fill="none"
249-
stroke="currentColor"
250-
viewBox="0 0 24 24"
251-
>
252-
<path
253-
stroke-linecap="round"
254-
stroke-linejoin="round"
255-
stroke-width="2"
256-
d="M5 13l4 4L19 7"
257-
/>
258-
</svg>
259-
Copied!
260-
{:else}
261-
<svg
262-
class="mr-2 h-4 w-4"
263-
fill="none"
264-
stroke="currentColor"
265-
viewBox="0 0 24 24"
266-
>
267-
<path
268-
stroke-linecap="round"
269-
stroke-linejoin="round"
270-
stroke-width="2"
271-
d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
272-
/>
273-
</svg>
274-
Copy Definition
275-
{/if}
276-
</button>
246+
<svg
247+
class="mr-2 h-4 w-4"
248+
fill="none"
249+
stroke="currentColor"
250+
viewBox="0 0 24 24"
251+
>
252+
<path
253+
stroke-linecap="round"
254+
stroke-linejoin="round"
255+
stroke-width="2"
256+
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
257+
/>
258+
</svg>
259+
OpenAPI JSON
260+
</a>
261+
<a
262+
href="/dynamic-entities/system/openapi-yaml?tags={entityName}"
263+
target="_blank"
264+
rel="noopener noreferrer"
265+
class="inline-flex items-center rounded-lg border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"
266+
title="View OpenAPI YAML"
267+
>
268+
<svg
269+
class="mr-2 h-4 w-4"
270+
fill="none"
271+
stroke="currentColor"
272+
viewBox="0 0 24 24"
273+
>
274+
<path
275+
stroke-linecap="round"
276+
stroke-linejoin="round"
277+
stroke-width="2"
278+
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
279+
/>
280+
</svg>
281+
OpenAPI YAML
282+
</a>
277283
</div>
278284
</div>
279285
</div>
@@ -494,6 +500,44 @@
494500

495501
<!-- Action Buttons -->
496502
<div class="mt-6 flex justify-end gap-2">
503+
<button
504+
type="button"
505+
onclick={exportDefinition}
506+
class="inline-flex items-center rounded-lg border border-green-300 bg-white px-4 py-2 text-sm font-medium text-green-700 hover:bg-green-50 dark:border-green-600 dark:bg-gray-800 dark:text-green-400 dark:hover:bg-green-900/20"
507+
title="Copy definition to clipboard"
508+
>
509+
{#if exportCopied}
510+
<svg
511+
class="mr-2 h-4 w-4"
512+
fill="none"
513+
stroke="currentColor"
514+
viewBox="0 0 24 24"
515+
>
516+
<path
517+
stroke-linecap="round"
518+
stroke-linejoin="round"
519+
stroke-width="2"
520+
d="M5 13l4 4L19 7"
521+
/>
522+
</svg>
523+
Copied!
524+
{:else}
525+
<svg
526+
class="mr-2 h-4 w-4"
527+
fill="none"
528+
stroke="currentColor"
529+
viewBox="0 0 24 24"
530+
>
531+
<path
532+
stroke-linecap="round"
533+
stroke-linejoin="round"
534+
stroke-width="2"
535+
d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
536+
/>
537+
</svg>
538+
Copy Definition
539+
{/if}
540+
</button>
497541
<button
498542
type="button"
499543
onclick={downloadDefinition}

src/routes/(protected)/dynamic-entities/system/openapi-json/+page.server.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ import { OBP_API_URL } from "$lib/config";
66

77
const logger = createLogger("OpenAPIJSONPageServer");
88

9-
export const load: PageServerLoad = async ({ locals }) => {
9+
export const load: PageServerLoad = async ({ locals, url }) => {
1010
const session = locals.session;
1111

12+
// Get tags parameter from URL
13+
const tags = url.searchParams.get("tags");
14+
1215
if (!session?.data?.user) {
1316
throw error(401, "Unauthorized");
1417
}
@@ -22,10 +25,14 @@ export const load: PageServerLoad = async ({ locals }) => {
2225

2326
try {
2427
logger.info("=== FETCHING DYNAMIC ENTITY OPENAPI JSON ===");
25-
const url = `${OBP_API_URL}/resource-docs/OBPv6.0.0/openapi?content=dynamic`;
26-
logger.info(`Request: ${url}`);
28+
let apiUrl = `${OBP_API_URL}/resource-docs/OBPv6.0.0/openapi?content=dynamic`;
29+
if (tags) {
30+
apiUrl += `&tags=${encodeURIComponent(tags)}`;
31+
logger.info(`Filtering by tags: ${tags}`);
32+
}
33+
logger.info(`Request: ${apiUrl}`);
2734

28-
const response = await fetch(url, {
35+
const response = await fetch(apiUrl, {
2936
headers: {
3037
Authorization: `Bearer ${accessToken}`,
3138
},

src/routes/(protected)/dynamic-entities/system/openapi-yaml/+page.server.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ import { OBP_API_URL } from "$lib/config";
66

77
const logger = createLogger("OpenAPIYAMLPageServer");
88

9-
export const load: PageServerLoad = async ({ locals }) => {
9+
export const load: PageServerLoad = async ({ locals, url }) => {
1010
const session = locals.session;
1111

12+
// Get tags parameter from URL
13+
const tags = url.searchParams.get("tags");
14+
1215
if (!session?.data?.user) {
1316
throw error(401, "Unauthorized");
1417
}
@@ -22,10 +25,14 @@ export const load: PageServerLoad = async ({ locals }) => {
2225

2326
try {
2427
logger.info("=== FETCHING DYNAMIC ENTITY OPENAPI YAML ===");
25-
const url = `${OBP_API_URL}/resource-docs/OBPv6.0.0/openapi.yaml?content=dynamic`;
26-
logger.info(`Request: ${url}`);
28+
let apiUrl = `${OBP_API_URL}/resource-docs/OBPv6.0.0/openapi.yaml?content=dynamic`;
29+
if (tags) {
30+
apiUrl += `&tags=${encodeURIComponent(tags)}`;
31+
logger.info(`Filtering by tags: ${tags}`);
32+
}
33+
logger.info(`Request: ${apiUrl}`);
2734

28-
const response = await fetch(url, {
35+
const response = await fetch(apiUrl, {
2936
headers: {
3037
Authorization: `Bearer ${accessToken}`,
3138
},

0 commit comments

Comments
 (0)