Switching between examples does not render the changed Example Value and Schema it keeps the request schema
Q&A (please complete the following information)
- OS: Kubuntu 22.04 LTS
- Browser: Chrome, Vivaldi
- Version: 125.0.6422.141
- Method of installation: none "https://editor-next.swagger.io/ and https://editor.swagger.io/"
- Swagger-Editor version: 5.0 Alpha 96 and current stable
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Example Swagger/OpenAPI definition:
openapi: 3.0.0
info:
title: 'API'
description: '!'
contact:
email: [email protected]
version: 1.0.0
paths:
/api/kundencenter/set:
post:
tags:
- kundencenter
description: 'An endpoint'
operationId: ApiKundencenterSet
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/insertData'
examples:
'insert customer':
$ref: '#/components/schemas/insertData'
'update customer':
$ref: '#/components/schemas/updateData'
responses:
'200':
description: 'The data'
'400':
description: 'The data'
'401':
description: Unauthorized
security:
-
bearerAuth: []
components:
schemas:
Angebot:
title: 'Angebot model'
description: 'Angebot model'
properties:
ident:
title: ident
description: ident
type: string
format: string
default: angebot
maxLength: 64
title:
title: Titel
description: Titel
type: string
format: string
default: test
maxLength: 64
sparte:
title: sparte
description: sparte
type: string
format: string
default: PHV
maxLength: 64
json:
title: json
description: json
type: object
format: object
type: object
Kunde:
title: 'Kunde model'
description: 'Kunde model'
properties:
Anrede_k:
title: Anrede
description: Anrede
type: string
enum:
- Herr
- Frau
- Firma
- WEG
type: object
KundeUpdate:
title: 'KundeUpdate model'
description: 'KundeUpdate model'
type: object
allOf:
-
$ref: '#/components/schemas/Kunde'
-
properties:
pk_k:
title: pk_k
description: pk_k
type: integer
format: int64
default: '12345'
type: object
insertData:
title: 'kundencenter insertData'
description: 'kundencenter insertData'
properties:
Kunde:
$ref: '#/components/schemas/Kunde'
Angebot:
$ref: '#/components/schemas/Angebot'
type: object
updateData:
title: 'kundencenter updateData'
description: 'kundencenter updateData'
properties:
Kunde:
$ref: '#/components/schemas/KundeUpdate'
Angebot:
$ref: '#/components/schemas/Angebot'
type: object
securitySchemes:
bearerAuth:
type: http
scheme: bearer
security:
-
bearerAuth: []
Swagger-Editor configuration options: https://editor-next.swagger.io/ or https://editor.swagger.io/
Describe the bug you're encountering
The editor should switch between the different examples and schemas which where referenced. Instead, the editor always shows the referenced schema of the request.
To reproduce...
Steps to reproduce the behavior:
- open https://editor-next.swagger.io/
- paste the yaml
- expand the POST request
- switch between the examples
Example Value and Schema are not changing.
Expected behavior
If I select the example "update customer", Example Value should add the required property "pk_k" and the schema should change from "kundencenter insertData" to "kundencenter updateData".
Screenshots
Additional context or thoughts
Same issue exists within the repose examples, they are not getting shown when switching between the examples. Now is the Question if this is intended or a bug. If it is intended, why is there a way to reference schemas for different examples, if they are not getting respected.
I'm using node swagger-express-ui version 4 and 5, and changing between Examples on response won't update the HTML content.
I remember I had a problem with a Javascript that didn't run on a part of Swagger UI before, with Laravel. And there is something I did that could fire the Javascript, maybe directly in the source code, or other, can't remember.
I got it totally wrong, maybe I was tired last night, because once I got back on it, I realized that mine was in response 200 aaplication/json and I forgot the value key in the second object. The final syntax is this:
endpoint.get.responses['200'].content['application/json'] = {
examples: {
default: {
summary: 'LRC content in plain text',
value: {
code: "eaae19e3-c80e-4733-b5a9-497c84d24624",
title: "Hard To Say I'm Sorry",
artist: "Az Yet",
length: 198.42,
content: "[ar:Az Yet]\\n[ti:Hard To Say I'm Sorry]\\n[length:03:18.42]\\n[by:Keitel Jovin]\\n[re:www.megalobiz.com/lrc/maker]\\n[ve:1.0]\\n[00:17.87]Everybody needs a little time away\\n[00:22.87]I heard her say, from each other"
},
},
object: {
summary: 'LRC content in object format',
value: {
code: "eaae19e3-c80e-4733-b5a9-497c84d24624",
title: "Hard To Say I'm Sorry",
artist: "Az Yet",
length: 198.42,
content: {
lines: {
1: {
tag: "[00:17.87]",
time: 17.87,
lyrics: "Everybody needs a little time away"
},
},
info: {
ar: { tag: "[ar:Az Yet]", name: "artist", value: "Az Yet" },
ti: { tag: "[ti:Hard To Say I'm Sorry]", name: "title", value: "Hard To Say I'm Sorry" },
length: { tag: "[length:03:18.42]", name: "length", value: "03:18.42", time: 198.42 },
ve: { tag: "[ve:1.0]", name: "editor version", value: "1.0" }
}
}
}
}
}
};
Is there anything new on this? @char0n @glowcloud @frantuma
Swagger Editor v5 has evolved significantly since this was opened. If this is still relevant, please open a new issue with updated details – it helps us prioritize effectively. Thanks for your understanding! 🚀