Forum > General
openAPI client
rnervi:
@paweld: worked like a charm ! now it's clear. ty again !
Thaddy:
--- Quote from: gidesa on July 02, 2024, 04:55:30 pm ---There is this library, for FPC and Delphi:
https://github.com/landgraf-dev/openai-delphi
--- End quote ---
That is quite, he uses my code I published one day after the API was officially released as beta. Christmas 2022.. Anyway, that is free to use without restrictions.
It originates from FreePascal for that reason.....(proof is on this forum)
There is a nice little anecdote: you need a developer key to use GPT and mine expired a couple of months later. Nice thing is I explained, showed what I did, proved my age (pensionado), and... got a new key... which does not seem to expire!. Thank you, OpenAI and Microsoft!!
abouchez:
I was not please with the Wagner code, clearly not really FPC friendly, and was not able to find Thaddy's original code.
So I made my own OpenAPI client generator:
https://blog.synopse.info/?post/2024/09/06/Swagger/OpenAPI-Client-Generator-for-Delphi-and-FPC
;D
Here are some features of our OpenAPI code generator for Delphi and FPC:
- Use high-level pascal records and dynamic arrays for "object" DTOs
- Use high-level pascal enumerations and sets for "enum" values
- Translate HTTP status error codes into high-level pascal Exceptions
- Recognize similar "properties" or "enum" to reuse the same pascal type
- Support of nested "$ref" for objects, parameters or types
- Support "allOf" attribute, with proper properties inheritance/overloading
- Support "oneOf" attribute, for strings or alternate record types
- Support of "in":"header" and "in":"cookie" parameter attributes
- Fallback to variant pascal type for "oneOf" or "anyOf" JSON values
- Generated source code units are very small and easy to use, read and debug
- Can generate very detailed comment documentation in the unit source code
- Tunable engine, with plenty of generation options (e.g. about verbosity)
- Leverage the mORMot RTTI and JSON kernel for its internal plumbing
- Compatible with FPC and oldest Delphi (7-2009)
- Tested with several Swagger 2 and OpenAPI 3 reference content
But still not fully compliant to all existing files: feedback is welcome!
The source code of the generator is a single unit:
https://github.com/synopse/mORMot2/blob/master/src/net/mormot.net.openapi.pas
And you will find several generated sample code units in the blog article, to make yourself your idea about the level of this little unit.
Feedback is welcome!
Navigation
[0] Message Index
[*] Previous page