OapiCodemode.SpecStore.OperationSummary (oapi_codemode v0.5.0)

Copy Markdown View Source

One entry of the slim search index, in struct form.

This is the whole of what search_apis puts in the sandbox for an operation (~1 KB): enough to find it and to see what it takes, never its schemas. param_index is the {name, in, required} identity of each parameter, resolved at decompose time so the index costs no ref walking — and already filtered there, so a store persists it and hands it back rather than deciding anything about it (a parameter whose identity could not be resolved has no entry; see OapiCodemode.Operation).

The JSON shape is OapiCodemode.Ingest.index_entry/1's and is not restated here: from_operation/1 goes through it, and index_entry/1 inverts the same key table. That keeps the index_bytes measured at ingest equal to the bytes a store's index is later encoded to.

segments is the exception: it is path parsed into literals and {:param, name} holes, derived here rather than stored or encoded, because OapiCodemode.Proxy.Matcher binds an intercepted path against it on every request and re-splitting the whole index per request would be the same work over and over. Deriving it in the two constructors means every store's index carries it without persisting a second spelling of path, and index_entry/1 leaves it out — the sandbox reads paths, not our match shape.

Summary

Functions

The index-entry map for this summary — what gets spliced into the sandbox.

Types

t()

@type t() :: %OapiCodemode.SpecStore.OperationSummary{
  id: String.t(),
  method: String.t(),
  param_index: [map()],
  path: String.t(),
  segments: [String.t() | {:param, String.t()}],
  summary: String.t() | nil,
  tags: [String.t()]
}

Functions

from_index_entry(entry)

@spec from_index_entry(map()) :: t()

Reads a summary out of an OapiCodemode.Ingest.index_entry/1 map.

from_operation(operation)

@spec from_operation(OapiCodemode.Operation.t()) :: t()

Summarises an operation, through OapiCodemode.Ingest.index_entry/1.

index_entry(summary)

@spec index_entry(t()) :: map()

The index-entry map for this summary — what gets spliced into the sandbox.