David Schwartz 409 Posted April 20, 2021 Just FYI, I'm not "still on" any particular version of swagger. The project I _was_ on had swagger info published that's generated from Microsoft tools that are in widespread use, and that code itself reports that it was V2.0. I have sampled a bunch of swagger specs I've found around the internet, and I've found very few that are V3.0. I don't know who produces these or how, but if most are being generated by MS tools, then consider it's MS themselves that's responsible for this disparity. Certainly nothing I'm connected to. (I'm not on that project any more, and anyway they had told me not to even use Delphi. So at this point it's just a curiosity.) If MS isn't supporting V3.0, then I'm not sure who's going to use it if it's really that hard to parse. Share this post Link to post
Lars Fosdal 1709 Posted January 23, 2023 Swagger (2.0) had a name transplant and is now known as OpenAPI (3.0). Quote The good news for those that are familiar with Swagger 2.0 is that the changes made for OpenAPI 3.0 are backwards compatible in a functional sense, although your JSON or YAML file will need to be updated as the format has changed a little. And... I now have literally hundreds of Swagger 2.0 APIs to translate to Delphi... Any news from you guys on Delphi and Swagger libs? Edit: Oh, btw - there is code in source\data\EMS.ResourceTypes.pas (D11.1) that generates rudimentary Swagger 2.0 specs in Json or YAML, but it contains numerous TO-DO comments. I guess the author never got to do them, and there doesn't seem to be anything to read Swagger or YAML. Share this post Link to post
Wagner Landgraf 43 Posted January 23, 2023 12 hours ago, Lars Fosdal said: And... I now have literally hundreds of Swagger 2.0 APIs to translate to Delphi... By "translating" are you referring to importing and generating client for it? If yes, I have provided a tool for that: https://github.com/landgraf-dev/openapi-delphi-generator 1 Share this post Link to post
Wagner Landgraf 43 Posted January 23, 2023 2 minutes ago, Wagner Landgraf said: By "translating" are you referring to importing and generating client for it? If yes, I have provided a tool for that: https://github.com/landgraf-dev/openapi-delphi-generator Well, I see now that this is the original request of this topic. 😅 So there you go folks, hope it's useful. It works with Swagger v2 and OpenAPI 3.0.x specifications. Share this post Link to post
David Schwartz 409 Posted January 24, 2023 8 hours ago, Wagner Landgraf said: Well, I see now that this is the original request of this topic. 😅 So there you go folks, hope it's useful. It works with Swagger v2 and OpenAPI 3.0.x specifications. hehe, yeah, 3 years later! 🙂 I noticed that when it was released and thought ... where were you back when I need this? 🙂 1 Share this post Link to post
mvanrijnen 121 Posted January 24, 2023 I never got time to make our own generator public . I am on holiday now. But try this out as soon as I get back Share this post Link to post
Dave Nottage 484 Posted January 24, 2023 If you're after something that does both (generate the doc, and parse it), there's this: https://github.com/paolo-rossi/OpenAPI-Delphi 1 Share this post Link to post
Lars Fosdal 1709 Posted January 24, 2023 That looks very promising, @Wagner Landgraf! I already have the code I need for pulling live specs and accessing the APIs. How deeply tied are the TMS Biz classes? Is the loaded Swagger/OpenAPI document class suitable for "plugging in" a custom class generator? I already have a set of framework classes that I want to create code for. Share this post Link to post
Wagner Landgraf 43 Posted January 24, 2023 1 hour ago, Lars Fosdal said: How deeply tied are the TMS Biz classes? It's only used to compile the generator executable. Anyone can compile, teste and contribute to code with the trial version. The compiled executable is provided so you don't need TMS BIZ to use it. The generated client code doesn't require TMS BIZ and works in both Delphi (XE8 and up) and Lazarus. About the custom generator, there are events in the code that you can use to intercept and modify the code generation. The OpenAPI parser can also be used separately, of course. Share this post Link to post
Lars Fosdal 1709 Posted January 24, 2023 9 minutes ago, Wagner Landgraf said: The OpenAPI parser can also be used separately, of course. Quote OpenAPI.Classes, OpenAPI.Classes.Path, OpenAPI.Classes.Operation, OpenAPI.Classes.Parameter, OpenApi.Document, OpenAPI.Types, Is that built on TMS Biz? Share this post Link to post
Wagner Landgraf 43 Posted January 25, 2023 On 1/24/2023 at 6:05 AM, Lars Fosdal said: Is that built on TMS Biz? Yes. Share this post Link to post