The OpenAPI Parser

A native Delphi class that reads OpenAPI 3.0, 3.1 and 3.2 specifications, plus Swagger 2.0 documents it converts on the way in, giving you programmatic access to every endpoint, schema and security definition.

TsgcOpenAPI

There is nothing to drop on a form. sgcOpenAPI registers no components and ships no design-time package, so you create TsgcOpenAPI in code, from sgcOpenAPI_Classes.pas, and read any specification into it.

Load Specifications

ReadFromFile takes a path and Read takes the document as a string, while the command line tool downloads a URL first. JSON and YAML are both read locally, and a Swagger 2.0 document is converted to OpenAPI 3.0 locally as well.

Browse the API Model

Paths, Webhooks, Components, Security, Servers, Tags and Info are properties on the object, so operations, parameters, request and response bodies, schemas and security schemes are all reachable through a strongly typed model.

Generate Code

TsgcOpenAPI_Parser_Client_Pascal descends from the same class, so the generator is the reader with an emitter on top. Subclass it to produce Pascal units, or walk the model yourself for custom tooling and automation.

Parser Details

Reference Resolution

A $ref is kept on the object as _Ref rather than inlined, so the model is not dereferenced for you. External file and URL references are pulled in beforehand by TsgcOpenAPI_Bundle, which inlines them, remembers what it has already visited and stops at a maximum depth.

Schema Composition

AllOf, OneOf and AnyOf are read into the schema object, together with Discriminator and its mapping, and the code generator flattens them into Pascal classes.

Specification Validation

Warnings collects everything the reader could not honour, from a missing info object to a keyword the generator ignores, and it is cleared on every read. Line and column are reported for a YAML document that will not parse.

Best value: All-AccessEvery eSeGeCe product, Premium Support included, from €1,059/year.
See All-Access pricing

Try the Parser

Download the free trial and parse your first OpenAPI specification in minutes.