Skip to content
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

Question: is the spec compatible with OpenAPI? #31

Open
AF-cgi opened this issue Nov 23, 2024 · 8 comments
Open

Question: is the spec compatible with OpenAPI? #31

AF-cgi opened this issue Nov 23, 2024 · 8 comments

Comments

@AF-cgi
Copy link

AF-cgi commented Nov 23, 2024

I figured out that the current openapi.yaml file hasn't a valid Open API spec. Is this correct? This will be hard to use some code generation tools to build a network layer based on your specs.

@grace-figma
Copy link
Contributor

Hi, do you have additional details? openapi.yaml should be valid Open API, and looks valid to me.

@nfirex
Copy link

nfirex commented Dec 19, 2024

@grace-figma
Hello!

Do you have any good client generators for kotlin?

I tried this one:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-gradle-plugin/README.adoc

And online swagger:
https://editor-next.swagger.io/

But they both generates invalid retrofit clients:
For example - method getMe() from User Api returns nothing:
image

@AF-cgi
Copy link
Author

AF-cgi commented Dec 19, 2024

@grace-figma Hello!

Do you have any good client generators for kotlin?

I tried that one: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-gradle-plugin/README.adoc

And online swagger: https://editor-next.swagger.io/

But they both generates invalid retrofit clients: For example - method getMe() from User Api return nothing: image

That was also my issue. I will try the Swagger Codegen, because the Swagger UI is the only tool that returns valid for the current specification.

@nfirex
Copy link

nfirex commented Dec 19, 2024

Some new info.

I tried manually change schema and build minor parts. And faced with parsing errors. That means that a lot of fields checked as required, but API don't return it:
Exception in thread "main" com.squareup.moshi.JsonDataException: Required value 'shapeType' missing at $.document.children[0].children[1] at com.squareup.moshi.internal.Util.missingProperty(Util.java:660) at com.squareup.moshi.kotlin.reflect.KotlinJsonAdapter.fromJson(KotlinJsonAdapter.kt:105) at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41) at com.squareup.moshi.CollectionJsonAdapter.fromJson(CollectionJsonAdapter.java:81) at com.squareup.moshi.CollectionJsonAdapter$2.fromJson(CollectionJsonAdapter.java:55) at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41) at com.squareup.moshi.kotlin.reflect.KotlinJsonAdapter.fromJson(KotlinJsonAdapter.kt:86) at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41) at com.squareup.moshi.CollectionJsonAdapter.fromJson(CollectionJsonAdapter.java:81) at com.squareup.moshi.CollectionJsonAdapter$2.fromJson(CollectionJsonAdapter.java:55) at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41) at com.squareup.moshi.kotlin.reflect.KotlinJsonAdapter.fromJson(KotlinJsonAdapter.kt:86) at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41) at com.squareup.moshi.kotlin.reflect.KotlinJsonAdapter.fromJson(KotlinJsonAdapter.kt:86) at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41) at com.squareup.moshi.JsonAdapter.fromJson(JsonAdapter.java:70)

@nfirex
Copy link

nfirex commented Dec 19, 2024

Exception in thread "main" com.squareup.moshi.JsonDataException: Required value 'shapeType' missing at $.document.children[0].children[1] at

response:

{
"document": {
"id": "0:0",
"name": "Document",
"type": "DOCUMENT",
"scrollBehavior": "SCROLLS",
"children": [
{
"id": "0:1",
"name": "Page 1",
"type": "CANVAS",
"scrollBehavior": "SCROLLS",
"children": [
{
"id": "2:2",
"name": "Rectangle 1",
"type": "RECTANGLE",
"scrollBehavior": "SCROLLS",
"blendMode": "PASS_THROUGH",
"fills": [
{
"blendMode": "NORMAL",
"type": "SOLID",
"color": {
"r": 0.8509804010391235,
"g": 0.8509804010391235,
"b": 0.8509804010391235,
"a": 1
}
}
],
"strokes": [],
"strokeWeight": 1,
"strokeAlign": "INSIDE",
"absoluteBoundingBox": {
"x": -364,
"y": 38,
"width": 441,
"height": 268
},
"absoluteRenderBounds": {
"x": -364,
"y": 38,
"width": 441,
"height": 268
},
"constraints": {
"vertical": "TOP",
"horizontal": "LEFT"
},
"effects": [],
"interactions": []
}
],
"backgroundColor": {
"r": 0.9607843160629272,
"g": 0.9607843160629272,
"b": 0.9607843160629272,
"a": 1
},
"prototypeStartNodeID": null,
"flowStartingPoints": [],
"prototypeDevice": {
"type": "NONE",
"rotation": "NONE"
}
}
]
},
"components": {},
"componentSets": {},
"schemaVersion": 0,
"styles": {},
"name": "Untitled",
"lastModified": "2024-12-19T17:57:46Z",
"thumbnailUrl": "https://s3-alpha.figma.com/thumbnails/0fb2e4ba-61c5-480a-b913-8e54fe2f2abd?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAQ4GOSFWCZ5JER5WN%2F20241219%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20241219T000000Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=2dd35ea0f8e4958ffa5732efc4d51f158d1788fa6618d1a861da54c3d0c12949",
"version": "2163888010403840939",
"role": "owner",
"editorType": "figma",
"linkAccess": "inherit"
}

@grace-figma
Copy link
Contributor

🤔 thanks for the additional info, I'll look into it

@AF-cgi
Copy link
Author

AF-cgi commented Jan 9, 2025

I get the following issue by using version 0.22.0 with swift-openapi-generator.
Bildschirmfoto 2025-01-09 um 22 38 12

@jefflee-figma
Copy link
Contributor

Thanks for the report here...we admittedly haven't done a huge amount of testing this OpenAPI spec outside of TypeScript. For what it's worth, the spec seems to validate properly in a 3.1 validator, and the openapi-typescript generates what we think is a pretty high-fidelity schema (example).

The schema does make heavy use of polymorphic types (e.g. anyOf and oneOf type descriptors), which are easily handled in TypeScript using a | type union operator. I wonder if some code generators aren't able to handle this gracefully, or if we are missing some annotation such as descriminator for facilitating that.

I think @nfirex's example about re: a missing shapeType property is a case in point: shapeType only appears in nodes of type SHAPE_WITH_TEXT. There is no SHAPE_WITH_TEXT in the example JSON, which means the generated SDK is misapplying object schemas, possibly because it doesn't know how to pick which one to use.

At any rate, we'll be looking into this, but in the mean time, we'd appreciate any advice from the community for tweaking the structure of the schema so it supports a wider range of tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants