You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: update all-types round-trip test to import Petstore Swagger (V2 and V3) (#171)
* feat: update all-types test to use petstore swagger (v2 and v3)
- updating to honor original spec format of imported spec
* Enhance round-trip comparison by refining ignored properties for API imports
Closes#170
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Elizabeth Maher <enewman@microsoft.com>
### 2026-06-20: Link-import vs inline-import operation fidelity (round-trip)
110
+
111
+
When comparing a *link-imported* API (e.g. Petstore via `swagger-link`/`openapi-link`) against the `apiops publish`*inline-imported* result, operation payloads diverge in two import-path-only ways — neither is an apiops bug:
112
+
113
+
1.**`schemaId`/`typeName` on representations.** APIM binds operation request/response representations to an API-level schema **only on link import**. Inline import (`format: openapi, value: <spec>`, what publish uses) does NOT rebind, so the target has no `schemaId`. The schema *content* is identical and still extracted as API-level Schemas. → strip `schemaId`, `typeName` (and any derived schema token) on operation resources.
114
+
115
+
2.**Parameter/header `description`.** Link import drops `templateParameters`/`queryParameters`/header descriptions; inline import preserves them from the spec. So the published **target is more faithful** than the link-imported source. Authoritative descriptions live in the API schema. → strip `description` on parameter-shaped objects (`{ name, …, values }`).
116
+
117
+
Round-trip comparison harness (`tests/integration/all-resource-types`) normalizes both via `RepresentationSchemaRefIgnoredProperties` and `ParameterIgnoredProperties`. Symptom if not stripped: every operation shows a `properties.request/responses/templateParameters` DIFF present-on-one-side-only.
### 2026-06-19: Spec dialect (Swagger 2.0 vs OpenAPI 3.0) is orthogonal to APIM `apiType`
122
+
**By:** CodeReviewer
123
+
**Status:** Approved
124
+
**Context:** Round-trip extract→publish produced diffs on a natively Swagger 2.0 REST API.
125
+
**Learned:**
126
+
- APIM's `properties.type` (`http`/`soap`/`graphql`/…) does **not** encode spec dialect — both Swagger 2.0 and OpenAPI 3.0 REST APIs are `type=http`. Dialect is a separate axis and must be detected, not inferred from type.
127
+
- Detect dialect from the auto-generated schema's content type: `application/vnd.ms-azure-apim.swagger.definitions+json` ⇒ Swagger 2.0, `application/vnd.oai.openapi.components+json` ⇒ OpenAPI 3.0. (Spec body itself: top-level `"swagger":"2.0"`.)
128
+
- APIM's `openapi-link` export **silently converts** Swagger 2.0 → OpenAPI 3.0, dropping parameter-level metadata (e.g. `format: int64`) and rewriting schema content types — a §VII silent-data-loss trap. Fidelity requires exporting via `swagger-link` and importing via `swagger-json` (JSON only; there is no inline Swagger YAML import format).
129
+
- Do **not** overload `apiType` with a synthetic value like `'Swagger2'`: `apiType` is a real APIM property echoed back on PUT and validated, so it must stay within the type enum. Carry dialect as its own parameter/type instead.
130
+
- Swagger 2.0 path parameters use the inline shape `{ name, in, required, type }`; OpenAPI 3.x wraps it as `{ ..., schema: { type } }`. Any injected/sanitized params must match the document's dialect.
131
+
**Decision:** Introduced `ApiSpecDialect = 'openapi3' | 'swagger2'` as a first-class, detected axis threaded through export and import; preferred an explicit dialect type over a boolean or an overloaded `apiType`.
132
+
**Constitution compliance:** §II (APIM-native formats), §VII (no silent round-trip loss)
0 commit comments