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

Adding values to enum triggers MIS-E002 #37

Open
tzachshabtay opened this issue Mar 17, 2021 · 2 comments
Open

Adding values to enum triggers MIS-E002 #37

tzachshabtay opened this issue Mar 17, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@tzachshabtay
Copy link

tzachshabtay commented Mar 17, 2021

Describe the bug
We added values to an enum in a response. We disabled rule RES-E003 to allow that, however it still triggers MIS-E002.

To Reproduce
Please provide information about:

  1. Initial Swagger Spec (old version)
/my_endpoint:
   get:
      ...
      responses:
         '400':
              description: Bad Request
              schema:
                  $ref: '#/definitions/Error'

definitions:
  Error:
    type: object
    required:
      - type
    properties:
      type:
        type: string
        enum:
          - error1
          - error2
  1. Modified Swagger Spec (new version)
/my_endpoint:
   get:
      ...
      responses:
         '400':
              description: Bad Request
              schema:
                  $ref: '#/definitions/Error'

definitions:
  Error:
    type: object
    required:
      - type
    properties:
      type:
        type: string
        enum:
          - error1
          - error2
          - error3
  1. Executed command
    swagger_spec_compatibility run old.yaml new.yaml -b RES-E003

the output:

[MIS-E002] Changed type: #/paths//my_endpoint/get/responses/400/schema/properties (documentation: https://swagger-spec-compatibility.readthedocs.io/en/latest/rules/MIS-E002.html)

Note: Please provide a minimal case of spec as it helps more in identifying the issue and fixing it.

Expected behavior
I expected the compability check to pass as rule RES-E003 is disabled.

Platform:

  • OS: Linux
  • Python interpreter: Python 3.8.7 (default, Jan 12 2021, 17:16:32) [GCC 8.3.0]
  • Library Version:
Name: swagger-spec-compatibility
Version: 1.2.3
Summary: Python library to check Swagger Spec backward compatibility
Home-page: https://github.com/Yelp/swagger-spec-compatibility
Author: Yelp, Inc.
Author-email: [email protected]
License: Copyright Yelp, Inc. 2018
Location: /usr/local/lib/python3.8/site-packages
Requires: termcolor, six, bravado-core, swagger-spec-validator, typing-extensions, bravado, venusian
Required-by:
@tzachshabtay tzachshabtay added the bug Something isn't working label Mar 17, 2021
@macisamuele
Copy link
Collaborator

@tzachshabtay thanks for reporting.

The tool implementation does treat rules independently, the fact that you disable RES-E003 (Added Enum value in Response contract) does not disable MIS-E002 (Changed type).

The changes that you are making on the specs are altering

  • the object per se (regardless on where it is used)
  • the response contract of an endpoint

and due to this the 2 rules are actually triggered.

@tzachshabtay
Copy link
Author

@macisamuele thanks, yeah I figured that's the reason why it's happening, but then what's the point of having a separate rule for the enum if you can't disable it?

We want to be able to add values for an enum, but fail on field type changes.

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