1
0
Fork 0
mirror of synced 2024-06-28 02:50:50 +12:00

Fix base path in server url for openapi3 import

This commit is contained in:
Rory Powell 2022-03-18 09:20:30 +00:00
parent 9d9c995f87
commit ce965de59d
4 changed files with 34 additions and 903 deletions

View file

@ -7,7 +7,6 @@
Layout,
Tabs,
Tab,
Input,
Heading,
TextArea,
Dropzone,
@ -98,15 +97,16 @@
<Body size="XS"
>Import your rest collection using one of the options below</Body
>
<Tabs selected="Link">
<Tab title="Link">
<Tabs selected="File">
<!-- Commenting until nginx csp issue resolved -->
<!-- <Tab title="Link">
<Input
bind:value={$data.url}
on:change={() => (lastTouched = "url")}
label="Enter a URL"
placeholder="e.g. https://petstore.swagger.io/v2/swagger.json"
/>
</Tab>
</Tab> -->
<Tab title="File">
<Dropzone
gallery={false}
@ -115,7 +115,14 @@
$data.file = e.detail?.[0]
lastTouched = "file"
}}
fileTags={["OpenAPI 2.0", "Swagger 2.0", "cURL", "YAML", "JSON"]}
fileTags={[
"OpenAPI 3.0",
"OpenAPI 2.0",
"Swagger 2.0",
"cURL",
"YAML",
"JSON",
]}
maximum={1}
/>
</Tab>

View file

@ -38,7 +38,11 @@ export abstract class ImportSource {
if (typeof url === "string") {
path = `${url}/${path}`
} else {
path = `${url.origin}/${path}`
let href = url.href
if (href.endsWith("/")) {
href = href.slice(0, -1)
}
path = `${href}/${path}`
}
}
queryString = this.processQuery(queryString)

View file

@ -74,7 +74,7 @@ export class Curl extends ImportSource {
getQueries = async (datasourceId: string): Promise<Query[]> => {
const url = this.getUrl()
const name = url.pathname
const path = url.pathname
const path = url.origin + url.pathname
const method = this.curl.method
const queryString = url.search
const headers = this.curl.headers
@ -90,7 +90,7 @@ export class Curl extends ImportSource {
name,
method,
path,
url,
undefined,
queryString,
headers,
[],

File diff suppressed because it is too large Load diff