class

Detector::Specification::Oas3

Inherits Detector < Reference < Object

Constants

OPENAPI3_JSON_MARKER = /"openapi"[ \t]*:[ \t]*"3\./

JSON gets no such structural guarantee — "openapi": "3.0.0" can sit nested inside a wrapper document — so the JSON branch keeps parsing and checking the root key, and the regex only serves as a cheap pre-gate.

OPENAPI3_YAML_MARKER = /^["']?openapi["']?[ \t]*:[ \t]*["']?3\./m

Every .json/.yaml/.yml in the tree reaches this gate. A bare /openapi/ matched any document that merely mentions OpenAPI — an x-origin: {url: .../openapi.yaml} block, a description, a swagger document that links to its own OAS3 conversion — and each of those paid for a full YAML/JSON parse before being rejected.

In YAML a key at column 0 is a root key: a block scalar's content must be indented past the key that introduces it, so an openapi: 3.x line starting at column 0 cannot be anything but the document's version field. That makes the anchored match as strong as the parse it replaces, so the YAML branch registers on the regex alone and lets the analyzer — which parses the document anyway — be the one that reads it. Previously every OpenAPI document in the tree was parsed twice: once to decide, once to analyze, with the first parse thrown away.

Class methods

tech_name

The tech name without needing an instance, so the registry can be read off the classes themselves rather than from a parallel list.

Source

Instance methods

applicable?(filename : String) : Bool

Registers every OAS3 spec path in CodeLocator for the analyzer pass. Must keep running after first match.

Source
detect(filename : String, file_contents : String) : Bool
Source
idempotent?

Registers every OAS3 spec path in CodeLocator for the analyzer pass. Must keep running after first match.

Source
set_name

Registers every OAS3 spec path in CodeLocator for the analyzer pass. Must keep running after first match.

Source