This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Add a migration guide for 1.0 #51
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
32d3d11
feat: Add a migration guide for 1.0
kylef af40105
refactor(migration-guide): Address pull request feedback
kylef da2b009
refactor(migration-guide): Address pull request feedback
kylef 0479d6c
refactor(migration-guide): Address pull request feedback
kylef File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,301 @@ | ||
# Migration Guide | ||
|
||
This guide documents all of the changes between API Elements 0.6 and API | ||
Elements 1.0. | ||
|
||
## JSON Serialisation | ||
|
||
In prior versions of API Element, an element could be serialised in JSON as a | ||
JSON type, or an API Element. | ||
|
||
For example, the string element in the title of the following element is a JSON | ||
value `"empty"` which is not longer valid in API Elements 1.0. | ||
|
||
```json | ||
{ | ||
"element": "null", | ||
"meta": { | ||
"title": "empty" | ||
} | ||
} | ||
``` | ||
|
||
Elements must always be serialised as an element, for example the following | ||
would be valid in API Elements 1.0: | ||
|
||
```json | ||
{ | ||
"element": "null", | ||
"meta": { | ||
"title": { | ||
"element": "string", | ||
"content": "empty" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
In previous versions of API Elements, both forms were valid so this is not a | ||
breaking change. However, we found multiple implementations that were fragile | ||
and could break when different forms were used. | ||
|
||
## Changes to Elements | ||
|
||
### Category Element | ||
|
||
The `meta` attribute has been renamed to `metadata` in a category element for | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But minim still calls it meta? Isn't it a discrepancy now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you maybe confusing meta at the element level, not the attribute called meta in the category element. Which was renamed to prevent confusion between the two. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😄 |
||
clarity. | ||
|
||
Before | ||
|
||
```json | ||
{ | ||
"element": "category", | ||
"attributes": { | ||
"meta": { | ||
"element": "array", | ||
"content": [ | ||
{ | ||
"element": "member", | ||
"content": { | ||
"key": { | ||
"element": "string", | ||
"content": "HOST" | ||
}, | ||
"value": { | ||
"element": "string", | ||
"content": "http://polls.apiblueprint.org/" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
After | ||
|
||
```json | ||
{ | ||
"element": "category", | ||
"attributes": { | ||
"metadata": { | ||
"element": "array", | ||
"content": [ | ||
{ | ||
"element": "member", | ||
"content": { | ||
"key": { | ||
"element": "string", | ||
"content": "HOST" | ||
}, | ||
"value": { | ||
"element": "string", | ||
"content": "http://polls.apiblueprint.org/" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Source Map Element | ||
|
||
A source map element may contain an optional line and column number to make it | ||
easier to handle source map information. Computing the line and column number | ||
can often be expensive so it may be provided by a parser. Note however that it | ||
is optional and it is down the each individual tooling on whether it is | ||
present, some tools only provide line and column number for source maps | ||
contained within Annotation Elements. | ||
|
||
```json | ||
{ | ||
"element": "sourceMap", | ||
"content": [ | ||
{ | ||
"element": "array", | ||
"content": [ | ||
{ | ||
"element": "number", | ||
"attributes": { | ||
"line": { | ||
"element": "number", | ||
"content": 3 | ||
}, | ||
"column": { | ||
"element": "number", | ||
"content": 2 | ||
} | ||
}, | ||
"content": 4 | ||
}, | ||
{ | ||
"element": "number", | ||
"attributes": { | ||
"line": { | ||
"element": "number", | ||
"content": 3 | ||
}, | ||
"column": { | ||
"element": "number", | ||
"content": 10 | ||
} | ||
}, | ||
"content": 12 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### Data Structure Elements | ||
|
||
#### Enumeration Element | ||
|
||
The layout of the enum element has been altered. The enumerations have been | ||
moved to an enumerations attribute of the element and the content now | ||
represents the given value. | ||
|
||
Enumerations themselves are an array of the possible enumerations. | ||
|
||
Before | ||
|
||
```json | ||
{ | ||
"element": "enum", | ||
"content": [ | ||
{ | ||
"element": "string", | ||
"content": "north" | ||
}, | ||
{ | ||
"element": "string", | ||
"content": "east" | ||
}, | ||
{ | ||
"element": "string", | ||
"content": "south" | ||
}, | ||
{ | ||
"element": "string", | ||
"content": "west" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
After | ||
|
||
```json | ||
{ | ||
"element": "enum", | ||
"attributes": { | ||
"enumerations": { | ||
"element": "array", | ||
"content": [ | ||
{ | ||
"element": "string", | ||
"content": "north" | ||
}, | ||
{ | ||
"element": "string", | ||
"content": "east" | ||
}, | ||
{ | ||
"element": "string", | ||
"content": "south" | ||
}, | ||
{ | ||
"element": "string", | ||
"content": "west" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
The intent of the structure was that it represents an enumeration of `north`, | ||
`east`, `south` and `west`. As the enumerations do not include a `fixed` type | ||
attribute it represents an enumeration where any string is valid and not just | ||
the fixed values. This created a limitation that tooling cannot determine the | ||
difference between one of the fixed element enumerations, or a type with a | ||
value. Thus, when the values are fixed they will now include a `fixed` type | ||
attribute as follows: | ||
|
||
```json | ||
{ | ||
"element": "enum", | ||
"attributes": { | ||
"enumerations": { | ||
"element": "array", | ||
"content": [ | ||
{ | ||
"element": "string", | ||
"attributes": { | ||
"typeAttributes": { | ||
"element": "array", | ||
"content": [ | ||
{ | ||
"element": "string", | ||
"content": "fixed" | ||
} | ||
] | ||
} | ||
}, | ||
"content": "north" | ||
}, | ||
{ | ||
"element": "string", | ||
"attributes": { | ||
"typeAttributes": { | ||
"element": "array", | ||
"content": [ | ||
{ | ||
"element": "string", | ||
"content": "fixed" | ||
} | ||
] | ||
} | ||
}, | ||
"content": "east" | ||
}, | ||
{ | ||
"element": "string", | ||
"attributes": { | ||
"typeAttributes": { | ||
"element": "array", | ||
"content": [ | ||
{ | ||
"element": "string", | ||
"content": "fixed" | ||
} | ||
] | ||
} | ||
}, | ||
"content": "south" | ||
}, | ||
{ | ||
"element": "string", | ||
"attributes": { | ||
"typeAttributes": { | ||
"element": "array", | ||
"content": [ | ||
{ | ||
"element": "string", | ||
"content": "fixed" | ||
} | ||
] | ||
} | ||
}, | ||
"content": "west" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about something like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's much better, copied this into da2b009.