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

Unexpected ibm-api-symmetry warning with dictionary #699

Open
vsandonis opened this issue Nov 18, 2024 · 5 comments
Open

Unexpected ibm-api-symmetry warning with dictionary #699

vsandonis opened this issue Nov 18, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@vsandonis
Copy link
Member

I am getting validation warning ibm-api-symmetry with an openapi spec that includes a dictionary following https://swagger.io/docs/specification/v3_0/data-models/dictionaries/ :

$ lint-openapi error_example.yaml --log-level ibm-api-symmetry=info
IBM OpenAPI Validator (validator: 1.20.0), @Copyright IBM Corporation 2017, 2024.

Validation Results for error_example.yaml:

[INFO] ibm-api-symmetry: checking variant schema DevicePrototype against canonical schema Device
[INFO] ibm-api-symmetry: schema defines 'additionalProperties' - it is not a proper graph fragment
[INFO] ibm-api-symmetry: nested object property input_parameters is not a graph fragment of canonical property input_parameters
[INFO] ibm-api-symmetry: nested object property device_config is not a graph fragment of canonical property device_config
[INFO] ibm-api-symmetry: nested object property details is not a graph fragment of canonical property details
[INFO] ibm-api-symmetry: variant schema DevicePrototype is not a graph fragment of canonical schema Device
Warnings:

  Message :   Variant schema should be a graph fragment of the canonical schema
  Rule    :   ibm-api-symmetry
  Path    :   components.schemas.DevicePrototype
  Line    :   120

Summary:

  Total number of errors   : 0
  Total number of warnings : 1

  Warnings:
   1 (100%) : Variant schema should be a graph fragment of the canonical schema

I am using this version: validator: 1.20.0; ruleset: 1.19.0 (default)

Here is the yaml file that generates the warning: error_example.txt

Is this a legitimate warning?

I guess it is not because if I define input_parameters in DeviceConfiguration as a string instead of a dictionary, no warning is generated, so I guess it has to do with the dictionary definition. In addition, if I comment the path /devices/{device_id} (lines 14 to 36 in the file) no warning is generated either.

Is there anyway to skip the validation for this input_parameters?

Thanks for your help.

@vsandonis
Copy link
Member Author

vsandonis commented Nov 18, 2024

Taking a look to the code in here, it seems that if the variant defines additionalProperties it is not considered a graph fragment.

@dpopp07
Copy link
Member

dpopp07 commented Nov 18, 2024

Taking a look to the code in here, it seems that if the variant defines additionalProperties it not considered a graph fragment.

That's correct - if the variant schema is a dictionary, it may contain properties that are not (or even cannot) be represented on the canonical schema, which would violate the graph fragment pattern.

@vsandonis
Copy link
Member Author

That's correct - if the variant schema is a dictionary, it may contain properties that are not (or even cannot) be represented on the canonical schema, which would violate the graph fragment pattern.

Thanks for the answer. Does it mean that the use of dictionaries is not allowed in variant schemas?

@dpopp07
Copy link
Member

dpopp07 commented Nov 18, 2024

Does it mean that the use of dictionaries is not allowed in variant schemas?

Upon looking at your API in more detail, I actually think that this case may be allowed since the two schemas are using the same dictionary property. I will go over the code and confirm whether or not this is intended behavior or a bug. Thanks for opening the issue.

@dpopp07
Copy link
Member

dpopp07 commented Nov 19, 2024

@vsandonis after review, this should not be a warning. I'll mark this as a bug and will update the code soon.

@dpopp07 dpopp07 added the bug Something isn't working label Nov 19, 2024
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