Switch spec parsing to OpenAPI 3 (native pipeline)#1584
Conversation
Switch the generator from Swagger 2 to OpenAPI 3 spec parsing. OpenAPI 3 is now the native pipeline: the parser reads servers, components/schemas, securitySchemes, requestBody, response content and oneOf/discriminator unions directly. Swagger 2 stays fully supported as a legacy adapter that converts its document to the OpenAPI 3 shape at construction and inherits the pipeline, so both formats produce identical SDKs by construction. - src/Spec/OpenAPI3.php: native OpenAPI 3 parser (new) - src/Spec/Swagger2.php: thin up-converting adapter (was the full parser) - src/Spec/Spec.php: getRequestModelEnums/getAllEnums on the base contract - src/SDK/SDK.php: derive spec.basePath from the endpoint URL - example.php: openapi3 by default, format as third CLI arg (php example.php <sdk> <platform> <swagger2|openapi3>), optional SDK_GEN_SPEC_FILE override, shared Config constants Tests are restructured into suites and run on shared fixtures: - tests/unit: spec parser tests incl. a cross-format parity test that asserts both formats parse into the exact same internal representation - tests/e2e: per-language SDK tests, now generating from the OpenAPI 3 fixture; the mock server is removed again in tearDown - tests/resources: spec-swagger2.json + spec-openapi3.json parity twins shared by both suites (plus upload fixtures) - CI runs the unit suite in its own job Verified byte-identical output for all SDK targets across the console, client and server platforms, between both spec formats and against the pre-refactor generator.
The spec parser tests moved to tests/unit and run in the dedicated Tests / Unit job.
The published @appwrite.io/console package does not export the new Apps service yet, which breaks the CLI validation build.
Spatial attribute models (line, polygon) have nested array defaults (List<List<double>>). The From() factory derived the ConvertToList element type by stripping every List< prefix, collapsing nested lists to their scalar type and breaking compilation. Strip only the outermost List<...> instead.
The 14.0.0 release is generated from the updated console spec, fixing the type errors against new API methods. The caret range picks up future minor and patch updates.
Model and definition generation is fully supported: per-definition model classes, request models, enums, nested references and union types.
Greptile SummaryThis PR replaces the legacy Swagger 2 parsing pipeline with a native OpenAPI 3 parser (
Confidence Score: 5/5Safe to merge. The cross-format parity test is a strong correctness guarantee, and the author reports zero diff across all SDK targets when comparing both parsers against the real cloud spec. The refactoring is well-contained: Swagger 2 converts to OpenAPI 3 at construction time and inherits the shared pipeline, so no template or downstream consumer can silently diverge. The parity harness plus 1379-assertion e2e suite gives strong confidence. Both noted items are non-functional. No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "(fix): initialize the header parameters ..." | Re-trigger Greptile |
The parameters map initialized 'headers' (plural) while header parameters are appended to 'header' (singular), which is also what the templates consume. Carried over from the legacy parser.
What does this PR do?
Switches the SDK generator from Swagger 2 to OpenAPI 3 spec parsing, with OpenAPI 3 as the native pipeline of the codebase.
Architecture
src/Spec/OpenAPI3.php(new) — the native parser. Readsservers,components/schemas,components/securitySchemes,requestBody, responsecontent, and realoneOf/anyOf/discriminatorunions directly.src/Spec/Swagger2.php— now a thin legacy adapter (~190 lines, was ~890). It converts the Swagger 2 document into its OpenAPI 3 equivalent at construction (host/basePath/schemes/x-host-docs→servers, body/formData params →requestBody, responseschema→ responsecontent, deep#/definitions/→#/components/schemas/ref rewrite) and inherits the entire pipeline — so both formats produce identical SDKs by construction.example.phpdefaults to OpenAPI 3 specs (open-api3-{version}-{platform}.json); format is selectable:php example.php <sdk> <platform> <swagger2|openapi3>. A local spec can be supplied withSDK_GEN_SPEC_FILE=/path/to/spec.json.Tests
tests/split intounit/(spec parser tests, no Docker, runs in its own CI job) ande2e/(per-language SDK tests).tests/resources/:spec-swagger2.json+spec-openapi3.jsonare parity twins;OpenAPI3SpecTest::testParsesIdenticallyToSwagger2asserts both parse into the exact same internal representation, so the fixtures (and formats) can't drift silently.tearDown()(no more leftovermockapicontainers locally).Verification
diff -rreports zero differing files, and output is also byte-identical to the pre-refactor generator.composer lint,rector, unit suite (32 tests): clean.Upstream dependencies (resolved)
Fix OpenAPI 3 spec generation parity with Swagger 2 appwrite#12564 spec generator parity fixes→ regenerated specs published via feat: API specs update for version latest specs#77 and feat: API specs update for version 1.9.x specs#78 (generated from the fix branch through appwrite-labs/cloud#4319); the generator patch itself still awaits merge upstream but no longer blocks this PRRepublished→ merged to appwrite/specs main; verified the default OpenAPI 3 flow produces SDKs byte-identical to Swagger 2open-api3-*specsNew→ 14.0.0 released and the CLI updated to@appwrite.io/consolerelease^14.0.0All 58 CI checks are green.
Related PRs and Issues