-
Sample request
+
+
Sample request
+
+
{{ endpoint.sampleRequest }}
-
Sample response
+
+
Sample response
+
+
{{ endpoint.sampleResponse }}
@@ -393,6 +417,8 @@ interface NavigationSectionItem {
groups: NavigationGroupItem[]
}
+const BASE_URL = 'https://opensquawk.de'
+
const sectionCategoryOrder: Record
= {
'Public endpoints': ['Waitlist & marketing', 'Authentication & onboarding', 'Tools & diagnostics'],
'Protected endpoints': ['Session controls', 'Invitation management', 'ATC synthesis', 'Decision engine'],
@@ -944,6 +970,8 @@ const endpointSections: EndpointSection[] = [
const searchTerm = ref('')
const searchInputRef = ref(null)
const openEndpoints = ref>({})
+const copyStates = ref>({})
+const copyTimeouts = new Map>()
const generalAnchor = 'about-the-api'
const activeAnchor = ref(generalAnchor)
@@ -1065,6 +1093,8 @@ const navigationSections = computed(() =>
.filter((section) => section.groups.length > 0),
)
+const fullEndpointUrl = (path: string) => `${BASE_URL}${path}`
+
const quickJumpTargets = computed(() => {
const sectionTargets = filteredSections.value.map((section) => ({
label: section.title,
@@ -1079,6 +1109,9 @@ const quickJumpTargets = computed(() => {
const getEndpointKey = (endpoint: EndpointEntry) => `${endpoint.method.toUpperCase()}-${endpoint.path}`
+const getCopyKey = (endpoint: EndpointEntry, type: 'url' | 'request' | 'response') =>
+ `${getEndpointKey(endpoint)}-${type}`
+
const setAnchorRef = (anchor: string) => (el: HTMLElement | null) => {
if (el) {
anchorRefs.set(anchor, el)
@@ -1126,6 +1159,31 @@ const handleAnchorClick = (anchor: string) => {
scheduleActiveAnchorUpdate()
}
+const copyToClipboard = async (value: string, key: string) => {
+ if (typeof navigator === 'undefined' || !navigator.clipboard) {
+ return
+ }
+
+ try {
+ await navigator.clipboard.writeText(value)
+
+ copyStates.value = { ...copyStates.value, [key]: true }
+
+ if (copyTimeouts.has(key)) {
+ clearTimeout(copyTimeouts.get(key)!)
+ }
+
+ const timeout = setTimeout(() => {
+ copyStates.value = { ...copyStates.value, [key]: false }
+ copyTimeouts.delete(key)
+ }, 2000)
+
+ copyTimeouts.set(key, timeout)
+ } catch (error) {
+ console.error('Failed to copy text', error)
+ }
+}
+
const clearSearch = () => {
searchTerm.value = ''
openEndpoints.value = {}
@@ -1173,6 +1231,11 @@ onBeforeUnmount(() => {
if (scrollFrame !== null) {
scrollFrame = null
}
+
+ copyTimeouts.forEach((timeout) => {
+ clearTimeout(timeout)
+ })
+ copyTimeouts.clear()
})
const isEndpointExpanded = (key: string) => {