Skip to content

Commit

Permalink
fix: missing baseurl on import openapi
Browse files Browse the repository at this point in the history
  • Loading branch information
anwarulislam authored and AndrewBastin committed Sep 8, 2023
1 parent 1431ecc commit dfd1bb3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type HoppImporterDefinition<T, Y, E> = {
export const defineImporter = <ReturnType, StepType, Errors>(input: {
id: string
name: string
icon: Component
icon: object | Component
importer: HoppImporter<ReturnType, StepType, Errors>
applicableTo: HoppImporterApplicableTo
steps: StepType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const parseOpenAPIV3Body = (
// We only take the first definition
const [contentType, media]: [
string,
OpenAPIV3.MediaTypeObject | OpenAPIV31.MediaTypeObject,
OpenAPIV3.MediaTypeObject | OpenAPIV31.MediaTypeObject
] = objs[0]

return contentType in knownContentTypes
Expand Down Expand Up @@ -514,6 +514,17 @@ const parseOpenAPIAuth = (
? parseOpenAPIV3Auth(doc as OpenAPIV3.Document | OpenAPIV31.Document, op)
: parseOpenAPIV2Auth(doc as OpenAPIV2.Document, op)

const parseOpenAPIUrl = (doc: OpenAPI.Document): string => {
let url = ""
if (objectHasProperty(doc, "host")) {
url += doc.host
}
if (objectHasProperty(doc, "basePath")) {
url += doc.basePath
}
return url
}

const convertPathToHoppReqs = (
doc: OpenAPI.Document,
pathName: string,
Expand All @@ -535,7 +546,9 @@ const convertPathToHoppReqs = (
makeRESTRequest({
name: info.operationId ?? info.summary ?? "Untitled Request",
method: method.toUpperCase(),
endpoint: `<<baseUrl>>${replaceOpenApiPathTemplating(pathName)}`, // TODO: Make this proper
endpoint: `${parseOpenAPIUrl(doc)}${replaceOpenApiPathTemplating(
pathName
)}`,

// We don't need to worry about reference types as the Dereferencing pass should remove them
params: parseOpenAPIParams(
Expand Down

0 comments on commit dfd1bb3

Please sign in to comment.