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 property to document "write once" on entity creation/immutability after creation for a field of an entity #2743

Open
Retro64 opened this issue Oct 11, 2021 · 0 comments

Comments

@Retro64
Copy link

Retro64 commented Oct 11, 2021

When creating an entity, sometimes initial values for a later readonly property might need to be created. Designing a schema with readonly does not work out, as it prevents writing once. Example:

/entity/{id}
  get:
    schema:
      type: object
      properties:
        virtual:
          type: boolean
          readOnly: true
        name:
          type: string
         
  put:    
    schema:
      oneOf:
        - type: object
          description: use only on create
          properties:
            virtual:
              type: boolean
              writeOnly: true
            name:
              type: string
        - type: object
          description: use only on update (on name)
          properties:
            virtual:
              type: boolean
              readOnly: true         
            name:
              type: string

The schema looks kind of redundant, as virtual should only be set on first put and become immutable afterwards. It can currently only be "solved" by adding a description when to use which schema. Is there any way to design a schema, defining properties immutable after creation?

@Retro64 Retro64 changed the title Provide property to document "write once" on entity creation, e.g. for an entity type Provide property to document "write once" on entity creation/immutability after creation for a field of a property Oct 11, 2021
@Retro64 Retro64 changed the title Provide property to document "write once" on entity creation/immutability after creation for a field of a property Provide property to document "write once" on entity creation/immutability after creation for a field of an entity Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants