Comments (7)
That or generate their own client using the openapi-generator and the spec at: https://github.com/ory/kratos/blob/master/spec/openapi.json
The 0.7 release is pretty close though: https://github.com/ory/kratos/milestone/9
from sdk.
Dupe of #74
from sdk.
Shit, I made a long post that explained the issue but apparently I closed the wrong window. Anyways, the gist of it is that polymorphism with simple types is simply extremely buggy in basically all the generators except for Golang (because I fixed it there) and TypeScript. Apparently, the generator expects polymorphism to always be a JSON object 🤷
So what I did was to remove the typing from the value (which means it can be any type) and re-generated the clients. Could you please check if this works in Java (I have no Java experience...). The generated code with the changes can be found here: https://github.com/ory/sdk/tree/openapi-fixy/clients/kratos/java
Thanks!
from sdk.
@aeneasr, thanks for the quick reply. I just quickly tested your fix and the login and registration flow responses are now deserialized correctly! Hopefully, this fix also solves the issues with the clients in other languages. Could you maybe point out what you exactly changed since db67552 contains a lot of changes in the generated files?
from sdk.
Ok that's awesome to hear! The problem is that we had a oneOf in the schema with simple types:
value:
oneOf:
- type: string
- type: number
- type: boolean
This is unfortunately not supported in most openapi-generator templates. There are quite a few issues on that (https://github.com/OpenAPITools/openapi-generator/search?q=oneof+string&type=issues - not all are relevant but maybe 10%).
What I did was basically removing that type and the leaving "value" type empty which implies that it is a polymorph type (could also be an object or array, which isn't the case actually, but better than something not working at all!)
from sdk.
Wohoo! I found the original tab with my findings
So I looked into this a bit more and I can't seem to come up with a good solution (also I don't have Java skills...). Basically the problem is this.
The value
object of node.attributes.value
is a polymorph simple type (string, bool, number, null). In OpenAPI Spec we use a ref and oneOf
to express that:
"value": {
"$ref": "#/components/schemas/uiNodeInputAttributesValue"
}
"uiNodeInputAttributesValue": {
"oneOf": [
{
"description": "The input's value.",
"nullable": true,
"type": "string"
},
{
"description": "The input's value.",
"nullable": true,
"type": "number"
},
{
"description": "The input's value.",
"nullable": true,
"type": "boolean"
}
]
},
Unfortunately we cannot do
"value": {
"oneOf": [
{
"description": "The input's value.",
"nullable": true,
"type": "string"
},
{
"description": "The input's value.",
"nullable": true,
"type": "number"
},
{
"description": "The input's value.",
"nullable": true,
"type": "boolean"
}
]
}
as that generates code in Java which would not compile due to a bug in openapi-generator. The interim step with the $ref
appears to trick the Java generator into thinking that the element under value
is an object while it really is a string, a number, or a boolean. This then causes the deserialization issue!
In Java, the value
type is:
public static final String SERIALIZED_NAME_VALUE = "value";
@SerializedName(SERIALIZED_NAME_VALUE)
private UiNodeInputAttributesValue value;
with a simple class
public class UiNodeInputAttributesValue {
backing it. UiNodeInputAttributesValue
itself is basically seen as a dumb object instead of polymorphism. After digging through some issues, this appears to be a general problem / limitation of openapi-generator for several languages right now:
- OpenAPITools/openapi-generator#8457
- OpenAPITools/openapi-generator#15
- ... and a couple more
So in the end I think it's better to just not have any typing here even though the typing appears to be correct.
from sdk.
@aeneasr thanks for the clarifying what is happening. Just so I understand, currently the best option for any user that's not using Golang nor Typescript is to wait for next release?
For the time being, I use db67552 directly, just thinking that maybe users need to be informed about it.
from sdk.
Related Issues (20)
- BC breaks: fields in the SDK changed (e.g. FrontendApi > FrontendAPI; IdentityApi > IdentityAPI) HOT 5
- ory client-go 1.6.1: cannot deserialize continue_with response HOT 3
- [Rust] update_registration_flow error handling HOT 1
- Getting error in the response of "createNativeRegistrationFlow" API : Social Sign In and OpenID Connect are only supported for flows initiated using the Browser endpoint
- .NET packages have not been updated HOT 1
- dotnet clients on nuget.com not updated since ~3 months HOT 6
- UnmarshalJSON fails for the LoginFlow type in kratos-client-go
- Elixir deps can't be compiled HOT 1
- v1.11.6 adds axios to @ory/client-fetch HOT 2
- Elixir API client deserialisation error when parsing enum values HOT 2
- Ruby generator generates invalid code due to Cookie Auth in spec HOT 1
- CI fails when trying to publish client HOT 1
- Ory client side libraries should be Tree Shakeable HOT 3
- Publish Java kratos-client 1.2 to maven central HOT 1
- upstream reference closed: github.com/gradle/gradle/issues/25036
- upstream reference closed: github.com/guzzle/psr7/pull/603
- Publish Rust crate v1.2.x
- Keto typescript fetch client HOT 2
- Publish Dart Client with Kratos v1.2.x HOT 1
- Package published to pub.dev is outdated HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk.