OapiCodemode.Operation (oapi_codemode v0.5.0)

Copy Markdown View Source

One HTTP operation extracted from a spec, ready for matching and validation.

param_index is the {name, in, required} identity of the entries in parameters, in their order. It exists because parameters may hold Reference Objects: matching, the slim search index and the path/operation parameter merge all need the identity without paying for the referenced schema, so the identity is resolved once at decompose time and the $ref itself is kept.

It is not positionally aligned with parameters, and deliberately: a parameter whose identity could not be resolved — a dangling $ref — has no entry here at all, because a name nobody can read is nothing to search for or match on. parameters still carries its $ref verbatim. So param_index is exactly what the slim index publishes (see OapiCodemode.Ingest.index_entry/1), which is what lets a spec store persist it and hand it back unfiltered.

request_body is the operation's requestBody node exactly as the document wrote it, refs intact — a Request Body Object, or a Reference Object standing in for one. Which media type the body is sent as, and which schema it must satisfy, are not decided here: a Reference Object has no content to decide them from, so OapiCodemode.Ingest.Normalize.extract_body/1 runs at read time, after OapiCodemode.Resolve has resolved the node. nil means the operation declares no body, or wrote one too malformed to be an object at all.

(The parity oracle the test suite runs against — a whole document dereferenced up front, see OapiCodemode.Ingest.Deref — fills this field with extract_body/1's output instead, which is the same shape a read produces. That is the point of it. See OapiCodemode.Ingest.Normalize.operations/2.)

The remaining fields are the document's own, scalar-coerced by Normalize (a value of the wrong type is dropped, never fatal):

  • description — the operation's long description, or nil.
  • responses — the Responses Object verbatim, refs intact; nil if the document's responses was not a map.
  • deprecated — true only for a literal true.

Summary

Types

t()

@type t() :: %OapiCodemode.Operation{
  deprecated: term(),
  description: term(),
  id: term(),
  method: term(),
  param_index: term(),
  parameters: term(),
  path: term(),
  request_body: term(),
  responses: term(),
  security: term(),
  segments: term(),
  summary: term(),
  tags: term()
}