Closed galvesribeiro closed 7 years ago
Anyone?
Damn, I had an answer written up the day you filed this issue, but apparently I didn't post it... sorry for that. As far as I can remember, your Swagger contains a lot of features that AutoRest just doesn't support (yet). I see:
enum
with non-string entriesdefault
with non-primitive valuedefault
(yes, AutoRest currently assumes that all explicitly modeled status codes indicate success, so you would really get an ErrorResponse
as a return value instead of throwing an exception - to model negative reponses, please follow https://github.com/Azure/azure-rest-api-specs-pr/blob/master/documentation/creating-swagger.md#negative-responses)I think there was quite some more, I can investigate further if AutoRest still won't behave.
Thanks for get back @olydis.
Do you have any idea if it may be supported in a near future? I plan to change the way other Microsoft project generate code (Microsoft/Docker.Dotnet).
Docker specs for Swagger is 100% compatible with Swagger spec.
I may help and contribute it here, but I would need some guidance as I have no clue on AutoRest codebase.
Thank you!
@galvesribeiro Great to hear those plans! Whether we support those things in a near future is hard to say, currently we have other priorities. :-/ Contributions would of course be great, however be warned: We are going through some fundamental architectural changes this month so it might be worth awaiting those to prevent the frustration of learning about stuff right before it's being changed.
@fearthecowboy any suggestions?
Wow.
This is a great swagger doc. We're going to have to use this for some test cases. This thing is full of cases that the current modeler has no ability to handle 😄
Notably:
default
values for object types -- this is something we are fixing --probably won't actually generate code for that, but at the very least, shouldn't crash.
-enum:
restriction that has an empty object. I'm not convinced that that's a really great thing to put in swagger, but for dammed sure, it's legal. 😠At the very least, we should not crash on those cases, so we'll queue them up to get fixed PDQ.
WRT the arrays of types.... we may have to hack some really dirty workaround to make that work. Possibly it to skip codegen for that and handle that case manually.
G
Yeah, I can't agree more that some stuff on Swagger spec are really dirty for us used to have type-safety and formal contracts but think that people who write that is used to untyped languages like JavaScript, so it make total sense for that to have a property that sometimes is of a type, sometimes is another.
I was about to start from scratch a generator based on YamlDotnet + Json.Net + Roslyn but I unfortunately had no time for that and the guys from Microsoft/Docker.DotNetty pointed me to AutoRest as a solution.
I hope you guys can get that sorted so we can use it soon :(
I'd highly recommend that you not try to write from scratch... AutoRest is a great example on how that's a lot more work that it looks 🗻
I'll see if we can't get fixes in to fix it pretty quick.
Yes, definitively... I did tried to start it and it take a lot of work :)
added features required for this to https://github.com/Azure/autorest/issues/2448 if they were not already there.
@olydis does it work with the swagger doc I pasted here?
no, while we're actually working on some of the features now, it probably won't work, yet. Note that #2448 is a collection of feature requests, which we created since we had countless similar/related issues and it got super hard to keep track of what people want - this issue right here is similar, things you encounter were essentially asked for before, so I just reference this issue from #2448 to make sure we review it (but also all related issues) when tackling the underlying problem.
I'm trying to use AutoRest to generate C# classes from https://docs.docker.com/engine/api/v1.26/swagger.yaml
I converted it to Json using http://editor.swagger.io and the converted file is attached (renamed to txt). swagger.txt
Can someone tell me what is wrong with it? Other tools like NSwag is able to run it perfectly.
Thank you!