-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
I'm having a hard time finding information about this in specs, so I can't guess whether the problem that I'm about to describe is by design or a if it's a bug.
When, within definitions
, an entry exists with a property referencing another definition via $ref
and also having a description
value, then swagger-editor shows a warning.
If it's only one, it wouldn't bother me as much, but my swagger-json is large, and I have dozens (and growing) of these. I'm trying to stay adamant with keeping the description
field where it is (as opposed to moving it to the actual referenced definition, which is what fixes the problem), because otherwise swagger-ui doesn't display it at all.
For example, the editor does not like description
values in this YAML definition
snippet):
'response:container:collection:agent':
type: object
properties:
jsonapi:
$ref: '#/definitions/response:container:jsonapi'
description: Service information
meta:
$ref: '#/definitions/response:container:meta'
description: Request processing information
links:
$ref: '#/definitions/response:container:links'
description: URLs related to the primary resource(s)
data:
type: array
items:
$ref: '#/definitions/response:data:agent'
included:
type: array
items:
$ref: '#/definitions/response:container:related'
description: 'Related resources of types: "lab"'
required:
- data
- jsonapi
- links
- meta
... while swagger-ui displays those description
values regardless (which I like):
When I move those description
fields to definition of objects that $ref
values point to, then swagger-editor shows the content as valid (so, no warning), but swagger-ui does not display those description values at all (not at the property level, not at the type level).
I did find some traces showing that my description
values are where they are supposed to be - see this:
Source: http://json-schema.org/example1.html
It seems logical to me that both locations should allow description
field: it may be desired that the definition ($ref
) is described in some generic way, while its usage (properties
) is described in addition to that. E.g. I could say that my $ref
"agent" is "a record that represents an employee", while my data
property can be described as "collection of agents". In other words, I think that both editor and swagger-ui should add the missing functionality in their code base, cause there's an obvious mismatch. I guess, if description
can't be in both places, then if the two projects are at least in agreement about where it goes, it would help.
Thanks.