Skip to content

Commit

Permalink
Merge pull request #79 from apiaryio/kylef/title-type
Browse files Browse the repository at this point in the history
feat(refract): Use the title of a hrefVariable as the type
  • Loading branch information
pksunkara committed Feb 3, 2017
2 parents 0560a21 + 9588fe0 commit 460bf62
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,13 @@
# Metamorphoses Changelog

## 0.13.5

### Enhancements

- Metamorphoses Refract adapter will use the title of an href variable as the
type if available.
[api-elements#20](https://github.com/apiaryio/api-elements/pull/20)

## 0.13.4

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@apiaryio/metamorphoses",
"version": "0.13.4",
"version": "0.13.5",
"description": "Transforms API Blueprint AST or legacy Apiary Blueprint AST into Apiary Application AST",
"main": "./lib/metamorphoses",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/adapters/refract/getUriParameters.coffee
Expand Up @@ -19,9 +19,11 @@ getUriParameters = (hrefVariables, options) ->
required = false

memberContent = lodashedHrefVariable.content()
title = lodashedHrefVariable.get('meta.title', '').contentOrValue().value()
key = memberContent.get('key').contentOrValue().value()
memberContentValue = memberContent.get('value')
type = memberContentValue.get('element').value()

type = title or memberContentValue.get('element').value()

sampleValues = memberContentValue.get('attributes.samples', '').contentOrValue()
defaultValue = memberContentValue.get('attributes.default', '').contentOrValue()
Expand Down
36 changes: 36 additions & 0 deletions test/getUriParameters-test.coffee
Expand Up @@ -153,6 +153,42 @@ describe('Transformation • Refract • getUriParameters' , ->
hrefVariables: undefined,
parameters: undefined,
},
{
hrefVariables: {
'element': 'hrefVariables',
'content': [
{
'element': 'member',
'meta': {
'title': 'datetime',
'description': 'Filter for posts since the specified date'
},
'content': {
'key': {
'element': 'string',
'content': 'since'
},
'value': {
'element': 'string',
'content': 'thursday'
}
}
}
]
},
parameters: [
{
'key': 'since',
'description': '<p>Filter for posts since the specified date</p>\n',
'type': 'datetime',
'required': false,
'default': '',
'example': 'thursday',
'values': [
]
}
]
},
]

it('should be transformed into a `parameter` object', ->
Expand Down

0 comments on commit 460bf62

Please sign in to comment.