The OpenAPI Specification, previously known as the Swagger Specification, is a specification for machine-readable interface files for describing, producing, consuming, and visualizing RESTful web services. Previously part of the Swagger framework, it became a separate project in 2016, overseen by the OpenAPI Initiative, an open-source collaboration project of the Linux Foundation. Swagger and some other tools can generate code, documentation, and test cases given an interface file.
Applications implemented based on OpenAPI interface files can automatically generate documentation of methods, parameters and models. This helps keep the documentation, client libraries, and source code in sync.
A new OpenAPI WebService has been released (currently is BETA) which reads the OpenAPI 3.0 Specification in JSON Format and creates automatically a Delphi Client in Native Pascal Code. The WebService creates a demo which shows how interactuate with the API.
The WebService requires the Specification is 3.0+ and in JSON format.
The first step is import the openAPI 3.0 specification, to do this I will use a simple openAPI specification used by abstractapi.com to retrieve the location of an IP Address. Find below the specification file:
Once you've the openAPI 3.0 specification in JSON format, you can generate the required Delphi files using our OpenAPI WebService, go to the following url:
https://www.esegece.com/openapi/ws/demo
Just set the classname (by default will be TsgcOpenAPI_Test) and upload the specification file (first uncompress it!!!, must be in JSON format). Finally press the button Upload to process the file.
If the process is successful, a new compressed file will be downloaded with a compiled demo.
Before test the demo, you must create a free account in abstractapi.com to get an API Key.
https://app.abstractapi.com/users/signup
Uncompress the downloaded file and go to the folder Demo, you will find a sgcOpenAPIDemo.exe file, execute it.
A new form is shown, which shows the url of the Abstractapi.com.
Press the next button and select the method Retrieve_the_location_of_an_IP_address, and fill the Api_Key and the IP Address to search. If the request is successfully processed a JSON message will be returned with information about the IP Address.
Find below the compressed generated automatically the sgcOpenAPI WebService to do the tests.
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.