Skip to content

Commit 266bc09

Browse files
authored
chore: update local openapi snapshot (#1194)
## 🧰 Changes this PR updates our APIv2 openapi description as part of @emilyskuo's work in #1175 and chunks out the OAS into its own dedicated file since it's absolutely massive. you can check out the diff of the file changes [here](next...1346b8b). i tried messing around with JSON module imports so we can eventually automate these updates more easily, but we lose out on a lot of good strict typing that we currently have with `as const satisfies OASDocument`. annoying! ## 🧬 QA & Testing no functional changes. do tests still pass?
1 parent 02bd825 commit 266bc09

File tree

5 files changed

+2908
-2682
lines changed

5 files changed

+2908
-2682
lines changed

__tests__/helpers/get-api-mock.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import nock from 'nock';
22

33
import config from '../../src/lib/config.js';
44
import { getUserAgent } from '../../src/lib/readmeAPIFetch.js';
5-
import { readmeAPIv2Oas } from '../../src/lib/types.js';
5+
import readmeAPIv2Oas from '../../src/lib/types/openapiDoc.js';
66

77
import { mockVersion } from './oclif.js';
88

src/lib/readmeAPIFetch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { git } from './createGHA/index.js';
1414
import { getPkgVersion } from './getPkg.js';
1515
import isCI, { ciName, isGHA } from './isCI.js';
1616
import { debug, warn } from './logger.js';
17-
import { readmeAPIv2Oas } from './types.js';
17+
import readmeAPIv2Oas from './types/openapiDoc.js';
1818

1919
const SUCCESS_NO_CONTENT = 204;
2020

src/lib/syncPagePath.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { PageMetadata } from './readPage.js';
2-
import type { GuidesRequestRepresentation } from './types.js';
2+
import type { GuidesRequestRepresentation } from './types/index.js';
33
import type DocsUploadCommand from '../commands/docs/upload.js';
44

55
import fs from 'node:fs/promises';
@@ -17,7 +17,7 @@ import promptTerminal from './promptWrapper.js';
1717
import readdirRecursive from './readdirRecursive.js';
1818
import { fetchMappings, fetchSchema } from './readmeAPIFetch.js';
1919
import readPage from './readPage.js';
20-
import { categoryUriRegexPattern, parentUriRegexPattern } from './types.js';
20+
import { categoryUriRegexPattern, parentUriRegexPattern } from './types/index.js';
2121

2222
/**
2323
* Commands that use this file for syncing Markdown via APIv2.

src/lib/types/index.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { FromSchema } from 'json-schema-to-ts';
2+
3+
import readmeAPIv2Oas from './openapiDoc.js';
4+
5+
export const categoryUriRegexPattern =
6+
readmeAPIv2Oas.paths['/versions/{version}/guides'].post.requestBody.content['application/json'].schema.properties
7+
.category.properties.uri.pattern;
8+
9+
export const parentUriRegexPattern =
10+
readmeAPIv2Oas.paths['/versions/{version}/guides'].post.requestBody.content['application/json'].schema.properties
11+
.parent.properties.uri.pattern;
12+
13+
type guidesRequestBodySchema =
14+
(typeof readmeAPIv2Oas)['paths']['/versions/{version}/guides/{slug}']['patch']['requestBody']['content']['application/json']['schema'];
15+
16+
/**
17+
* Derived from our API documentation, this is the schema for the `guides` object
18+
* as we send it to the ReadMe API.
19+
*
20+
* This is only for TypeScript type-checking purposes — we use ajv
21+
* to validate the user's schema during runtime.
22+
*/
23+
export type GuidesRequestRepresentation = FromSchema<
24+
guidesRequestBodySchema,
25+
{ keepDefaultedPropertiesOptional: true }
26+
>;

0 commit comments

Comments
 (0)