داده، SQL، قراردادها و ماشین حالت · فصل ۵ — JSON Schema، OpenAPI، AsyncAPI، Protobuf و gRPC · 70
OpenAPI 3.1: HTTP Contract as Source
Review and falsify one OpenAPI 3.1 HTTP contract: bind method/path, parameters, request/response media types, status outcomes and Schema Objects to executable examples, while recording version/dialect boundaries and implementation drift. میتواند «OpenAPI 3.1: HTTP Contract as Source» را برای یک domain محدود مدل کند و constraint، compatibility یا recovery evidence لازم را مشخص کند.
Lesson summary
Review and falsify one OpenAPI 3.1 HTTP contract: bind method/path, parameters, request/response media types, status outcomes and Schema Objects to executable examples, while recording version/dialect boundaries and implementation drift.
میتواند «OpenAPI 3.1: HTTP Contract as Source» را برای یک domain محدود مدل کند و constraint، compatibility یا recovery evidence لازم را مشخص کند.
This lesson produces
میتواند «OpenAPI 3.1: HTTP Contract as Source» را برای یک domain محدود مدل کند و constraint، compatibility یا recovery evidence لازم را مشخص کند.
Who it is for
Foundation
Worked baseline, explicit evidence table, local fixture and one guided failure probe.
Repair
Reduce to one broken contract/protocol assumption, observe it, repair it, then restore the full case.
Experienced
Compress introductory syntax; require independent compatibility/reliability decision, negative evidence and residual-limit statement.
Prerequisites
_Locale: en-US · Lesson: DAT-013 · Public order: 70_
Outcome and working artifact
This lesson produces a OpenAPI HTTP Contract Review Record v1: a decision artifact that separates observations, assumptions, limits, and required evidence. The goal is a transferable model, not memorized tool names.
میتواند «OpenAPI 3.1: HTTP Contract as Source» را برای یک domain محدود مدل کند و constraint، compatibility یا recovery evidence لازم را مشخص کند.
Boundary model
OpenAPI can be the inspectable source for an HTTP contract, but a rendered documentation page is not runtime conformity evidence. A review must connect method and path, parameters, media types, request and response schemas, status outcomes, examples, and observed server behavior. It must also keep the OpenAPI document version separate from the product API version.
Keep three labels throughout the work: observed, bounded inference, and needs verification. When evidence is unavailable, record unknown. A product name or a passing happy path is not a substitute for evidence.
1. Version fields answer different questions
The top-level openapi value selects the specification version used by the document. info.version identifies the described API release under the team's versioning policy.
2. An operation is more than a path
Method, path template, path/query/header parameters, request body, media types, responses, and security declarations together define the bounded interface.
3. Schema Objects need a declared boundary
OpenAPI 3.1 aligns its Schema Object model with JSON Schema vocabularies, but tool support and dialect behavior still need to be pinned and tested.
4. Examples are evidence fixtures, not decoration
A request example should validate against the request schema and a response example should match its status code, media type, and schema. Negative fixtures reveal undocumented behavior.
5. Runtime drift needs a separate probe
A syntactically valid document can disagree with the deployed handler. Contract tests compare actual requests and responses to the source without claiming every implementation path was explored.
Five-step method
- Pin the OAS version and state the independent API versioning rule.
- Select one operation and enumerate its complete HTTP surface.
- Validate request and response examples against the correct media type and Schema Object.
- Probe a missing required parameter, wrong media type, undocumented status, and schema-invalid response.
- Record document result, runtime observation, tool limitation, and compatibility decision separately.
Worked case
POST /orders accepts JSON with customerId and at least one item. The contract documents 201, 400, and 409 outcomes. A baseline example validates and the synthetic handler returns a 201 body matching its schema. Negative probes omit customerId, send text/plain, return an undocumented 500 shape, and add a future optional Idempotency-Key header. The record distinguishes a document defect from a handler drift and classifies the optional header separately from the new 409 response.
Decision and evidence matrix
| Concern | Boundary or owner | Evidence | Decision or limitation |
|---|---|---|---|
| Document version | openapi 3.1.x | Parser and source pin | Not the API release version |
| Request | POST /orders application/json | Positive and negative examples | Required fields enforced |
| Responses | 201/400/409 | Status-media-schema matrix | Undocumented outcomes stay open |
| Runtime | Synthetic handler | Observed exchange | Partial path evidence only |
| Change | Optional idempotency header | Old/new consumer review | Separate compatibility decision |
Failure probes and repair
- OpenAPI documentation proves the server implementation conforms at runtime.
- The openapi field is the API product version or the same thing as info.version.
- OpenAPI 3.1 is the latest overall OAS feature set as of 2026-09-02.
- A valid Schema Object guarantees every code generator or validator behaves identically.
For each statement, narrow the claim, create a counterexample, and name the observation that could confirm or reject it.
Transfer challenge
Change the scenario so that one assumption in the worked case no longer holds. Rebuild the OpenAPI HTTP Contract Review Record v1 without copying the earlier decision, then explain what changed in the input and what stayed stable in the decision rule.
What this does not prove
This lesson does not claim certification, production guarantees, or coverage of every implementation. Its conclusion is valid only within the scenario boundary, dated sources, and recorded observations.
Self-check
- [ ] Did I separate responsibilities from framework or tool names?
- [ ] Did I state at least one failure probe and its predicted observable?
- [ ] Are fact, inference, and design choice visibly separated?
- [ ] Did I record non-claims and missing evidence?
- [ ] Did I complete transfer in a changed context without a prepared answer?
Sources and freshness boundary
Sources were reviewed for the frozen Bible as of 2026-09-19. A review_due date triggers a versioned requalification; it does not authorize silent in-place edits.
- OAS-3.1.2 — Normative OpenAPI 3.1 family semantics used by the locked lesson scope. (https://spec.openapis.org/oas/v3.1.2.html; review: 2026-10-17)
- OAS-LATEST — Current latest published OpenAPI Specification context; not used to rewrite the locked 3.1 lesson scope. (https://spec.openapis.org/oas/latest.html; review: 2026-10-17)
Assessment
There is no answer key in this lesson pack; answer it yourself and mark honestly. "Needs review" sends the lesson to your review queue.
DAT-013-S1 retrieval
DAT-013-S2 application
DAT-013-S3 diagnosis
DAT-013-S4 decision
DAT-013-S5 transfer
Assessment rubric
| Dimension | Critical | Sufficient evidence |
|---|---|---|
| contract/protocol correctness | yes | Explanation preserves version/dialect, compatibility/reliability and evidence semantics. |
| evidence quality | yes | Positive, negative and change/repair observations are traceable and separated from inference. |
| scope discipline | yes | Adjacent outcomes and unsupported tool/runtime generalizations are deferred. |
| transfer independence | yes | Changed-context task is solved without decisive scaffold. |
A submission passes only when every critical dimension is sufficient and the learner states missing evidence honestly. AI suggestions are not observed evidence; the learner remains accountable for the final bounded judgment.
References & freshness
Case studies
Lab files
Build OpenAPI HTTP Contract Review Record v1 from the safe local fixture. First state a prediction. Then record the baseline, run or simulate the declared failure probes against the fixture, and preserve both positive and negative observations. Complete the transfer case without copying the worked lesson decision.
The starter intentionally does not choose the final classification or risk decision. Edit evaluate_record.py and the evidence template. Run python3 ../run_checks.py from this directory's parent to verify the environment and file shape; those checks do not grade your substantive decision.
Safety boundary: No production system/data, no external account/service dependency, and all failure probes must be bounded and deterministic.
Lesson media & slides
Teaching files (download)