//native
/**
* Create an API definition
* Create an API definition in the API Reference section of your ReadMe project.
>📘
> This route is only available to projects that are using [ReadMe Refactored](https://docs.readme.com/main/docs/welcome-to-readme-refactored).
*/
export async function main(auth: RT.Readme, branch: string, body: Body) {
const url = new URL(`https://api.readme.com/v2/branches/${branch}/apis`)
const formData = new FormData()
for (const [k, v] of Object.entries(body)) {
if (v !== undefined && v !== '') {
formData.append(k, String(v))
}
}
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: 'Bearer ' + auth.apiKey
},
body: formData
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
/**
* The API definition to upload. We provide full support for OpenAPI 3.x and Swagger 2.0 and experimental support for Postman collections.
*/
export interface Body {
/**
* The API definition.
*/
schema?: {
[k: string]: unknown
}
/**
* The source that the API definition is being uploaded through.
*/
upload_source?: string
/**
* The URL where the API definition is hosted.
*/
url?: {
[k: string]: unknown
}
}
Submitted by hugo697 235 days ago