-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toEmbeddedRefract #254
Comments
That's right, we removed it in Minim 0.17 (https://github.com/refractproject/minim/releases/tag/v0.17.0). Missed that it was still in the README and I'll fix this shortly. We settled on only supporting a single form of JSON serialisation for Refract (and API Elements) and it was removed from the Refract spec in 2017 via refractproject/refract-spec#73. |
This function has been removed in prior Minim (0.17.0) and was mistakenly left in the documentation. Closes #254
Cool, thanks for explanation ;] |
With GZIP of JSON serialisation we don't currently face any performance problems due to the over-the-wire format, if we did in future it might make sense to explore binary serialisation formats like protobuf and the likes. |
Yes, I remember having discussion about it with Wilda and we agreed GZIP + JSON is more than enough. Maybe offtopic, but still related. What was the background for making the decision, that |
I think the best approach for the parser is that it shouldn't blanket handle The parser(s) do need to ensure that the Theres some reasons where each individual parser may vary so I'll break them down below. For API Blueprint, this rule is followed with exception of body generation (more on that below). OpenAPI 2 (not 3) in particular is implemented different (more at the end). General Exception: Message Body ExamplesThere are parser features (which IMO i'm not entirely sure they really belong in the parser, but they are here historically for performance reasons):
Generating a JSON example body requires the dereferencing to take place which is the case where the API Blueprint (drafter) and OpenAPI 3 (fury-adapter-oas3-parser) parser will do dereferencing. JSON Schema generation is similiar, in most cases generated JSON Schemas are "self-contained" and themselves contain all their Long term, I don't think this work nessecerily should be done directly in the parser but its ended up that way for performance reasons in API Blueprint and the OAS 2/3 parsers follow the same design. 🥇 This feature of generating example message bodies and schemas is now optional (as of today) in apiaryio/api-elements.js#281 and available in subsequent releases of Drafter and the Fury adapters. Next step is to provide some kind of fury serialisers for these message body formats which I've outlined at apiaryio/api-elements.js#372. The plan is that we can push some of this expansion and generation in this case down to the API Elements consumer and do it "on the fly" when they want JSON example bodies or JSON Schemas. This particular aspect counts for most of API Blueprint parsing time (apiaryio/api-elements.js#281 (comment)) and larger API Elements trees. It will remaing enabled by default to maintain current behaviour as to not break any tooling Apiary, and others have. Thus this is something we're actively working towards changing but there's work to do:
API Elements and/or tooling doesn't support referencing a particular componentWhile API elements has a generic referencing system, most tooling and Apiary products does not have generic support for referencing. For example adding referenced hrefVariables is theoretically possible for some aspects of the data, for example the following would be valid in API Elements: {
"element": "hrefVariables",
"content": [
{
"element": "member",
"content": {
"key": { "element": "string", "content": "username" },
"value": { "element": "username" }
}
}
]
} Perhaps placing inside a data structure category: {
"element": "string",
"meta": {
"id": { "element": "string", "element": "username" }
},
"content": "doe"
} Most tooling I am aware of (Dredd, ApiaryUI etc) don't allow for this and thus need adapting to move towards this direction. We should introduce further categories to be able to store particular elemenents which do not fit into the existing structure (such as reusable header structures -- possibly they can be put in data structures but they cannot contain header or parameter specific information). A problem here is that our referencing system does not have any concept of name spacing and is done via id's and thus translating OAS names into API Element's tree can have either collisions (if theres a Schema Object named "user" and a header object named "user"). The route that the OAS 2 parser went down to solve this is to namespace the reusable element id's such as I don't think there are any GitHub issues tracking any of this. Although it will need to be solved to implement apiaryio/api-blueprint-rfcs#3 and full OpenAPI 3.0 compatibility in API Elements. OpenAPI 2 Parser❗ Our OpenAPI 2 parser (fury-adapter-swagger) is the exception to all of this, the way that parser was architected is that the parser takes the approach of dereferencing the entire tree upfront (because that's how swagger-parser, it's dependency does it). I think this is a poor approach which I've slowly been trying to solve to improve the performance of that particular adapter but it is something that has not been fully resolved (and I'm not sure it makes sense for us to invest effort in doing so). |
Thank you for this analysis. I will have a lot of followup questions to this ;] |
So if I understand what you said correctly, what you're saying is: Parser do need to understand the JSON-References and should encode them to RefElements. And then every found reference ( |
AFAICT the
toEmbeddedRefract
is not part of the library any more, yet it is still mentioned in the README. Is it correct observation?The text was updated successfully, but these errors were encountered: