-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathindex.ts
30 lines (24 loc) · 1.25 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import type { FromSchema } from 'json-schema-to-ts';
import readmeAPIv2Oas from './openapiDoc.js';
export const categoryUriRegexPattern =
readmeAPIv2Oas.paths['/versions/{version}/guides'].post.requestBody.content['application/json'].schema.properties
.category.properties.uri.pattern;
export const parentUriRegexPattern =
readmeAPIv2Oas.paths['/versions/{version}/guides'].post.requestBody.content['application/json'].schema.properties
.parent.properties.uri.pattern;
type guidesRequestBodySchema =
(typeof readmeAPIv2Oas)['paths']['/versions/{version}/guides/{slug}']['patch']['requestBody']['content']['application/json']['schema'];
type projectSchema =
(typeof readmeAPIv2Oas)['paths']['/projects/me']['get']['responses']['200']['content']['application/json']['schema'];
/**
* Derived from our API documentation, this is the schema for the `guides` object
* as we send it to the ReadMe API.
*
* This is only for TypeScript type-checking purposes — we use ajv
* to validate the user's schema during runtime.
*/
export type GuidesRequestRepresentation = FromSchema<
guidesRequestBodySchema,
{ keepDefaultedPropertiesOptional: true }
>;
export type ProjectRepresentation = FromSchema<projectSchema, { keepDefaultedPropertiesOptional: true }>;