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

Provide a consistent way of describing the difference between DB schema and request/response #82

Open
cebe opened this issue Feb 7, 2025 · 0 comments
Labels
under discussion Still discussing, not ready for implementation.

Comments

@cebe
Copy link
Member

cebe commented Feb 7, 2025

moved from cebe#135

For simple CRUD operations the DB schema often matches the JSON schema of the request response exactly.
However there are a lot of use cases where the schema returned by the API is very different from the API.

Example:

User:
  type: object
  properties:
    id:
      type: integer
    username:
       type: string
       maxLength: 32
    password_hash:
       type: string
       maxLength: 64

For obvious reasons we do not want to expose the password_hash on the API.

Possible solutions:

use readOnly and writeOnly (related to https://github.com/cebe/yii2-openapi/issues/4)

use sepearate Schemas for DB and API and find a way to link them together

@cebe cebe added the under discussion Still discussing, not ready for implementation. label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
under discussion Still discussing, not ready for implementation.
Projects
None yet
Development

No branches or pull requests

1 participant