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

Rules no-invalid-media-type-example does not handle OAS specifics tags for XML #1276

Open
LasneF opened this issue Sep 28, 2023 · 1 comment
Labels
governance Issues relating to problems with or requests for API governance/linting/decorating p3 Type: Enhancement

Comments

@LasneF
Copy link

LasneF commented Sep 28, 2023

Describe the bug
no-invalid-media-type-example is behaving incorrectly and raising a false positive error when using XML

OAS specify dedicated tag to handle XML around tag names rewrite , name space, and attribute. Those looks not handled by redoclint

To Reproduce
given the specification below the example is correct but redoclint raises the below error
using the minimal command line : redocly lint sample.json
Warning was generated by the no-invalid-media-type-examples rule. with Example value must conform to the schema: type must be object.

Expected behavior

The example should not raise an error , as the file is correct

Logs

[7] sample.json:18:44 at #/paths/~1pet/get/responses/200/content/application~1xml/example

Example value must conform to the schema: type must be object.

16 |             "$ref": "#/components/schemas/niceCatResult"
17 |         },
18 |         "example": "<Cat><nice>true</nice></Cat>"
19 |     }
20 | }

referenced from sample.json:14:48 at #/paths/~1pet/get/responses/200/content/application~1xml

OpenAPI description

{
    "openapi": "3.0.0",
    "info": {
        "title": "Kitten",
        "version": "1.0.0"
    },
    "paths": {
        "/pet": {
            "get": {
                "responses": {
                    "200": {
                        "description": "cat",
                        "content": {
                            "application/xml": {
                                "schema": {
                                    "$ref": "#/components/schemas/niceCatResult"
                                },
                                "example": "<Cat><nice>true</nice></Cat>"
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "niceCatResult": {
                "type": "object",
                "properties": {
                    "nice" : {
                        "type": "string"
                    }
                },
                "xml": {
                    "name": "Cat"
                }
            }
        }
    }
}

Redocly Version(s)

Using 1.0.2

@LasneF LasneF added the Type: Bug Something isn't working label Sep 28, 2023
@tatomyr
Copy link
Contributor

tatomyr commented Sep 28, 2023

Thanks for reporting @LasneF!

@tatomyr tatomyr added p3 Type: Enhancement and removed Type: Bug Something isn't working labels Sep 28, 2023
@lornajane lornajane added the governance Issues relating to problems with or requests for API governance/linting/decorating label Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
governance Issues relating to problems with or requests for API governance/linting/decorating p3 Type: Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants