Repository navigation
chore: absorb openapi into packages/openapi - #13865
Conversation
CONTEXT.md states that an extension is "captured on every model that can
carry one". Discriminator was the exception: the reader built it from
propertyName and mapping and dropped every x- key alongside them, so an
extension nested inside a discriminator was unreachable from the parsed
Specification.
This matters because the standard mapping is single-valued — it maps one
property value to one schema. A union whose members are told apart by a
combination of properties cannot be expressed with it. Appwrite's spec
carries the full rule set in `x-mapping`:
"discriminator": {
"propertyName": "type",
"mapping": { "string": ".../attributeString" },
"x-mapping": {
".../attributeEmail": { "type": "string", "format": "email" },
".../attributeString": { "type": "string" }
}
}
Five of its attribute models share `type: "string"` and differ only by
`format`, so `mapping` can name just one of them and consumers reading
only `mapping` silently collapse the other four into it.
The reader already has Value::extensions(); this passes its result to the
constructor. Nothing here interprets the extension — it is captured and
handed to the consumer, which is the contract every other model follows.
Every schema class sat under Model\Schema, which stuttered on the base
class and repeated itself on the kinds:
Utopia\OpenAPI\Model\Schema\Schema
Utopia\OpenAPI\Model\Schema\ArraySchema
Utopia\OpenAPI\Model\Schema\ObjectSchema
The segment carried no information the class names did not already
carry, and a consumer importing a base type and two kinds read Schema
three times per line. The classes move up beside the models they are
part of, so the base is Model\Schema and a kind is Model\ArraySchema.
Dropping the suffix instead is not possible. Array, Object, String and
Never are reserved and cannot name a class in PHP, so Model\Schema\Array
and its neighbours cannot exist, and dropping the suffix only where the
language allows would leave Schema\Integer beside Schema\ArraySchema.
Removing the namespace segment keeps every kind named consistently while
taking the redundancy out of the path.
Model is a flat namespace of value objects, so schemas sit naturally
next to Parameter, Response and MediaType rather than one level below
them. No behaviour changes: the classes, their properties and their
relationships are untouched.
Flatten the schema namespace
Stop interpreting x-nullable
An anyOf can combine a string enum with an enum-free string branch to document common values without closing the accepted set. Consumers currently have to repeat that structural interpretation themselves.\n\nExpose the enum-bearing branch from CompositeSchema when the union has exactly that shape. Keep oneOf, mixed-type unions, and unions with multiple enums unchanged.
feat: expose open string enum branches
Expose typed string enum metadata
…tion Validate open enum metadata
Allow derived enum keys
(feat): map OAS 3.1 annotated enumerations onto StringSchema
Add explicit schema reference resolution
feat: expose accepted and required security scheme names
chore(openapi): absorb library into monorepo
feat(openapi): expose conditional model references
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
| public function testFileTypeReadsAsBinaryStringUnderEveryDialect(): void | ||
| { | ||
| foreach ([Version::V2, Version::V3_0, Version::V3_1] as $version) { | ||
| $schema = $this->reader($version)->read(['type' => 'file'], '#/x'); | ||
| self::assertInstanceOf(StringSchema::class, $schema); | ||
| self::assertSame('binary', $schema->format); | ||
| } | ||
| } |
There was a problem hiding this comment.
These tests explicitly preserve behavior that their own comments acknowledge is invalid for some OpenAPI dialects. Pinning known-bad implementation behavior means a correct dialect-gating fix will fail the suite. This violates the repository directive to test observable behavior rather than mirror implementation or version-specific behavior. Replace these compatibility pins with tests of the valid per-dialect contract; the numeric-exclusive-bounds test at lines 586–599 has the same problem. This repository requirement must be satisfied before merging.
Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/openapi/tests/Schema/ReaderTest.php
Line: 573-580
Comment:
**Tests Pin Invalid Behavior**
These tests explicitly preserve behavior that their own comments acknowledge is invalid for some OpenAPI dialects. Pinning known-bad implementation behavior means a correct dialect-gating fix will fail the suite. This violates the repository directive to test observable behavior rather than mirror implementation or version-specific behavior. Replace these compatibility pins with tests of the valid per-dialect contract; the numeric-exclusive-bounds test at lines 586–599 has the same problem. This repository requirement must be satisfied before merging.
**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| if (preg_match('/^3\.0(?:\.\d+)?$/D', $version) === 1) { | ||
| return self::V3_0; | ||
| } | ||
|
|
||
| if (preg_match('/^3\.1(?:\.\d+)?$/D', $version) === 1) { |
There was a problem hiding this comment.
Prohibited Regular Expressions
This version parser adds two preg_match calls even though the repository explicitly prohibits new regular expressions and requires string functions or an existing validator unless the PR explains why no alternative works. The JSON Pointer escape check in Reference/LocalResolver.php:40 repeats the same violation. This repository requirement must be satisfied before merging.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/openapi/src/Version.php
Line: 19-23
Comment:
**Prohibited Regular Expressions**
This version parser adds two `preg_match` calls even though the repository explicitly prohibits new regular expressions and requires string functions or an existing validator unless the PR explains why no alternative works. The JSON Pointer escape check in `Reference/LocalResolver.php:40` repeats the same violation. This repository requirement must be satisfied before merging.
**Context Used:** AGENTS.md ([source](https://github.com/appwrite/appwrite/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| ## Development | ||
|
|
||
| Development takes place in the [utopia-php monorepo](https://github.com/utopia-php/monorepo). From its root, run: | ||
|
|
||
| ```sh | ||
| bin/monorepo test openapi | ||
| bin/monorepo check openapi | ||
| bin/monorepo validate | ||
| ``` | ||
|
|
||
| Run `bin/monorepo check openapi --fix` to apply Pint formatting and Rector refactoring. PHPStan findings require manual fixes. The monorepo provides the shared QA tools; this package keeps its Rector configuration. | ||
|
|
||
| `composer test` is the unit tier and runs on the host against local fixtures. No services or containers are required. Monorepo CI runs tests and QA checks for changed packages, validates package conventions, and lints Markdown with Vale. |
There was a problem hiding this comment.
Development Instructions Are Stale
This section directs contributors to develop from utopia-php/monorepo, contradicting the new banner and the absorb workflow that makes appwrite/appwrite the package's writable home. Contributors following these instructions will work in the obsolete repository. Point this section and its commands at the Appwrite repository root.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/openapi/README.md
Line: 367-379
Comment:
**Development Instructions Are Stale**
This section directs contributors to develop from `utopia-php/monorepo`, contradicting the new banner and the absorb workflow that makes `appwrite/appwrite` the package's writable home. Contributors following these instructions will work in the obsolete repository. Point this section and its commands at the Appwrite repository root.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
|
Squash-merged, so the subtree annotation was dropped and |
appwrite#13865 was squash-merged, which dropped the annotation from the `git subtree add` merge commit and left the split unable to continue the mirror's history (non-fast-forward on utopia-php/openapi). Restore it: the mainline is the squash's parent, the split is the mirror head it was imported from. git-subtree-dir: packages/openapi git-subtree-mainline: c3e1489 git-subtree-split: a988ff1 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Unblocked by #13866. Split run pushed |
|
Retired from the monorepo in utopia-php/monorepo#341. Its Split run no longer includes |
Summary
This moves
utopia-php/openapiintopackages/openapi, so Appwrite loads it directly. It follows the playbook inrfc/monorepo.mdand comes in three commits:Add 'packages/openapi/' from commit 'a988ff18…': subtree import from the mirror with full history. The mirror head is the0.2.4tag Appwrite already locks, and its tree matchespackages/openapiinutopia-php/monorepo(3662e330), so the dependency graph doesn't change.chore(openapi): mirror plumbing:mirror.ymlnow points here, and the README banner is refreshed.refactor: load openapi from packages/:replaceentries, drops theutopia-php/openapirequire line, and removes the package from the lock.appwrite/sdk-generatorstill requiresutopia-php/openapi: ^0.2.4, andreplacesatisfies that.src/,Utopia\OpenAPI\Tests\), so step A needed no moves.braces_position. Rector is clean.phpstan.neonat level max oversrcandtests, with aphpstan-baseline.neonof 166 findings. The monorepo analysed this package at level 5. Nearly all the findings are offset access on the decodedmixeddocument inParser/*. The RFC's phase 8 burn-down list now includes them, next to compression and system.There's nothing to hoist, since the package requires only PHP and
ext-json. Appwrite uses it inTasks/Specs.php,Tasks/SDKs.phpandSDK/Specification/Format{,/OpenAPI3}.php, and root PHPStan passes on all of them.Validation
bin/monorepo validate: all packages validbin/monorepo check openapi: Rector, Pint, and PHPStan level max (with baseline) passbin/monorepo test openapi: 122 tests / 680 assertionsvendor/bin/phpunit --testsuite packages --filter 'Utopia\\OpenAPI\\Tests': 122 tests pass under the root autoloadervendor/bin/phpunit tests/unit/SDK: 43 tests passbin/monorepo split openapi --dry-run:ce6a9705, which fast-forwards from the mirror heada988ff18git diff --checkMerge and follow-up
Warning
Merge with a merge commit, not a squash. A squash drops the
git-subtree-*annotation, and the split then gets rejected by the mirror. That happened with #13862 and needed #13864 to fix.The
utopia-php/openapimirror already has the canonicalmainruleset (id22564359), with the split app as an always-bypass actor, so the absorb ran with--skip-ruleset.After merge: confirm
Splitpushes toutopia-php/openapi. Then removepackages/openapifromutopia-php/monorepo. The mirror has no open PRs, and neither does the monorepo for openapi.🤖 Generated with Claude Code