-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Description
Q&A (please complete the following information)
- OS: Windows 10
- Browser: Chrome latest
- Method of installation: dist assets
- Swagger-UI version: 3.39.0
- Swagger/OpenAPI version: OpenAPI 3.0 (I didn't check OAS2 but it may also be affected by this issue)
Content & configuration
Example Swagger/OpenAPI definition:
openapi: 3.0.3
info:
title: XML examples
version: 1.0.0
paths:
/foo:
get:
responses:
'200':
description: ok
content:
application/xml:
schema:
$ref: '#/components/schemas/MyObject'
'201':
description: ok
content:
application/xml:
schema:
$ref: '#/components/schemas/MyArray'
components:
schemas:
MyObject:
type: object
properties:
id:
type: integer
foo:
type: string
example:
id: 5
foos: value # <--- "foos" not "foo"
MyArray:
type: array
items:
type: object
properties:
id:
type: integer
foo:
type: object
properties:
bar:
type: string
example:
- id: 5
foo:
bars: value # <--- "bars" not "bar"Describe the bug you're encountering
If a schema-level example contains a property not defined in schema properties (e.g. if the property name is misspelled), then the XML example generator crashes.
Note: An unknown property name in examples is NOT an error. For example, schemas without additionalProperties: false allow arbitrary extra properties.
Expected behavior
XML example generator should not crash.
As for handling unknown properties, either:
- display schema-level examples as is, including unknown properties
or - ignore (exclude) unknown properties when generating XML examples
Screenshots
Additional context or thoughts
In v. 3.35.2, XML example generator didn't crash, it ignored unknown properties.
