diff --git a/app/helpers/schemaReferenceContext.js b/app/helpers/schemaReferenceContext.js new file mode 100644 index 00000000..7d9801d9 --- /dev/null +++ b/app/helpers/schemaReferenceContext.js @@ -0,0 +1,10 @@ +var common = require('../lib/common'); + +/** + * Resolve a (local) json schema $ref and replace context to referenced object. + * @param reference + * @param options + */ +module.exports = function(reference, options) { + return options.fn(reference ? common.resolveSchemaReference(reference, options.data.root) : this); +}; diff --git a/app/views/partials/swagger/parameters.hbs b/app/views/partials/swagger/parameters.hbs index 98f450f1..250a2c02 100644 --- a/app/views/partials/swagger/parameters.hbs +++ b/app/views/partials/swagger/parameters.hbs @@ -10,34 +10,36 @@ {{#if parameters}}
{{#each parameters}} -
-
-
{{name}}
- {{#if required}} - - {{/if}} -
- in {{in}} + {{#schemaReferenceContext $ref}} +
+
+
{{name}}
+ {{#if required}} + + {{/if}} +
+ in {{in}} +
+
+ {{~>json-schema/datatype . ~}} +
+ {{!-- + {{#if schema.$ref}} + {{$ref}} + {{/if}} + --}}
-
- {{~>json-schema/datatype . ~}} +
+ {{>swagger/description description}}
- {{!-- - {{#if schema.$ref}} - {{$ref}} - {{/if}} - --}}
-
- {{>swagger/description description}} -
-
- {{! parameter `collectionFormat` field }} - {{~#if collectionFormat ~}} -
- {{md (swaggerCollectionFormat collectionFormat name) stripParagraph=true}} -
- {{~/if}} + {{! parameter `collectionFormat` field }} + {{~#if collectionFormat ~}} +
+ {{md (swaggerCollectionFormat collectionFormat name) stripParagraph=true}} +
+ {{~/if}} + {{/schemaReferenceContext}} {{/each}}
{{/if}} diff --git a/app/views/partials/swagger/responses.hbs b/app/views/partials/swagger/responses.hbs index 24bee5db..27a6d5e0 100644 --- a/app/views/partials/swagger/responses.hbs +++ b/app/views/partials/swagger/responses.hbs @@ -21,25 +21,27 @@ --}} {{#each responses}} -
-
- {{! Use response-code and http-name as text}} -
{{@key}} {{httpResponseCode @key}}
- {{#if schema}} -
{{>json-schema/reference schema}}
- - {{/if}} + {{#schemaReferenceContext $ref}} +
+
+ {{! Use response-code and http-name as text}} +
{{@key}} {{httpResponseCode @key}}
+ {{#if schema}} +
{{>json-schema/reference schema}}
+ + {{/if}} +
+
+ {{md description}} +
-
- {{md description}} -
-
- {{#if schema.type}} -
-
type
-
{{>json-schema/datatype schema}}
-
- {{/if}} + {{#if schema.type}} +
+
type
+
{{>json-schema/datatype schema}}
+
+ {{/if}} + {{/schemaReferenceContext}} {{/each}}
@@ -53,37 +55,39 @@ {{/if}} {{#each responses}} - {{#if schema}} -
-
Response Example ({{@key}} {{httpResponseCode @key}})
- {{>swagger/print-example .}} -
- {{/if}} - {{#if headers}} + {{#schemaReferenceContext $ref}} + {{#if schema}}
-
Response Headers ({{@key}} {{httpResponseCode @key}})
-
- - - - - - - - - - {{#each headers}} - {{#if $ref}} - {{> swagger/responseHeaderRow header=(json-schema-resolve-ref $ref) name=@key}} - {{else}} - {{> swagger/responseHeaderRow header=. name=@key}} - {{/if}} - {{/each}} - -
-
+
Response Example ({{@key}} {{httpResponseCode @key}})
+ {{>swagger/print-example .}}
- {{/if}} + {{/if}} + {{#if headers}} +
+
Response Headers ({{@key}} {{httpResponseCode @key}})
+
+ + + + + + + + + + {{#each headers}} + {{#if $ref}} + {{> swagger/responseHeaderRow header=(json-schema-resolve-ref $ref) name=@key}} + {{else}} + {{> swagger/responseHeaderRow header=. name=@key}} + {{/if}} + {{/each}} + +
+
+
+ {{/if}} + {{/schemaReferenceContext}} {{/each}}