-
Notifications
You must be signed in to change notification settings - Fork 15
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
Yet another Overlay proposal #36
Comments
Should this be a distinct spec from OpenAPI? |
Should the core document reference the overlay or should the overlay reference the core document? Or should the relationship be dynamic and external to the spec? Should overlays be composable? Can I reference one overlay from another? |
Consensus:
|
Suggestion for 3.1 that extensions that have a null value have the same meaning as the extension not being present. |
See also http://jmespath.org One reason I suggest it as an alternative, is that JSONPath defers 'scripting' expressions to the underlying language.
which we of course have no control over, potentially leading to incompatible overlay documents. In naive implementations this would be a security risk too. JSONPath's dual dotted and bracketed syntaxes also don't help with trying to get across clear intent. Just for fun I've implemented the above (but with Question: how (if?) are Question: should we allow a I think I'm in favour of publishing this as a separate spec., because there's really nothing which is OpenAPI-specific about it. Maybe we could issue a Technical Note or similar? (I'd also like to do one for an errata for v2.0 of the main spec.) |
That said, if we prefer to align things a little more to the OAS, then I'd be tempted to slightly rework the structure as follows: overlay: 1.0.0
info:
version: 1.0.0
title: My Nice Overlay
extends: ./openapi.yaml # an optional uri_reference to the base openapi document OR another overlay document
updates:
- target: info
value:
description: Overlay applied |
@darrelmiller here by way of an example is an overlay which translates all |
Let's work on this together. It's gonna be implemented soon in AsyncAPI. BTW, I like the direction it's taking. |
Just a couple of observations... Behavior:
General structure:
Overlay Object:
Update Object:
|
Food for thoughts:
why not use an existing diffing format? I am thinking Unified Diff or a variation thereof. This would cover both "diffing" and "patching" use cases, with all the benefits of using an existing (and widely used) format and not having to maintain "yet another"(tm) Spec. |
@jstoiko two 'objections' to using a format such as unified diff or json-patch:
|
@webron thoughts on your notes (in case I forget during the call):
An OAS document which is invalid because overlays have not been applied is invalid, period. As long as we do not specify that tooling MUST validate the target OAS document before applying overlays we leave ourselves an exit hatch. However, in the real world tools using a parser to ingest the target OAS document will likely choke on an invalid one. We could reach out to the JMesPath maintainer and see whether there is any appetite for producing an RFC (possibly supported by TDC contributions). I would strongly suggest supporting all of whatever expression language we choose, as supporting a subset hobbles the ability of tooling to use existing libraries. (This is another reason not to use JsonPath.) |
hi, all By the way, i18n is so import, we shouldn't hesitate so long. Bests, JK openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
description: A sample API that uses a petstore as an example to demonstrate features in the
servers:
- url: http://petstore.swagger.io/api
paths:
/pets:
get:
description: Returns all pets from the system that the user has access to
post:
description: $ref: '@abc/en.properties/key_pets_post_desc' |
@shijinkui Your example isn't valid YAML syntax:
Even if we changed all |
Dear community, I started development on tooling to apply overlays to JSON and YAML files. I based it on the specs of the openapi overlays. A very early alpha version can be found at GitHub > JayOverlay. Currently it has a gradle plugin to apply the overlays but working on CLI and maven plugin. |
@darrelmiller @lornajane want to transfer this issue to the Overlays repo? I don't have permissions there. |
Thanks! Although I'm not sure what to do with these issues that have been open a while and where things like Overlays have moved on. I'll close this one as I feel that we have taken the action that it needs. |
A continuation of the conversation in #35 but with a new approach.
Updated 2018/12/06 based on Mike's suggestions.
OpenAPI Overlays
In recent months we have been discussing various use cases for overlays and various solutions. The following proposal takes a somewhat more radical approach to the problem. It is a more ambitious proposal than the others we have seen before but the additional complexity does allow for supporting many of the scenarios that have been discussed to date.
Overlay Document
An overlay document contains a list of Update Objects that are to be applied to the target document. Each Update Object has a
target
property and avalue
property. Thetarget
property is a JMESPath query that identifies what part of the target document is to be updated and thevalue
property contains an object with the properties to be overlayed.Overlay Object
This is the root object of the OpenAPI Overlay document.
Fixed Fields
string
url
The list of update objects MUST be applied in sequential order to ensure a consistent outcome. This enables objects to be deleted in one update and then re-created in a subsequent update.
Info Object
This object contains identifying information about the OpenAPI Overlay document.
Fixed Fields
string
string
Update Object
This object represents one or more changes to be applied to the target document at the location defined by the target JMESPath.
Fixed Fields
string
The properties of the
Value Object
MUST be compatible with the target object referenced by the JMESPath key. When the Overlay document is applied, the properties in theValue Object
replace properties in the target object with the same name and new properties are appended to the target object.Structured Overlays Example
When updating properties throughout the target document it may be more efficient to create a single
Update Object
that mirrors the structure of the target document. e.g.Targeted Overlays
Alternatively, where only a small number of updates need to be applied to a large document, each Update Object can be more targeted.
Wildcard Overlays Examples
One significant advantage of using the JMESPath syntax that it allows referencing multiple nodes in the target document. This would allow a single update object to be applied to multiple target objects using wildcards.
Array Modification Examples
Due to the fact that we can now reference specific elements of the parameter array, it does open the possibilty to being able to add parameters and potentially remove them using a
null
value.Proposal Summary
Benefits
Challenges
The text was updated successfully, but these errors were encountered: