Skip to content

chore: absorb openapi into packages/openapi - #13865

Merged
loks0n merged 36 commits into
mainfrom
feat/absorb-openapi
Sep 23, 2026
Merged

loks0n merged 36 commits into
mainfrom
feat/absorb-openapi

Conversation

@loks0n

@loks0n loks0n commented Sep 23, 2026

Copy link
Copy Markdown
Member

Summary

This moves utopia-php/openapi into packages/openapi, so Appwrite loads it directly. It follows the playbook in rfc/monorepo.md and comes in three commits:

  1. Add 'packages/openapi/' from commit 'a988ff18…': subtree import from the mirror with full history. The mirror head is the 0.2.4 tag Appwrite already locks, and its tree matches packages/openapi in utopia-php/monorepo (3662e330), so the dependency graph doesn't change.
  2. chore(openapi): mirror plumbing: mirror.yml now points here, and the README banner is refreshed.
  3. refactor: load openapi from packages/:
    • Adds the root autoload and replace entries, drops the utopia-php/openapi require line, and removes the package from the lock. appwrite/sdk-generator still requires utopia-php/openapi: ^0.2.4, and replace satisfies that.
    • The package already had the standard shape (src/, Utopia\OpenAPI\Tests\), so step A needed no moves.
    • Pint formatting, mostly braces_position. Rector is clean.
    • Adds a phpstan.neon at level max over src and tests, with a phpstan-baseline.neon of 166 findings. The monorepo analysed this package at level 5. Nearly all the findings are offset access on the decoded mixed document in Parser/*. 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 in Tasks/Specs.php, Tasks/SDKs.php and SDK/Specification/Format{,/OpenAPI3}.php, and root PHPStan passes on all of them.

Validation

  • bin/monorepo validate: all packages valid
  • bin/monorepo check openapi: Rector, Pint, and PHPStan level max (with baseline) pass
  • bin/monorepo test openapi: 122 tests / 680 assertions
  • vendor/bin/phpunit --testsuite packages --filter 'Utopia\\OpenAPI\\Tests': 122 tests pass under the root autoloader
  • vendor/bin/phpunit tests/unit/SDK: 43 tests pass
  • bin/monorepo split openapi --dry-run: ce6a9705, which fast-forwards from the mirror head a988ff18
  • git diff --check

Merge 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/openapi mirror already has the canonical main ruleset (id 22564359), with the split app as an always-bypass actor, so the absorb ran with --skip-ruleset.

After merge: confirm Split pushes to utopia-php/openapi. Then remove packages/openapi from utopia-php/monorepo. The mirror has no open PRs, and neither does the monorepo for openapi.

🤖 Generated with Claude Code

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.
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): map OAS 3.1 annotated enumerations onto StringSchema
ChiragAgg5k and others added 6 commits September 8, 2026 10:06
feat: expose accepted and required security scheme names
chore(openapi): absorb library into monorepo
feat(openapi): expose conditional model references
…e48aa906'

git-subtree-dir: packages/openapi
git-subtree-mainline: c3e1489
git-subtree-split: a988ff1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@loks0n loks0n added the absorb History-preserving package absorption; merge commit required label Sep 23, 2026
@loks0n loks0n self-assigned this Sep 23, 2026
@greptile-apps

greptile-apps Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The runtime migration appears sound, but the explicit repository requirements concerning test design and regular expressions must be satisfied before merging.

Fix All in Claude CodeFindings

  1. P2 Tests Pin Invalid Behavior ▶
  2. P2 Prohibited Regular Expressions ▶
  3. P2 Development Instructions Are Stale ▶
Fix with agent prompt
### Issue 1
packages/openapi/tests/Schema/ReaderTest.php:573-580
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.

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!

### Issue 2
packages/openapi/src/Version.php:19-23
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.

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!

### Issue 3
packages/openapi/README.md:367-379
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.

Summary

This PR absorbs the previously locked utopia-php/openapi package into packages/openapi, wires it into the root Composer autoloader, and adds package-local quality configuration and mirror plumbing.

  • The imported implementation corresponds to the previously locked 0.2.4 source commit.
  • Composer now satisfies downstream package constraints through the root package’s replace declaration.
  • The package includes its parser, model, tests, fixtures, documentation, and static-analysis baseline.
  • Review findings concern deliberately implementation-coupled tests, prohibited regular expressions, and stale development instructions.

Reviews (1) · Last reviewed commit: "refactor: load openapi from packages/"

Comment on lines +573 to +580
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);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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)

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!

Fix in Claude Code Fix in Codex

Comment on lines +19 to +23
if (preg_match('/^3\.0(?:\.\d+)?$/D', $version) === 1) {
return self::V3_0;
}

if (preg_match('/^3\.1(?:\.\d+)?$/D', $version) === 1) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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!

Fix in Claude Code Fix in Codex

Comment on lines +367 to +379
## 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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.

Fix in Claude Code Fix in Codex

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat/absorb-openapi (after).

Metric Before After Change
🚀 Requests/sec 163.63 169.3 ⚪ +3.5%
⏱️ Latency P50 105.24 ms 101.56 ms ⚪ -3.5%
⏱️ Latency P95 241.66 ms 237.23 ms ⚪ -1.8%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 101.56 237.23 10,830 169.3 -4.43
Account 207.83 377.99 570 9.41 +9.55
TablesDB 98.1 182.46 5,890 95.07 -18.78
Storage 92.94 200.87 2,850 47.59 -12.73
Functions 146.69 278.73 1,520 25.88 +5.47

Top API waits (after)

API request Max wait (ms)
account.name.update 623.78
account.prefs.update 474.75
functions.variables.update 467.89
functions.create 440.31
tablesdb.rows.create 411.68

@loks0n
loks0n merged commit 2da06c1 into main Sep 23, 2026
65 checks passed
@loks0n

loks0n commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

Squash-merged, so the subtree annotation was dropped and Split was rejected by the openapi mirror (non-fast-forward). Fix: #13866 restores the annotation. Tested locally: the split fast-forwards onto a988ff1.

pull Bot pushed a commit to dolfly/appwrite that referenced this pull request Sep 23, 2026
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]>
@loks0n

loks0n commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

Unblocked by #13866. Split run pushed utopia-php/openapi main to 64cb0fc, a fast-forward on a988ff1. Remaining: utopia-php/monorepo#341 retires the package there.

@loks0n

loks0n commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

Retired from the monorepo in utopia-php/monorepo#341. Its Split run no longer includes openapi, and the mirror stays at 64cb0fc. The migration is complete.

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

Labels

absorb History-preserving package absorption; merge commit required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants