question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add values to an existing enum in an array

See original GitHub issue

Hello,

I’m new at OpenAPI. I have an object with 2 versions, and a base enum containing Cat, Dog and Rabbit. base.yaml:

pet:
  type: string
  enum:
    - Cat
    - Dog
    - Rabbit

In v1(v1.yaml) object, I import the base enum in an array as following:

pets:
          xml:
            name: pets
            wrapped: true
          properties:
            pet:
              allOf:
                - $ref: './base.yaml#/components/schemas/pet'

In v2 object (v2.yaml file), I want to add some values to the base enum : Horse and Parrot. I’m doing as following:

pets:
   xml:
     name: pets
     wrapped: true
        properties:
          pet:
            allOf:
              - $ref: './v1.yaml#/components/schemas/pets/properties/pet'
              - $ref: './v2.yaml#/components/schemas/pet'
pet:
  type: string
  enum:
    - Horse
    - Parrot

I encounter a problem: alone, v1 works fine. When I add the v2 object to be able to switch version, the pet list of version 1 takes the values of version 2.

How can I have v1 values for v1 object and v2 values for v2 object instead of having v2 values for v1 and v2 objects?

Thank you by advance

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hkosovacommented, Apr 18, 2018

I think you need oneOf or anyOf (not allOf) to combine the enums.

0reactions
handrewscommented, Feb 11, 2020

Answered over a year ago, no further discussion, closing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding a new value to an existing ENUM Type - Stack Overflow
PostgreSQL 9.1 introduces ability to ALTER Enum types: ALTER TYPE enum_type ADD VALUE 'new_value'; -- appends to list ALTER TYPE enum_type ...
Read more >
Updating Enum Values in PostgreSQL - The Safe and Easy Way
PSQL provides an easy way to add new values to an enum: ALTER TYPE name ADD VALUE ... . Version 10 introduced an...
Read more >
Extending Enums in Java - Baeldung
In this tutorial, we'll discuss extending enums in Java, including adding new constant values and new functionalities.
Read more >
More enum modification - Jazz.net
I have a seperate script that checks the value of the text attribute and modifies the enum accordingly - removes a "cp "...
Read more >
Define Enum Fields and Suggested Values in the UI
Select Enums and Suggested Values, then select Suggested Values to make additional controls appear. From here, select Add row to start adding ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found