Skip to content

Commit

Permalink
Add baseUrl property to generated output body (#71)
Browse files Browse the repository at this point in the history
Issue #53 raises concern that the generated output contains neither host
nor basePath. This commit adds basePath to the top of index.html, just
before info.version.

Both the location of basePath and the continued absence of host were
inspired by the current format of Swagger UI (2.0), with basePath and
info.version colocated and host never being displayed.

Issue #53: 'Missing fields'
#53
  • Loading branch information
TheTaylorHicks committed Jun 29, 2016
1 parent 1dbd110 commit cc65bcb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,4 +1,5 @@
.idea
*.iml
node_modules
target
test-output
test-output
2 changes: 1 addition & 1 deletion handlebars/partials/base/body.hbs
Expand Up @@ -4,7 +4,7 @@
--}}
<h1>{{info.title}}</h1>
<p class="sw-info-version">Version: <span>{{info.version}}</span></p>
<p class="sw-info">{{#if basePath}}Base URL: <span class="sw-info-basePath">{{basePath}}</span>, {{/if}}Version: <span class="sw-info-version">{{info.version}}</span></p>
<p>{{md info.description}}</p>

{{#if consumes}}
Expand Down
2 changes: 1 addition & 1 deletion less/theme.less
Expand Up @@ -163,7 +163,7 @@ span.sw-default-value-header {
font-weight: bold;
}

.sw-info-version {
.sw-info {
font-weight: bold;
span {
font-family: monospace;
Expand Down
11 changes: 8 additions & 3 deletions test/info-object/info-object-spec.js
Expand Up @@ -23,11 +23,16 @@ describe('The info object should', function () {
})

it('cause to render the API version.', function () {
expect(context.$('p.sw-info-version').text()).to.contain('Version:')
expect(context.$('p.sw-info-version > span').text()).to.contain('1.0.0')
expect(context.$('p.sw-info').text()).to.contain('Version:')
expect(context.$('p.sw-info > span.sw-info-version').text()).to.contain('1.0.0')
})

it('cause to render the Base URL.', function () {
expect(context.$('p.sw-info').text()).to.contain('Base URL:')
expect(context.$('p.sw-info > span.sw-info-basePath').text()).to.contain('/v1')
})

it('cause to render a description.', function () {
expect(context.$('p.sw-info-version + p + p').html()).to.contain('Description is present.')
expect(context.$('p.sw-info + p + p').html()).to.contain('Description is present.')
})
})
1 change: 1 addition & 0 deletions test/info-object/swagger.json
Expand Up @@ -5,6 +5,7 @@
"version": "1.0.0",
"title": "API title"
},
"basePath": "/v1",
"paths": {
"/": {
"get": {
Expand Down

0 comments on commit cc65bcb

Please sign in to comment.