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

Incorrect validation occuring due to property using "enum" as a property name #490

Open
briangleeson opened this issue Sep 8, 2022 · 5 comments
Labels
bug Something isn't working spectral Waiting for fix to be released in Spectral

Comments

@briangleeson
Copy link
Member

Version: [email protected]

The validator comes back with a warning for the content of some of our example responses:

 Message :   Enum value "option1" must be "single_select".                                                                                                
 Path    :   paths./tekton_pipelines/{pipeline_id}/properties.post.requestBody.content.application/json.examples.single_select_env_properties.value.enum.0
 Line    :   1119                                                                                                                                         

This is arising in 9 places in our API yaml. The full yaml file can be seen here

This is one example:

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PropertyPrototype'
            examples:
              single_select_env_properties:
                value:
                  name: "enums"
                  type: "single_select"
                  enum: ["option1","option2","option3"]
                  value: "option1"

Schema for the enum:

enum:
          description: Options for `single_select` property type
          type: array
          minItems: 0
          maxItems: 1024
          items:
            $ref: '#/components/schemas/GeneralString'

It seems like the fact we are using the term enum for one of the properties in our API schema is confusing the validator

@rmkeezer rmkeezer added the bug Something isn't working label Nov 30, 2022
@padamstx
Copy link
Member

@briangleeson Do you still see this problem in the latest version of the validator?

@briangleeson
Copy link
Member Author

@padamstx I just tried with latest version and still see the same warnings

$ openapi-sdkgen.sh version
3.76.0-ad3e6f96-20230724-172814

@dpopp07
Copy link
Member

dpopp07 commented Jul 27, 2023

@briangleeson Looks like you posted the SDK Generator version 🙂 but I imagine you meant you tried with the latest validator version?

@briangleeson
Copy link
Member Author

Oops yeah got the tools mixed up, but same problem with latest validator

$ npm ls -g ibm-openapi-validator
C:\Users\I72022754\AppData\Roaming\npm
└── [email protected]

$ npm run openapi lint
> bash ./scripts/terraform/openapi.sh "lint"

Lint openapi.yaml
IBM OpenAPI Validator (validator: 1.1.2; ruleset: 1.1.1), @Copyright IBM Corporation 2017, 2023.

Validation Results for ./tekton/controllers/spec/v2/openapi.yaml:

Summary:

  Total number of errors   : 0
  Total number of warnings : 9

  Warnings:
   3  (30%) : Enum value "option1" must be "single_select".
   3  (30%) : Enum value "option2" must be "single_select".
   3  (30%) : Enum value "option3" must be "single_select".

Complete

@dpopp07
Copy link
Member

dpopp07 commented Jul 28, 2023

@briangleeson I was able to reproduce but identified this issue is coming from a Spectral rule called typed-enum, which we did not implement and don't maintain. I'd recommend opening an issue against their project here or seeing if there's anything obviously wrong with their implementation here if you're interested in opening a PR.

@dpopp07 dpopp07 added the spectral Waiting for fix to be released in Spectral label Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working spectral Waiting for fix to be released in Spectral
Projects
None yet
Development

No branches or pull requests

4 participants