Comments (4)
I'm interested, in what way is this behavior a regression/bug? What is it breaking?
Admittedly, this transformation is confusing, but I don't understand how it's incorrect. Does the emitted API Elements fail to represent the data structure given to drafter in MSON?
- The sample is an
enum
, which is of the type of what we are providing a sample for. - The sample
enum
's content is not just anystring
value (i.e. withoutfixed
), but the one and onlyfree
value (i.e. withfixed
).
Also note that the output of drafter, API Elements, is by no means an Abstract Syntax Tree (AST) for API Blueprint.
from drafter.
@tjanc I don't mean that it's a bug or regression. Actually you are right, it's confusing behaviour.
from drafter.
We were toying with the idea of saying that samples/default are interpreted as fixed in API Elements by default. If I recall correctly, we dropped that mainly because of three reasons:
- it adds a point of contextual interpretation (you need to know whether the element is a sample to interpret it), adding confusion
fixed
behaves differently onarray
andobject
compared to other types, more confusion- perhaps in the future we want to have second order types in APIE; a sample then would be something more than a value; that's why always fixing every sample to a single value might close some doors on us
That said, I don't really see a reason why we shouldn't put the string
directly into samples
(without a wrapping enum
). My reasoning there was probably to have the type of the sample match the type of the element one to one, but that might be an unnecessary requirement.
@pksunkara What's your take on this?
from drafter.
it adds a point of contextual interpretation (you need to know whether the element is a sample to interpret it), adding confusion
Actually I can't understand your point. Do you mean that such AST could be interpreted without any context?
element: "enum"
content:
element: "string"
attributes:
typeAttributes:
element: "array"
content:
-
element: "string"
content: "fixed"
content: "free"
If I'm not mistaken this part is the same for enum with one element and enum example, so you need a bit of context to understand what is it.
fixed behaves differently on array and object compared to other types, more confusion
Could you please explain your point a bit more?
perhaps in the future we want to have second order types in APIE
What is second order types in this context?
from drafter.
Related Issues (20)
- Missing resource name renders incorrect output but it is validated
- Compatibility with MSVC 2019 HOT 1
- Building drafter-cli causes a link "warning" (macOS)
- Duplicit value in enumeration HOT 2
- Missing description after wrongly interpreted MSON `enum[string], fixed`
- PEGTL not fixed to specific version HOT 1
- Drafter backend crashes on unexpanded `Include (object)` HOT 1
- sigsegv
- Include Drafter version in ABI HOT 2
- Parser emits that `false` is not allowed boolean type for default HOT 1
- Ninja can no longer build due to cycling input HOT 2
- Drafter version does not work for CMake builds
- Docker hub entry outdated HOT 1
- Distinct OneOf gets parsed as single OneOf group in schema HOT 5
- Fixed array with a mixin inside produces incorrect json schema
- Building drafter is painfully slow. HOT 3
- Drafter for Java
- Compile error with newer gcc
- [build] CMake build on RHEL 9 is missing libraries HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drafter.