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

content Type XML and example not property handle #2523

Open
LasneF opened this issue Aug 8, 2023 · 1 comment
Open

content Type XML and example not property handle #2523

LasneF opened this issue Aug 8, 2023 · 1 comment
Labels
t/bug Something isn't working triaged

Comments

@LasneF
Copy link

LasneF commented Aug 8, 2023

Describe the bug
give an API Spec with a return content type set to application/xml spectral raise an error stating that example must be an object

notice that the file looks correct , and is correctly rendered by editor.swagger.io

To Reproduce
given the API spec below

{
    "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": "boolean"
                    }
                },
                "xml": {
                    "name": "Cat"
                }
            }
        }
    }
}

Error below is raised
18:44 error oas3-valid-media-example "example" property type must be object paths./pet.get.responses[200].content.application/xml.example

Expected behavior
No Error raised ,

@mnaumanali94 mnaumanali94 added the t/bug Something isn't working label Nov 29, 2023
@philsturgeon
Copy link
Contributor

Also having this problem with examples and a value that's a string.

    responses:
        '201':
          description: Booking successful
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Booking'
                  - properties:
                      links:
                        $ref: '#/components/schemas/Links-Self'

              examples:
                new_booking:
                  summary: New Booking
                  value: |-
                    {
                      "id": "{{ uuid() }}",
                      "trip_id": "{{ request.body/trip_id }}",
                      "passenger_name": "{{ request.body/passenger_name }}",
                      "has_bicycle": {{ request.body/has_bicycle }},
                      "has_dog": {{ request.body/has_dog }},
                      "links": {
                        "self": "https://api.example.com/bookings/1725ff48-ab45-4bb5-9d02-88745177dedb"
                      }
                    }

This is allowed by the spec, and its eneded for using Microcks mocking tool, but I get this error:

  370:26        error  oas3-valid-media-example                       "value" property type must be object

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

No branches or pull requests

3 participants