-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support getting suggested APIs from spec
- Loading branch information
1 parent
3040a92
commit ecc6454
Showing
30 changed files
with
1,180 additions
and
551 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
make test-all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
const props = defineProps({ | ||
suite: String, | ||
address: String, | ||
method: String, | ||
operationId: String, | ||
}) | ||
const emit = defineEmits(['update:address', 'update:method', 'update:operationId']) | ||
function loadCache(callback : Function) { | ||
if (localCache.value.length > 0) { | ||
callback() | ||
return | ||
} | ||
const suite = props.suite | ||
const requestOptions = { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
name: suite | ||
}) | ||
}; | ||
fetch('/server.Runner/GetSuggestedAPIs', requestOptions) | ||
.then(response => response.json()) | ||
.then(e => { | ||
localCache.value = e.data | ||
callback() | ||
}) | ||
} | ||
const querySuggestedAPIs = (queryString: string, cb: (arg: any) => void) => { | ||
loadCache(function(){ | ||
const results = queryString | ||
? localCache.value.filter(createFilter(queryString)) | ||
: localCache.value | ||
cb(results.slice(0, 10)) | ||
}) | ||
} | ||
const localCache = ref({} as TestCase[]) | ||
interface Request { | ||
api: string, | ||
method: string, | ||
} | ||
interface TestCase { | ||
name: string, | ||
request: Request, | ||
} | ||
const createFilter = (queryString: string) => { | ||
return (v: TestCase) => { | ||
return ( | ||
v.request.api.toLowerCase().indexOf(queryString.toLowerCase()) !== -1 | ||
) | ||
} | ||
} | ||
const handleSelect = (item: TestCase) => { | ||
emit('update:address', item.request.api) | ||
// emit('update:method', item.request.method) | ||
// emit('update:operationId', item.name) | ||
} | ||
</script> | ||
|
||
<template> | ||
<el-autocomplete | ||
:value="address" | ||
@input="$emit('update:address', $event)" | ||
:fetch-suggestions="querySuggestedAPIs" | ||
@select="handleSelect" | ||
placeholder="API Address" | ||
style="width: 70%; margin-left: 5px; margin-right: 5px;" | ||
> | ||
<template #default="{ item }"> | ||
<div class="value">{{ item.request.method }}</div> | ||
<span class="link">{{ item.request.api }}</span> | ||
</template> | ||
</el-autocomplete> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package docs | ||
|
||
import _ "embed" | ||
|
||
//go:embed api-testing-schema.json | ||
var Schema string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.