Skip to content
This repository was archived by the owner on Mar 18, 2019. It is now read-only.

Link's encoding is no longer fixed to application/json, it's from the schema #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,8 @@ To run the tests (linting & unit tests):
[npm-url]: http://badge.fury.io/js/coreapi
[codecov-image]: https://codecov.io/gh/core-api/javascript-client/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/core-api/javascript-client


# Fixed

Link's encoding is no longer fixed to `application/json`, it's from the schema.
3 changes: 2 additions & 1 deletion lib/codecs/corejson.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function primitiveToNode (data, baseUrl) {
const title = getString(data, 'title')
const description = getString(data, 'description')
const fieldsData = getArray(data, 'fields')
const encoding = getString(data, 'encoding') || 'application/json'
var fields = []
for (let idx = 0, len = fieldsData.length; idx < len; idx++) {
let value = fieldsData[idx]
Expand All @@ -83,7 +84,7 @@ function primitiveToNode (data, baseUrl) {
let field = new document.Field(name, required, location, fieldDescription)
fields.push(field)
}
return new document.Link(url, method, 'application/json', fields, title, description)
return new document.Link(url, method, encoding, fields, title, description)
} else if (isObject) {
// Object
let content = {}
Expand Down