eSeGeCe
software
From sgcOpenAPI Parser 2026.2.0 the Delphi Parser supports using a library instead of a GUI executable. The OpenAPI Parser can be used as a shared library (DLL) so you can generate Pascal clients from your own applications without invoking the command line tool. The library exports a small set of functions that wrap the same parser features available in the CLI.
This article explains how to integrate the OpenAPI parser through the DLL interface and generate Delphi/Pascal client units programmatically. It focuses only on the three exported functions that are required for integration: CreateOpenAPIPascalFile, CreateOpenAPIPascalFileEx, and GetOpenAPILastErrors.
The parser DLL encapsulates the same conversion and generation pipeline used by the command-line tool:
When a function returns False, call GetOpenAPILastErrors immediately to retrieve diagnostic details for logging or UI feedback.
Generates a Pascal client file using the default parser options (generate classes, JSON support, documentation, method names from OperationId, no authentication, no base URL override).
function CreateOpenAPIPascalFile(const aInputFile, aOutputFile: PWideChar): Boolean; stdcall;
Parameters
Return value
Returns True if the file is generated successfully, otherwise False. If it fails, call GetOpenAPILastErrors to retrieve the error message.
Example
if not CreateOpenAPIPascalFile('c:\specs\openapi.json', 'c:\clients\orders.pas') then ShowMessage(GetOpenAPILastErrors);
Use CreateOpenAPIPascalFile when you want a fast integration with standard output and you do not need to tune generation behavior.
function CreateOpenAPIPascalFileEx(const aInputFile, aOutputFile: PWideChar; aGenerateClasses, aGenerateJSON, aGenerateDocumentation: Boolean; aMethodsName, aAuthentication: Integer; const aBaseURL: PWideChar; aEnableLog: Boolean): Boolean; stdcall;
Parameters
Return value
Returns True if the file is generated successfully, otherwise False. If it fails, call GetOpenAPILastErrors to retrieve the error message.
Example: OAuth2 client with explicit base URL and logging
if not CreateOpenAPIPascalFileEx( 'c:\specs\openapi.json', 'c:\clients\orders.pas', True, True, True, 0, 3, 'https://api.example.com/v2', True) then ShowMessage(GetOpenAPILastErrors);
Returns a message describing the last error (validation, conversion, or parsing error) produced by the parser. Call this function after CreateOpenAPIPascalFile or CreateOpenAPIPascalFileEx returns False.
function GetOpenAPILastErrors: PWideChar; stdcall;
Return value
A null-terminated string with the last error message. If no error has occurred, the string can be empty.
Enter your text here ...
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.