fix display manual request web service (swagger ui)
This commit is contained in:
parent
e50d9948df
commit
0c256b6cf6
3 changed files with 32 additions and 78 deletions
|
|
@ -2,8 +2,10 @@ import env from "../index";
|
||||||
|
|
||||||
const apiKey = `${env.API_URI}/org/apiKey`;
|
const apiKey = `${env.API_URI}/org/apiKey`;
|
||||||
const apiManage = `${env.API_URI}/org/api-manage/`;
|
const apiManage = `${env.API_URI}/org/api-manage/`;
|
||||||
|
const apiManualSwagger = `${env.API_URI}/org/api-manage/manual/swagger`;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
apiKeyMain: apiKey,
|
apiKeyMain: apiKey,
|
||||||
apiManage: apiManage,
|
apiManage: apiManage,
|
||||||
|
apiManualSwagger: apiManualSwagger,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -10,19 +10,13 @@ function onCloseDialog() {
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<q-dialog v-model="modal" persistent maximized>
|
<q-dialog v-model="modal" persistent maximized>
|
||||||
<q-card style="max-width: 85vw; height: 85vh">
|
<q-card style="max-width: 85vw; height: 90vh">
|
||||||
<DialogHeader tittle="วิธีการใช้งาน" :close="onCloseDialog" />
|
<DialogHeader tittle="วิธีการใช้งาน" :close="onCloseDialog" />
|
||||||
<q-separator />
|
<q-separator />
|
||||||
|
|
||||||
<q-card-section>
|
<q-card-section style="height: 80vh; overflow: auto">
|
||||||
<SwaggerViewer />
|
<SwaggerViewer />
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
<q-separator />
|
|
||||||
|
|
||||||
<q-card-actions align="right" class="bg-white text-teal">
|
|
||||||
<q-btn label="ปิด" color="secondary" @click.pervent="onCloseDialog()" />
|
|
||||||
</q-card-actions>
|
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -3,83 +3,34 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import SwaggerUI from "swagger-ui";
|
import SwaggerUI from "swagger-ui";
|
||||||
import "swagger-ui/dist/swagger-ui.css";
|
import "swagger-ui/dist/swagger-ui.css";
|
||||||
|
|
||||||
// 🔁 ใส่ URL ของ Swagger JSON API ของคุณตรงนี้
|
import http from "@/plugins/http";
|
||||||
// const swaggerUrl: string = "https://petstore.swagger.io/v2/swagger.json";
|
import config from "@/app.config";
|
||||||
|
|
||||||
onMounted(() => {
|
// URL ของ Swagger JSON API ของคุณตรงนี้
|
||||||
|
// const swaggerUrl: string = "https://petstore.swagger.io/v2/swagger.json";
|
||||||
|
const swaggerJson = ref();
|
||||||
|
async function fetchSwaggerJson() {
|
||||||
|
swaggerJson.value = await http
|
||||||
|
.get(`${config.API.apiManualSwagger}`)
|
||||||
|
.then((res) => {
|
||||||
|
return res.data.result;
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error fetching Swagger JSON:", error);
|
||||||
|
return null; // หรือจัดการข้อผิดพลาดตามที่คุณต้องการ
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await fetchSwaggerJson();
|
||||||
SwaggerUI({
|
SwaggerUI({
|
||||||
dom_id: "#swagger-ui",
|
dom_id: "#swagger-ui",
|
||||||
// url: swaggerUrl,
|
// url: swaggerUrl,
|
||||||
spec: {
|
spec: swaggerJson.value,
|
||||||
openapi: "3.0.0",
|
|
||||||
info: {
|
|
||||||
title: "API Web service",
|
|
||||||
version: "1.0.0",
|
|
||||||
description: "Example API for getting registry data",
|
|
||||||
},
|
|
||||||
servers: [
|
|
||||||
{
|
|
||||||
url: "https://api.example.com",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
paths: {
|
|
||||||
"/registry": {
|
|
||||||
get: {
|
|
||||||
summary: "รายการข้อมูลทะเบียนประวัติข้าราชการ",
|
|
||||||
description: "แสดงข้อมูลข้าราชการทั้งหมด",
|
|
||||||
tags: ["ทะเบียนประวัติ"],
|
|
||||||
responses: {
|
|
||||||
"200": {
|
|
||||||
description: "รายการข้อมูลทะเบียนประวัติ",
|
|
||||||
content: {
|
|
||||||
"application/json": {
|
|
||||||
schema: {
|
|
||||||
type: "array",
|
|
||||||
items: {
|
|
||||||
$ref: "#/components/schemas/Registry",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
example: [
|
|
||||||
{
|
|
||||||
id_card: "1234567890123",
|
|
||||||
firstname: "Developer",
|
|
||||||
lastname: "Lastname",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
schemas: {
|
|
||||||
Registry: {
|
|
||||||
type: "object",
|
|
||||||
properties: {
|
|
||||||
id_card: {
|
|
||||||
type: "string",
|
|
||||||
example: "1234567890123",
|
|
||||||
},
|
|
||||||
firstname: {
|
|
||||||
type: "string",
|
|
||||||
example: "Developer",
|
|
||||||
},
|
|
||||||
lastname: {
|
|
||||||
type: "string",
|
|
||||||
example: "Lastname",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
required: ["id_card", "firstname", "lastname"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -88,4 +39,11 @@ onMounted(() => {
|
||||||
.swagger-ui h2.title {
|
.swagger-ui h2.title {
|
||||||
line-height: 1rem;
|
line-height: 1rem;
|
||||||
}
|
}
|
||||||
|
.swagger-ui .scheme-container {
|
||||||
|
margin: 0 0 0px;
|
||||||
|
padding: 0px 0px 20px;
|
||||||
|
}
|
||||||
|
.swagger-ui .scheme-container .schemes .auth-wrapper {
|
||||||
|
justify-content: end;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue