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

Recent fix to indexing enums causes not all enums to be indexed #175

Closed
TristanSpeakEasy opened this issue Sep 22, 2023 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@TristanSpeakEasy
Copy link
Contributor

The change here #169 caused some of our tests to start failing as all the enums we were expecting to be in the index are no longer in the index.

For example in this spec:

openapi: 3.1.0
servers:
  - url: http://localhost:8080
paths:
  /test:
    get:
      operationId: test
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  enumRef:
                    $ref: '#/components/schemas/enum'
                  enum:
                    type: string
                    enum: [big, small]
                    nullable: true
components:
  schemas:
    enum:
      type: [string, null]
      enum: [big, small]

The enum in the component named enum is not contained within the index anymore

@TristanSpeakEasy
Copy link
Contributor Author

TristanSpeakEasy commented Sep 22, 2023

Also in this example the enum in the enum property is not found anymore

openapi: 3.1.0
servers:
  - url: http://localhost:8080
paths:
  /test:
    get:
      operationId: test
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  enum:
                    type: number
                    enum: [0.1, 0.2]

@TristanSpeakEasy
Copy link
Contributor Author

reverting to v0.10.3 fixes the issue

@daveshanley
Copy link
Member

I think this may be a case of 'unfix the bug, we need the bug'. Technically the new behavior is correct, because the property named enum is not an enum, so it should not be indexed.

However the bug that exists in v0.10.3 is something you've come to depend on.

So, I think the solution here, is the same as the circular references approach. The option to include properties named enum into the index, or ignore them (default is to ignore, which is correct in my opinion)

But you can flip a bit in the Index Config or via a method to ignore that check and revert back to the pre bugfix behavior.

Thoughts?

@TristanSpeakEasy
Copy link
Contributor Author

So I don't think we were relying on a bug.

Ie we are calling .Index.GetAllEnums() and expect that to return all enums in the spec.

The properties and components above called "enum" still contain enum schemas that we would expect to be found in the index

@daveshanley
Copy link
Member

OK, I will loop back around on this, more intelligence on deciding what is and is not an enum is needed.

@TristanSpeakEasy
Copy link
Contributor Author

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants