Comments (7)
I've a test case for this somewhere too, thanks for the example. There has been quite a lot of work and discussion around the context of property descriptions, and I was sure we'd got this right (for example, we have lots of resources that contain addresses which are defined as a standard, reusable definition. Each address instance is different though, so the description of each address property is taken from the property and not the referenced definition.
I can confirm I can reproduce with your example. Will investigate, as we agree with you, that is the way it should be. There might be a subtle difference in our specifications. We will see...
from dapperdox.
If you define the second
property as follows (with the $ref
within an items
member), then you get the result you expect (for second
).
"second": {
"type": "object",
"description": "second property",
"items" : {
"$ref": "#/definitions/MyObject"
}
}
items
appears only mandatory for arrays (and outside of in in
body). To be honest, the specification isn't that explicit, and parsers generally seem to manage. We wonder if using an items
member for no array references is strictly wrong. Either way, DapperDox is not working for specifications that do not have items
and that is incorrect.
Fixing....
EDIT: Actually, we're convinced "items": { "$ref": .... }
is wrong for all but array types.
from dapperdox.
The problem seems to stem from go-openapi
, the specification parser used by DapperDox. Without the "items":{}
wrapper around "$ref": ...
we do not get a Description
returned by go-openapi
.
I've opened an issue over there, so we'll see what they say. We've sent them quite a detailed report. go-openapi/spec#22
from dapperdox.
We've got the answer. JSON schema states that other properties in an object with $ref need to be ignored. http://json-schema.org/latest/json-schema-core.html#rfc.section.7 So what go-openapi
and thus DapperDox is doing is correct.
However, wrapping $ref
in an items:{}
block is also (technically) wrong, as items
should only be used for arrays. Because DapperDox needs to support it for arrays, it also "works" for object.
The correct solution (advised by the go-openapi
guys) is this:
{
"first": {
"allOf" : [
{
"type": "object",
"description": "first property"
},
{
"$ref": "#/definitions/MyObject"
}
]
}
}
Basically, merge the partial schema object, containing type
and description
with the referenced object, thus adding description
to MyObject (type is mandatory, so must be there).
However, the current release of DapperDox doesn't process this correctly because it expects each element of the allOf
array to be a complete schema object, each with properties
. We just hadn't seen or expected this use case.
We're working on a more complete solution, so will leave this issue open.
from dapperdox.
Great, thanks!
from dapperdox.
Still working on this. It's a little complicated!
from dapperdox.
I was testing some other schema and I found a solution with works:
{
"first": {
"type": "object",
"description": "first property"
"allOf" : [
{
"$ref": "#/definitions/MyObject"
}
]
}
}
I'm not sure if this is according to the spec but it is rendered as expected in dapperdox.
from dapperdox.
Related Issues (20)
- Ability to handle deprecated fields in swagger2.0 spec
- Open redirect HOT 2
- Code examples support in several languages HOT 1
- Documentation and implementation error
- Version string is incorrect HOT 1
- Set dependencies to specific versions
- Dapperdox as a centralized "API Catalog" HOT 1
- How to publish the api documentation on public host
- Can I use with existing node.js application?
- Can I use dapperdox inside my product which is distributable?
- Support oneOf for Schema Objects
- not able to do the API calls even when on separate sub domain
- Tag name and description related
- How to parse specifications from url?
- configure http and https schemes.
- How can i run dapperdox as a Linux service? HOT 1
- ARM build running issues
- Run dapperdox example locally
- code-samples insertion in different languages
- GPLv3 license HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dapperdox.