I am happy to announce the sgcOpenAPI Pascal Parser, a brand new product allowing import an OpenAPI Specification and generate a Pascal Interface. The sgcOpenAPI Parser supports the following specifications:
Supports the following Authentications:
An OpenAPI Parser is a tool used for parsing and validating OpenAPI specifications. OpenAPI is a specification for building APIs that defines a standard language-agnostic interface for RESTful web services.
The OpenAPI Parser reads OpenAPI documents written in either JSON or YAML format, and ensures that they adhere to the specification's rules and guidelines. This includes checking that the document contains all the required fields, has valid data types, and conforms to the expected structure.
In addition to validating the syntax of the OpenAPI document, the parser can also be used to generate code from the specification, making it easier to implement the API in different programming languages.
Overall, the OpenAPI Parser helps ensure that APIs are built according to the OpenAPI specification, which can improve interoperability between different APIs and make it easier for developers to consume and integrate them.
Now you can use the sgcOpenAPI Parser to import any OpenAPI Specification and generate the required Delphi / Pascal interface methods to interactuate with the API.
Find below an example of OpenAPI Specification used to get information given an IP Address
123456789101112131415161718192021222324252627282930{"openapi": "3.0.1","servers": [{"url": "https://ipgeolocation.abstractapi.com"}],"info": {"description": "Abstract IP geolocation API allows developers to retrieve the region, country and city behind any IP worldwide. The API covers the geolocation of IPv4 and IPv6 addresses in 180+ countries worldwide. Extra information can be retrieved like the currency, flag or language associated to an IP.","title": "IP geolocation API","version": "1.0.0","x-apisguru-categories": ["location"],"x-logo": {"url": "https://api.apis.guru/v2/cache/logo/https_global-uploads.webflow.com_5ebbd0a566a3996636e55959_5ec2ba29feeeb05d69160e7b_webclip.png"},"x-origin": [{"format": "openapi","url": "https://documentation.abstractapi.com/ip-geolocation-openapi.json","version": "3.0"}],"x-providerName": "abstractapi.com","x-serviceName": "geolocation"},"externalDocs": {"description": "API Documentation","url": "https://www.abstractapi.com/ip-geolocation-api#docs"
The sgcOpenAPI Parser reads the specification and creates automatically all required classes, methods... to interactuate with the class. Find below the interface created given the prior specification.
123456789101112131415161718192021222324252627282930{ ***************************************************************************sgcOpenAPI componentwritten by eSeGeCecopyright © 2023Web : http://www.esegece.com*************************************************************************** }unit geolocation;interface{$IF DEFINED(VER280) OR DEFINED(VER290) OR DEFINED(VER300) OR DEFINED(VER310) OR DEFINED(VER320) OR DEFINED(VER330) OR DEFINED(VER340) OR DEFINED(VER350)}{$DEFINE SGC_OPENAPI_JSON}{$IFEND}usesClasses, SysUtils,sgcHTTP_OpenAPI_Client;Type{$IFDEF SGC_OPENAPI_JSON}TsgcOpenAPI_inline_response_200_Class = class;TsgcOpenAPI_Retrieve_the_location_of_an_IP_address_Response = class;{$ELSE}TsgcOpenAPI_inline_response_200_Class = string;TsgcOpenAPI_Retrieve_the_location_of_an_IP_address_Response = string;{$ENDIF}
123456789101112131415function GetCountry(const aApiKey, aIpAddress: string): string;varoResponse: TsgcOpenAPI_Retrieve_the_location_of_an_IP_address_Response;beginoResponse := GetOpenAPIClient.Retrieve_the_location_of_an_IP_address(aApiKey, aIpAddress);Tryif oResponse.IsSuccessful thenresult := oResponse.Successful.Countryelseraise Exception.Create(oResponse.ResponseError);FinallyoResponse.Free;End;end;
Find below a link to the sgcOpenAPI Parser Trial
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.