Skip to content
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

Resource embedding across different schemas #2346

Closed
steve-chavez opened this issue Jun 23, 2022 · 2 comments
Closed

Resource embedding across different schemas #2346

steve-chavez opened this issue Jun 23, 2022 · 2 comments
Labels
idea Needs of discussion to become an enhancement, not ready for implementation

Comments

@steve-chavez
Copy link
Member

steve-chavez commented Jun 23, 2022

Resource Embedding only supports embedding across a single schema.

According to the profile negotiation spec:

A client requests an XML document where the elements in namespace urn:example:namespaces:ns1 must conform to XML schema http://example.com/schema/schema-1 and the elements in namespace urn:example:namespaces:ns2 must conform to XML schema http://example.com/schema/schema-2. The server answers that it can supply the document as requested.

Request:
GET /some-resource HTTP/1.1
Accept-Profile: <urn:example:namespaces:ns1
http://example.com/schema/schema-1
urn:example:namespaces:ns2
http://example.com/schema/schema-2>

Response:
HTTP/1.1 200 OK
Content-Type: application/xml
Profile: <urn:example:namespaces:ns1
http://example.com/schema/schema-1
urn:example:namespaces:ns2
http://example.com/schema/schema-2>

The spec is more XML focused but I believe we can extend the same concept of "elements in namespace must conform to XML schema" to "relations must conform to schema". So this would allow us to do:

GET /projects?select=*,clients(*)

Accept-Profile: <projects:api_v1 clients:api_v2>

Where projects comes from the api_v1 schema and clients comes from the api_v2 schema.

I'm still unclear on how to structure the absolute URLs for our case, but in theory it seems possible.


The resource embedding code is actually ready for handling different schemas, we just need code for mapping the header.


Related #2769

@steve-chavez steve-chavez added the idea Needs of discussion to become an enhancement, not ready for implementation label Jun 23, 2022
@wolfgangwalther
Copy link
Member

I don't see why we would want to allow resource embedding across different profiles. When I remember correctly, you tried hard to make sure that schemas accessed through profiles are isolated from each other - there's a few test cases for that, too, right?

@steve-chavez
Copy link
Member Author

Ditching this idea. No longer think is good for an API schema to allow cross resource embedding.

We'll likely move from the Accept-Profile header too #2927

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea Needs of discussion to become an enhancement, not ready for implementation
Development

No branches or pull requests

2 participants