A $ref needs to be wrapped inside a schema which is not according to spec.
See original GitHub issueThis is a followup to https://github.com/swagger-api/swagger-ui/issues/1228
I have
"Person" : {
"type" : "object",
"title" : "Information about a person",
"properties" : {
"externalId1" : {
"title" : "first",
"type" : "object",
"$ref" : "#/definitions/map1"
}
which does not work. The answer was to wrap it inside a “schema” and then it works:
"externalId1" : {
"title" : "first",
"type" : "object",
"schema": { // < -------------- This will make it work like you expect
"$ref" : "#/definitions/map1"
} // ------------------- :)
},
However, after looking into the spec of both swagger and JSON schema, there is no reference anywhere the “schema” wrapper is required.
As far as I can tell, my version without the “schema” wrapper is correct.
The example here https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#simple-model does not use the “schema” wrapper.
Am I missing something?
Issue Analytics
- State:
- Created 8 years ago
- Comments:21 (11 by maintainers)
Top Results From Across the Web
openapi - Swagger schema properties ignored when using $ref
A possible workaround is to wrap $ref into allOf - this can be used to "add" attributes to a $ref but not override...
Read more >OpenAPI Specification - Version 3.0.3 - Swagger
Schema. In the following description, if a field is not explicitly REQUIRED or described with a MUST or SHALL, it can be considered...
Read more >Applying Subschemas Conditionally - JSON Schema
The dependentRequired keyword conditionally requires that certain properties must be present if a given property is present in an object. For example, suppose ......
Read more >XML Schema Part 0: Primer Second Edition - W3C
In such cases, you will need to refer to the XML Schema specification, ... An instance is not actually required to reference a...
Read more >Language Guide | Protocol Buffers - Google Developers
Repeated fields of numeric types can be serialized in the packed format, which will not be parsed correctly when an optional field is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, I thought the
description
is used to describe the field (externalId1
andexternalId2
in this case). If thedescription
must be on the referenced object, then you can not have a different description if you have multple references to the same object?So something like:
is not correct and not otherwise possible?
Okay, just wanted to make sure.
This how
"Person"
should be defined: