Authress / authress-sdk.rs

The Authress SDK for Rust provides authorization as a service with fully compatible REST apis.
https://authress.io
Apache License 2.0
4 stars 0 forks source link

Generate the necessary scaffolding #1

Closed wparad closed 1 year ago

wparad commented 3 years ago
curl -XPOST https://generator3.swagger.io/api/generate -H 'content-type: application/json' -d '{"specURL" : "https://api.authress.io/.well-known/openapi.json","lang" : "rust","type" : "CLIENT","codegenVersion" : "V3"}'  --output sdk_files
akincel commented 3 years ago

Looks like the Swagger generator doesn't support Rust. However, the community version of the OpenAPI generator does work.

I need to figure out how good/bad the output is, and whether Authress uses any specs the generator doesn't support.

akincel commented 3 years ago

So far only 2 issues (and they have the same cause). There are 2 references that look a bit unusual and I'm not sure if OAS3 supports them:

"$ref": "#/components/schemas/PermissionObject/properties/action"
"$ref": "#/components/schemas/Role/properties/roleId"

Can you actually reference a property of schema instead of only referencing the containing schema?

I can work around the type in the SDK by just changing it to string but every follow-up re-generation of the SDK will need that manual intervention. Did you have this issue with SDKs generated against other languages or not at all?

I'm not sure you want that, but if OAS3 doesn't support this, a possible fix is to extract the action and roleId property into their own schemas, and then reference the schemas instead of the property.

wparad commented 3 years ago

Don't worry about the fields that don't work, the DTOs are the only things that matter, so we can add back in the fields after we generate them. I.e. download the spec, delete the two properties and run the generator. If that's challenging for any reason, we can host an alt version of the spec with the properties removed, and add them back in after the fact.

Also don't worry about regeneration, we don't really run them a second time, so at as long as the DX is good :+1:

wparad commented 3 years ago

Can you actually reference a property of schema instead of only referencing the containing schema?

It never occurred to m that this could be an issue, the ref generation use a relative path from the document root in OAS3 which is a huge change from Swagger2, one of the reasons it is this way. We can of course make a change in the spec concretely, however we can also investigate what's the error exactly, and search for the issue in OAS generator and see what happens. The swagger generator worked fine, I would almost be surprised that there is something we can't fix there.