Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feat: Add support for pattern properties#2288

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
hontas wants to merge4 commits intoopenapi-ts:main
base:main
Choose a base branch
Loading
fromhontas:pattern-properties

Conversation

hontas
Copy link

@hontashontas commentedMay 5, 2025
edited
Loading

Changes

Add support for patternProperties in addition to additionalProperties (#754).
Building on the work of@gzm0 in1901 by adding tests

Ran the commandpnpm run update:examples which created 129 new files and updated 69, none of which seemed related to this change. Let me know if you wan't me to do it anyways.

How to Review

Refer to comments in originalPR 1901
Validate tests are satisfactory

Checklist

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

webadam1 reacted with heart emoji
@hontashontas requested a review froma team as acode ownerMay 5, 2025 08:21
@hontashontas requested a review fromkerwanpMay 5, 2025 08:21
@netlifyNetlify
Copy link

netlifybot commentedMay 5, 2025
edited
Loading

👷 Deploy request foropenapi-ts pending review.

Visit the deploys page to approve it

NameLink
🔨 Latest commitb299279

@changeset-botchangeset-bot
Copy link

changeset-botbot commentedMay 5, 2025
edited
Loading

🦋 Changeset detected

Latest commit:b299279

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
NameType
openapi-typescriptMinor
swr-openapiMajor

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

@gzm0
Copy link
Contributor

gzm0 commentedMay 5, 2025

@kerwanp LMK if you'd like to hand-off review to me here.
@hontas TY so much for taking this over!

hontas reacted with heart emoji

@drwpow
Copy link
Contributor

@gzm0 yes please feel free to review! The round-robin assignment was only meant to divide the PR reviews among us evenly, but always feel free to jump in and stamp a PR if you have context/time

@drwpowdrwpow requested a review fromgzm0May 12, 2025 01:22
addlTypes.push(transformSchemaObject(v, options));
}
}
const addlType = addlTypes.length === 0 ? UNKNOWN : tsUnion(addlTypes);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm afraid the logic here is not correct: We need to addUNKNOWN iffadditionalProperties: true (or it is unset andoptions.ctx.additionalProperties is set).

So for example, for the following, we should generatestring | unknown:

type:objectadditionalProperties:truepatternProperties:".*":type:string

IIUC the current code would only generatestring.

(FWIW: I realize this was wrong in my PR as well).

given: { type: "object", patternProperties: {} },
want: `{
[key: string]: unknown;
}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this test case is correct. I think the result here should be the empty object.

IIUC openapi-typescript works under the base assumption that the default foradditionalProperties is false (which is not actually the JSON schema default). So in this object type, no keys are allowed:

The additionalProperties keyword is used to control the handling of extra stuff, that is, properties whose names are not listed in the properties keyword or match any of the regular expressions in the patternProperties keyword. By default any additional properties are allowed.

From:https://json-schema.org/understanding-json-schema/reference/object#additionalproperties

@duncanbeevers maybe you can double check my understanding of the--additional-properties flag?

},
],
[
"patternProperties > additional and patterns",
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add test cases with:

  • additionalProperties: true?
  • options.additionalProperties = true?

@bRRRITSCOLDtkww
Copy link

Any more movement on this?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gzm0gzm0gzm0 requested changes

@kerwanpkerwanpAwaiting requested review from kerwanpkerwanp is a code owner automatically assigned from openapi-ts/maintainers

Requested changes must be addressed to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@hontas@gzm0@drwpow@bRRRITSCOLDtkww

[8]ページ先頭

©2009-2025 Movatter.jp