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

[OAS 3.1.0] New restrictions on ServerVariable.enum #593

Closed
Azquelt opened this issue Jan 19, 2024 · 4 comments · Fixed by #614
Closed

[OAS 3.1.0] New restrictions on ServerVariable.enum #593

Azquelt opened this issue Jan 19, 2024 · 4 comments · Fixed by #614
Assignees
Labels
OAS 3.1.0 All issues related to OpenAPI version 3.1.0 support

Comments

@Azquelt
Copy link
Member

Azquelt commented Jan 19, 2024

Two new restrictions are added to ServerVariable.enum:

  • If enum is defined it may not be empty
  • If enum is defined then the value set for default must be found within enum

We should

  • Check that we don't have any tests which violate this constraint
  • Update our documentation if necessary
@Azquelt Azquelt added the OAS 3.1.0 All issues related to OpenAPI version 3.1.0 support label Jan 19, 2024
@Azquelt Azquelt added this to the MP OpenAPI 4.0 milestone Jan 19, 2024
@benjamin-confino
Copy link
Contributor

tck/src/main/java/org/eclipse/microprofile/openapi/tck/ModelConstructionTest.java

This test modifies the enum list, but never sets a default so the ServerVariable will be in an illegal state.

(It also raises the question of intermediate values. If you want to remove the defualt from the enum, add a new value, snd set the new value to the default. Is it required to ensure the default is in the enum at every step of the process?)

The following tests use ServerVariable in line with the rule

tck/src/main/java/org/eclipse/microprofile/openapi/apps/airlines/JAXRSApp.java - enumeration is unset.

tck/src/main/java/org/eclipse/microprofile/openapi/apps/airlines/resources/ReviewResource.java - enumeration is set, default is set and in the enumeration.

tck/src/main/java/org/eclipse/microprofile/openapi/reader/MyOASModelReaderImpl.java - enumeration is set, default is set and in the enumeration.

The following files only mention ServerVariable

api/src/main/java/org/eclipse/microprofile/openapi/models/servers/Server.java
api/src/main/java/org/eclipse/microprofile/openapi/models/servers/ServerVariable.java
api/src/main/java/org/eclipse/microprofile/openapi/models/servers/package-info.java
api/src/main/java/org/eclipse/microprofile/openapi/OASFactory.java
api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/Server.java
api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/ServerVariable.java
api/src/main/java/org/eclipse/microprofile/openapi/annotations/servers/package-info.java

@Azquelt
Copy link
Member Author

Azquelt commented Apr 30, 2024

(It also raises the question of intermediate values. If you want to remove the defualt from the enum, add a new value, snd set the new value to the default. Is it required to ensure the default is in the enum at every step of the process?)

No, I don't think this is required, the object being in an invalid intermediate state is fine.

@benjamin-confino
Copy link
Contributor

I spoke with Andrew yesterday and learned that we do not add TCK tests for illegal states. Given that, and the results of my audit above, I think this issue only needs an update to the documentation.

@Azquelt
Copy link
Member Author

Azquelt commented May 8, 2024

I think we should doc that default must be one of the values in enum if enum is set. Do this on the default field in the ServerVariable model interface and annotation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OAS 3.1.0 All issues related to OpenAPI version 3.1.0 support
Projects
None yet
2 participants