chore(deps): upgrading our OpenAPI dependencies#1169
Conversation
🦋 Changeset detectedLatest commit: 345f825 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| }) | ||
| .then(Oas.init) | ||
| .then(async spec => { | ||
| await spec.dereference({ preserveRefAsJSONSchemaTitle: true }); |
There was a problem hiding this comment.
transformer was removed from the oas earlier this year because it was only ever used within this library and did not to exist there.
| .map(status => { | ||
| const schema = operation.getResponseAsJSONSchema(status, { | ||
| includeDiscriminatorMappingRefs: false, | ||
| transformer: (s: SchemaObject) => { |
There was a problem hiding this comment.
transformer was removed from the oas earlier this year because it was only ever used within this library and did not to exist there.
| "version": "npm run build:versioned-files && git add schema.json src/packageInfo.ts" | ||
| }, | ||
| "dependencies": { | ||
| "@readme/api-core": "file:../core", |
There was a problem hiding this comment.
Had to change these package file references in order for these packages to get built properly under the new https://turborepo.dev/ build system.
| @@ -70,7 +71,7 @@ | |||
| "devDependencies": { | |||
| "@api/test-utils": "file:../test-utils", | |||
| "@readme/oas-examples": "^7.0.0", | |||
There was a problem hiding this comment.
oas-examples is also a full major release behind but I didn't want to bump that and explode the diff here with SDK fixtures changes. Will address at some point in a followup.
| "title": "app_patch", | ||
| "x-readme-ref-name": "app_patch" | ||
| "x-readme-ref-name": "app_patch", | ||
| "$schema": "http://json-schema.org/draft-04/schema#" |
There was a problem hiding this comment.
These $schema properties all got added because of some improvements we've made to JSON Schema generation in the oas library.
darrenyong
left a comment
There was a problem hiding this comment.
tried to review as best I could!
| // This may result in some data loss if there's already a `title` present, but in the case | ||
| // where we want to generate code for the API definition (see http://npm.im/api), we'd | ||
| // prefer to retain original reference name as a title for any generated types. | ||
| // | ||
| // This work used to exist within the `oas` library as a `preserveRefAsJSONSchemaTitle` | ||
| // option but was deprecated and removed in https://github.com/readmeio/oas/pull/1084. | ||
| if (spec?.components?.schemas && typeof spec.components?.schemas === 'object') { | ||
| Object.keys(spec.components.schemas).forEach(schemaName => { | ||
| // oxlint-disable-next-line no-param-reassign, no-unsafe-optional-chaining | ||
| (spec.components?.schemas?.[schemaName] as SchemaObject).title = schemaName; | ||
|
|
||
| // oxlint-disable-next-line no-param-reassign, no-unsafe-optional-chaining | ||
| (spec.components?.schemas?.[schemaName] as SchemaObject)['x-readme-ref-name'] = schemaName; | ||
| }); | ||
| } | ||
|
|
||
| const normalize = new OASNormalize(spec, { | ||
| parser: { | ||
| dereference: { | ||
| circular: 'ignore', | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| return normalize.dereference(); | ||
| }) | ||
| .then(spec => spec as OASDocument) |
There was a problem hiding this comment.
seems like this block of code already exists in test-utils/index as dereferenceAPI()
| const params: DataForHARWithFiles = jsonSchema ? getJSONSchemaDefaults(jsonSchema) : {}; | ||
| if (!jsonSchema) { | ||
| return params; | ||
| } |
There was a problem hiding this comment.
are these checking the same thing?
| const params: DataForHARWithFiles = jsonSchema ? getJSONSchemaDefaults(jsonSchema) : {}; | |
| if (!jsonSchema) { | |
| return params; | |
| } | |
| if (!jsonSchema) { | |
| return {}; | |
| } | |
| const params: DataForHARWithFiles = getJSONSchemaDefaults(jsonSchema); | |
🧰 Changes
This upgrades our dependencies on oas, oas-normalize, and @readme/oas-to-har to bring them up to date. A lot has changed within these packages over the last year, including the full removal of
.dereference()and JSON Schema transformation APIs that we relied on here; as a result I've had to rework a number of internals in order to maintain parity with how we expect codegen to function.