0

This seems to me to be a common use case but I can't figure it out. What if I have some common data schema which is used all over the place but I want a different description on each one? E.g. a very simple example (mine is light-years more complicated):

components:
  schemas:
    Id:
      type: integer
      minimum: 1
      description: Resource identity (primary key)
    OnOffAuto:
      type: string
      enum:
        - on
        - off
        - auto
    Lights:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        status:
          $ref: '#/components/schemas/OnOffAuto'
>>        description: Status of the lights. Value "auto" means they turn on at night and off in the morning.
    Door:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/Id'
        status:
          $ref: '#/components/schemas/OnOffAuto'
>>        description: Status of the door. Value "auto" means it locks at night and unlocks in the morning.

Question is where to put the OnOffAuto "description" so it will have a different value each place the schema ref is used.

Also once again sure would be nice to have an openapi-3 tag... It is considerably different from version 2.

user9645
  • 6,286
  • 6
  • 29
  • 43
  • See the ^^ linked Q&A. To sum up: you need to wrap the `$ref` into `allOf. (The linked question is about OAS2, but the solution is the same for OAS2 and OAS3.) – Helen Feb 04 '19 at 12:54
  • Thanks @Helen - I was hoping that was not the answer. BTW - I do realize that you can't have any siblings to a `$ref` - it is shown that way in my example because I did not know where to put it - so I don't think it is a duplicate of the question you referenced. If you put your "allOf" solution in as an answer I will accept it. – user9645 Feb 04 '19 at 14:58
  • After thinking about it for a while I decided that the other answer did in fact answer my question even though it was asked for a different reason, so I'm marking this one duplicate. – user9645 Feb 04 '19 at 16:56

0 Answers0