-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add pet store examples to the samples repo #135
Comments
Sure, I'll get to it. |
Further to this issue, here's the cli command I've been trying to use (but with no luck / errors out):
and this throws an error: (one of the two schema instances is a |
@PureKrome Thanks for reporting this and trying to generate the pet store samples. |
@PureKrome, are you still working on this or should we let @wcontayon take a stab at this? Note: it'll probably be better to wait for #204 to be merged before taking this on. |
Happy to wait and/or let @wcontayon take it - i've still tried and haven't had too much luck yet. |
Thanks for the lightspeed answer! Did you run into any additional issue? If so, can you report them as new issues so we can tackle them please? |
I thought the latest code pull .. didn't work? i think the generated code was requiring nuget packages that didn't exist? |
You should be able to get the packages by configuring the package manager to use the github package feed. Which language are you targeting at the moment? |
C# / .NET Core. Yep - I just haven't done the Github PAT yet. Feels like a frustrating (temp) barrier to entry. But I'll give it a go! |
I'm going to assign this to you for now, to avoid having multiple people working on the same thing. If you feel like you don't have time or or don't want to do it anymore, just let me know. Thanks for the help! |
Status Update:
Thoughts:
UpdateThe |
Hey @PureKrome |
no because this file type is only included because of the schema of the "multipart/form-data" request schema. And I have excluded that content type for requests with my latest PR as even if we fix the generation issue, we'll still need to add a new serializer we don't have today. |
Hey @PureKrome, |
thanks for the update, try out |
✅ Ok nice! things are working. Really appreciate the hand-holding, baby steps 😊 Alright, so I've had another play and .. I think this is starting to look good! My first thing I noticed was the ... which I then noticed, I didn't answer your last questions!! Zomg, I'm so sorry. I'm sure it's too late now because decisions have probably been made, but i'll give it a go. (if anything, you might be able to at least answer what decisions you've all made and how this can work with my thoughts)
Correct. I don't want to see -any- to clarify, it would then look like this:
This would mean:
I don't really understand what this point is saying/communicating? But I do -not- want to go against a spec, at all. Spec > everything else. That's the source of truth .. even if the "truth" hurts. Now, if the spec says the default value is false, does that mean the default is to -not- copy any unmapped key/values into this dictionary? If that is correct, can we still obfuscate this property to a field + accessor method, then? Also, where does one change this value from Could someone post an link to an example of how this looks like, with Kiota? E.g. given 'this json result from some api' ... this key/value will end up in the
Ah ok. This -definatley- needs to be in some bold, upper case, shouting text. If we (the developers) can't just use the common EDIT: to clarify the last point about native serializers, I was meaning this: see how the |
Additional Datasee the spec setting additionalProperties: false should remove that from the model. About hiding it, what would this achieve? The trade-offs being more code generated and harder discovery (arguably the intent here). We've had multiple cases in Microsoft Graph of people asking "I see property X in the http snippet, but not in the model, where is it at?", IMHO the more obvious we can make this property, the better. This way if they are debugging and inspecting the object, they might discover the property they are looking for is there instead. Default for that additionalProperties from the spec AFAIK is true (string), and the work to split it has been done since then. Serialization of modelsYes, this is a design choice, models are not intended to be serialized via native libs directly as those native libraries have a number of different limitations we've learnt the hard way in our Microsoft Graph SDK experience. Something like the following should be used instead using var writer = requestAdapter.SerializationWriterFactory.GetSerializationWriter("application/json");
writer.WriteCollectionOfObjectsValues(null, result);
using var serializedStream = writer.GetSerializedContent(); |
setting this where in my code?
Why would the http result have a property, but the model doesn't? Should Kiota generate the model with the property? Or is this because the model was generated with Kiota at .. say 1st may. and then a week later, that API was updated to return an extra property .. but of course, my model was generated a week ago and that property wasn't available then .. and still hasn't been updated. So then the developer would say: "I see property X in the http snippet/response .. but not in the model?" ... so wouldn't the developer then just re-run Kiota to generate the model(s)? I feel like I'm really missing something, here.
I guess we just need to agree to disagree. I don't want to see extra fields that aren't in the api response. It's so confusing. Just imagine all the people starting to use this and have -never- seen or heard about OpenAPi specs and AdditionalData and stuff. And then they first hit
Again, depends on which way you come at this from. Model <-> Api is 1:1 match .. versus .. model is behind/out of date with Api.
No probs. This needs to be shouted out from the roof-tops and with an example of why. I would have thought a lot of POCO's generated from an API would be pretty .. simple/basic. Again, I've not used MS Graph. So then the common json libraries can do a fine job. But if you're saying the generated POCO's that represent the API results are complex, which break stuff .. then yeah .. would be kewl to see some examples so we go 'a-ha.. gotcha'. |
It leaves in the OpenAPI description, you'd have to work on your own copy of pet store.
It's both to support new properties showing up in the API without having to re-generate/update the client and also to support other underlying protocols that do not necessarily describe the payload in its entirety because it varies on the context. A common example of that are OData annotations (
No worries, I just wanted to be transparent on the fact this is something that's not likely to change and that you have control over it by tweaking the OpenAPI description.
Agreed, we're still figuring out where the kiota docs should go once we release. For now we have this on serialization, which leaves here. Would you mind sending up a pull request to add a paragraph about that? |
AH! kewl. ok .. so is there any way I could manually say during generation (using kiota.exe, etc) to not generate |
Yes, that could be easily done. In case you want to send a pull request our way, we'd be delighted to get it merged :)
|
Kewl! i'll create a new issue about having the ability to force |
Hi @baywet 👋🏻 I have a local branch with sme of my custom code, adding in the CLI option. ✔️ Problem is, I'm trying to compile against To make sure it's not -my- custom code causing this, I tried just downloading the latest code (as a zip) from GitHub and then building that (
Are you finding that the current code in the Kiota project compiles fine .. but using that |
Hi @PureKrome, |
Thanks @baywet! |
Hey @PureKrome 👋 |
Absolutely! i'll get onto it this weekend 👍🏻 |
@baywet 👋🏻 G'day! Okay, so I've created this DRAFT PR over in the samples repo. It's dotnet only :( I've actually done none of the other langs. I started with the golang tonight and sorta got stuck on the first bit of code trying to create an instance of the anon authenticate request. So - I have some questions and what to see your thoughts: Do you need me to do the golang/java/all-the-langs? (i don't have a mac, though) Or can I just keep on going and try and ask some lang-specific questions here? (I think i'll get more ❤️ here than StackOverflow where I'll either get abused for 'no-homework-questions-here' or that I'll get downvoted for who-knows-what. Also, with my current PR, I also tried to do an example where I hit this Swagger Petstore endpoint:
but I have no idea how to do this with the generated SDK? It's like ... it didn't work? (compiled, but no result). (and the console.writeline output) So I'm sorta confused :( EDIT/UPDATE: Oh! I also forgot to ask this question, also: Why does the generator automatically include XXXX when the class isn't using it? This means I need to either:
|
Thanks for the update, and the continuous work on this. Which languagesDotnet and TypeScript would be enough. Go and Java better. PHP and Python great additions. I'm not expecting swift/ruby as these languages are very early in their development. I'm not expecting CLI because the content is really similar to dotnet. Pet store inventoryThe description doesn't say much besides it'll return an object which supports additional data. So I'd expect you'll find the additional data in the additional data manager. (well, if you didn't disable it during generation). DependenciesI'm not sure why the IDE is reporting this one as unused since, it's actually being used https://github.com/microsoft/kiota-samples/pull/993/files#diff-e7516bc6ca3b86ee17272ffd8e5cbc7ccb1ee91b8815b2c2825d02ee4e720568R43 |
Thanks @baywet
I'll def start with that as a minimum.
oh ... the Yep - was that :( damn. but okay! it's working as intended then.
Ah good point! It was 'hidden' so I didn't see that. Is it needed, though? Like, sure I can remove it manually but is there any reason to have it there? Can the code know, by the |
Right now this is de-corelated to give people control through the serializer and deserializer options The generator doesn't know that "this serializer handles Json" so it doesn't use that option to select which mime type it's looking at. And in the other way around the generator doesn't use the mime types to select which serializers it's going to include. You have to provide those manually. Additionally, you also have an option to instruct the generator which mime types to consider "structured" (and generate models for) and which ones to just map to stream. |
correct, you'd have to do 3 things actually:
The source of the page is here if you want to correct it. https://github.com/microsoft/kiota/blob/main/docs/using.md |
AB#9120
The text was updated successfully, but these errors were encountered: