Edits history of script submission #18576 for ' Update a reference page (readme)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Update a reference page
     * Updates an existing page 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, slug: string, body: Body) {
    	const url = new URL(`https://api.readme.com/v2/branches/${branch}/reference/${slug}`)
    
    	const response = await fetch(url, {
    		method: 'PATCH',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: JSON.stringify(body)
    	})
    	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.
     */
    
    export interface Body {
    	/**
    	 * Allow indexing by robots.
    	 */
    	allow_crawlers?: 'enabled' | 'disabled'
    	appearance?: {
    		icon?: {
    			name?: string
    			type?: 'icon' | 'emoji'
    		}
    	}
    	category?: {
    		/**
    		 * A URI to the category resource.
    		 */
    		uri?: string
    	}
    	content?: {
    		body?: string
    		excerpt?: string
    		/**
    		 * Information about where this page should redirect to; only available when `type` is `link`.
    		 */
    		link?: {
    			url?: string
    			new_tab?: boolean
    		}
    		next?: {
    			description?: string
    			pages?: (
    				| {
    						slug: string
    						title: string
    						type: 'basic' | 'endpoint'
    				  }
    				| {
    						title: string
    						type: 'link'
    						url: string
    				  }
    			)[]
    		}
    	}
    	metadata?: {
    		description?: string
    		keywords?: string
    		title?: string
    		image?: {
    			uri?: string
    		}
    	}
    	parent?: {
    		uri?: string
    	}
    	privacy?: {
    		view?: 'public' | 'anyone_with_link'
    	}
    	/**
    	 * The accessible URL slug for the page.
    	 */
    	slug?: string
    	state?: 'current' | 'deprecated'
    	title?: string
    	type?: 'api_config' | 'basic' | 'endpoint' | 'link' | 'webhook'
    	connections?: {
    		recipes?: {
    			/**
    			 * URI of the recipe that this API reference is connected to. The recipe and API reference must exist within the same version.
    			 */
    			uri?: string
    		}[]
    	}
    	/**
    	 * Information about the API that this reference page is attached to. If you wish to detach this page from an API definition, making it a stand page, set `api.uri` to `null`.
    	 */
    	api?: {
    		/**
    		 * The endpoint HTTP method.
    		 */
    		method?: 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace'
    		/**
    		 * The endpoint path.
    		 */
    		path?: string
    		schema?: {
    			[k: string]: unknown
    		}
    		/**
    		 * OpenAPI features that are utilized within this API operation.
    		 */
    		stats?: {
    			/**
    			 * This API operation uses `additionalProperties` for handling extra schema properties.
    			 */
    			additional_properties?: boolean
    			/**
    			 * This API operation has `callbacks` documented.
    			 */
    			callbacks?: boolean
    			/**
    			 * This API operation contains `$ref` schema pointers that resolve to itself.
    			 */
    			circular_references?: boolean
    			/**
    			 * This API operation utilizes common parameters set at the path level.
    			 */
    			common_parameters?: boolean
    			/**
    			 * This API operation utilizes `discriminator` for discriminating between different parts in a polymorphic schema.
    			 */
    			discriminators?: boolean
    			/**
    			 * This API operation has `links` documented.
    			 */
    			links?: boolean
    			/**
    			 * This API operation contains polymorphic schemas.
    			 */
    			polymorphism?: boolean
    			/**
    			 * This API operation, after being dereferenced, has `x-readme-ref-name` entries defining what the original `$ref` schema pointers were named.
    			 */
    			references?: boolean
    			/**
    			 * This API operation has composable variables configured for its server definition.
    			 */
    			server_variables?: boolean
    			/**
    			 * This API operation has parameters that have specific `style` serializations.
    			 */
    			style?: boolean
    			/**
    			 * This API definition has `webhooks` documented.
    			 */
    			webhooks?: boolean
    			/**
    			 * This API operation has request bodies that accept XML.
    			 */
    			xml_requests?: boolean
    			/**
    			 * This API operation has response payloads that return XML.
    			 */
    			xml_responses?: boolean
    			/**
    			 * This API operation has parameters or schemas that can serialize to XML.
    			 */
    			xml_schemas?: boolean
    		}
    		source?:
    			| 'api'
    			| 'apidesigner'
    			| 'apieditor'
    			| 'bidi'
    			| 'form'
    			| 'postman'
    			| 'rdme'
    			| 'rdme_github'
    			| 'url'
    		uri?: string
    	}
    	position?: number
    }
    

    Submitted by hugo697 235 days ago