Skip to content

Add questionToken option to transform #1417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

JorrinKievit
Copy link
Contributor

@JorrinKievit JorrinKievit commented Nov 1, 2023

Changes

This adds the possibility of appending a questionToken to a property using the transform function. Fixes #1411

How to Review

I am not 100% confident I covered all use cases of the transform function. Keep in mind that with the limited knowledge of this library, I might have missed some things.

Checklist

  • Unit tests updated
  • docs/ updated (if necessary)
  • pnpm run update:examples run (only applicable for openapi-typescript)

Copy link

changeset-bot bot commented Nov 1, 2023

⚠️ No Changeset found

Latest commit: de72e59

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR


```diff
- file: Blob;
+ file?: Blob | null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 The docs look great! Thank you.

@@ -467,6 +467,11 @@ export type SchemaObject = {
| {}
);

export interface TransformObject {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This is great.

We can probably extend this pretty far before having to change this API.

},
],
[
"options > transform with schema object",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 Fantastic tests!

@@ -51,14 +53,31 @@ export default function transformComponentsObject(
const items: ts.TypeElement[] = [];
if (componentsObject[key]) {
for (const [name, item] of getEntries(componentsObject[key], ctx)) {
const subType = transformers[key](item, {
let subType = transformers[key](item, {
Copy link
Contributor

@drwpow drwpow Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup I think this will work in all cases I can think of. Just handling keys on type: object schema objects should be the main usecase here (we don’t ever want to have question tokens, for example, directly on the components["schemas"] object as that doesn’t make sense)

Copy link
Contributor

@drwpow drwpow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not 100% confident I covered all use cases of the transform function. Keep in mind that with the limited knowledge of this library, I might have missed some things.

All the tests pass, including the ones you added! So as far as I’m concerned, you handled all cases perfectly 🙂 (and if you missed something, then that’s the test suite’s fault and not yours)

@drwpow
Copy link
Contributor

drwpow commented Nov 2, 2023

Also the changeset can be ignored in this PR, as this will go into the v7 (beta) release (i.e. there’s no version to bump yet). But I’ll update the release notes for v7 and give you credit.

@drwpow drwpow merged commit 06c04a0 into openapi-ts:main Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transform nullable returns | null instead of optional ?
2 participants