-
Notifications
You must be signed in to change notification settings - Fork 194
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
Incorrect translation of float data type #1721
Comments
Hi @softworkz The mapping of primitive types in Kiota is here kiota/src/Kiota.Builder/KiotaBuilder.cs Line 594 in b12abea
And the unit tests for it there
I suspect what's throwing kiota off balance is the fact that the number is also marked as nullable. Kiota always defaults scalar properties to their nullable equivalent (as you can see with max height in your screenshot), this is a design decision that was made because properties can be selected or not (get, with $select in odata for example) or rely on service side defined defaults (post). In effect having a nullable scalar in the description doesn't "add" any value for kiota. Just for the purpose of the investigation, can you edit your description to remove nullable, and see what results you get please? |
For a similar reason, we have most types defined as nullable.
MaxHeight is nullable already in the definition: so it probably can't be an issue with nullable. |
Ah I missed the fact we were talking about query parameters. kiota/src/Kiota.Builder/KiotaBuilder.cs Line 1184 in b12abea
This should be an easy fix:
Is this something you'd be willing to submit a pull request for? |
Why isn't there a single function that does this? |
I'd be open to introducing the following method private static void SetCollectionInformation(CodeTypeBase target, OpenApiSchema schema, CodeTypeBase.CodeTypeCollectionKind collectionKind = CodeTypeBase.CodeTypeCollectionKind.Array) {
target.CollectionKind = schema.IsArray() ? collectionKind : default;
} I didn't suggest that originally because I didn't want the refactoring burden to fall on you. |
I'm afraid, but I can't do that because I figured that there are too many things that I don't understand or don't make sense to me. var typeNames = new List<string>{typeSchema?.Items?.Type, childType, typeSchema?.Type};
if(typeSchema?.AnyOf?.Any() ?? false)
typeNames.AddRange(typeSchema.AnyOf.Select(x => x.Type)); // double is sometimes an anyof string, number and enum
// first value that's not null, and not "object" for primitive collections, the items type matters
var typeName = typeNames.FirstOrDefault(x => !string.IsNullOrEmpty(x) && !typeNamesToSkip.Contains(x)); This looks like we just want to get "something", but how can it be so totally irrelevant from where the if (typeSchema?.Items?.Enum?.Any() ?? false)
typeName = childType;
else { What is the above meaning to do? When a schema for var format = typeSchema?.Format ?? typeSchema?.Items?.Format; Above, we're already taking the Also, the format value can have a meaning when it's empty (not specified). We just can't take it from elsewhere because it's empty. |
no worries, I'll take it on when I have some time. |
Sure. Thank you very much! |
We're going to keep this one open since it's an actual issue with the generator that eventually needs to be addressed. |
Yea, sorry, closing was a bit egoistic. |
Submitted #1723 , which will close this issue when merged |
This is in the OpenApi v3 doc:
And this is what is getting generated:
And that's what the OpenApi spec says:
The text was updated successfully, but these errors were encountered: