zenstackhq / zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
2.07k stars 89 forks source link

Openapi model id is always String #842

Open ivi3 opened 10 months ago

ivi3 commented 10 months ago

Hello Yiming. I appreciate for this great project. I have been working on a project and generated Openapi from my .zmodel using zenstack/openapi generator, but I have a problem in Openapi which is Id fields in each components that considered always string and that is different of real response from server, I read your Openapi plugin and figure out this line, can you tell me what is the reason of it? https://github.com/zenstackhq/zenstack/blob/b5929d88a2da200d1dfed00b2148a150801cf371/packages/plugins/openapi/src/rest-generator.ts#L891C41-L891C47

ymc9 commented 10 months ago

Hi @ivi3 , good catch! I think the reason is JSON:API spec requires the id field always to be a string. But it's bad to be inconsistent with the server behavior. I think we should fix the spec generation and afford a bit of inconsistency with JSON:API.

Let me know if you'd be interested in submitting a PR, and I'll be happy to facilitate a fix if you want to 😄.