Jump to content
David Schwartz

swagger help needed

Recommended Posts

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

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
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
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? 🙂

 

  • Haha 1

Share this post


Link to post

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

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
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×