freeconf / restconf

Implementation of RESTCONF Management protocol - IETF RFC8040
Apache License 2.0
29 stars 9 forks source link

when requesting xml, response is a truncated json response #31

Closed pdumais closed 1 year ago

pdumais commented 1 year ago

When doing a POST with content-type "application/yang-data+json", the restconf server responds with a correctly formated response that conforms to our yang model.

But if the request is made with application/yang-data+xml. then the response is send as application/yang-data+json, but with the top level attribute stripped out.

dhubler commented 1 year ago

FreeCONF doesn't support XML https://freeconf.org/docs/reference/compliance/rfcs/ Curious, is this just for compliance? My impression was there is little practical reason to support this, only theoretical. I'm not sure how hard this would be to support.

If you pass anything but application/yang-data+json you get regular JSON and not namespaces per RFC7951 much like how gnmi supports both

https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-specification.md#231-json-and-json_ietf

On Thu, Apr 13, 2023 at 7:21 AM Patrick Dumais @.***> wrote:

When doing a POST with content-type "application/yang-data+json", the restconf server responds with a correctly formated response that conforms to our yang model.

But if the request is made with application/yang-data+xml. then the response is send as application/yang-data+json, but with the top level attribute stripped out.

— Reply to this email directly, view it on GitHub https://github.com/freeconf/restconf/issues/31, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACA7VW5JQ2FZ2NJAAWL63XA7OTLANCNFSM6AAAAAAW456K2I . You are receiving this because you are subscribed to this thread.Message ID: @.***>

pdumais commented 1 year ago

If you pass anything but application/yang-data+json you get regular JSON This means that issue #29 should not get resolved then. I'll take a look at the RFC. Do you remember where you saw that?

pdumais commented 1 year ago

actually, let me rephrase the issue.

When a request is made with content-type yang-data+xml, it is ok to respond with yang-data+json. When when receiving the response, I expect it to be the same regardless. In our case, we are missing the top level node of the json document.

dhubler commented 1 year ago

Today we have:

When Accept: yang-data+json Expect JSON IETF7951

When Accept: anything else Get JSON

You want:

When Accept: yang-data+json or yang-data+xml Expect JSON IETF7951

When Accept: anything else Get JSON

If so, I kinda feel if the ask is for xml, we should error, not return JSON (IETF7951 or otherwise)

On Thu, Apr 13, 2023 at 7:48 AM Patrick Dumais @.***> wrote:

actually, let me rephrase the issue.

When a request is made with content-type yang-data+xml, it is ok to respond with yang-data+json. When when receiving the response, I expect it to be the same regardless. In our case, we are missing the top level node of the json document.

— Reply to this email directly, view it on GitHub https://github.com/freeconf/restconf/issues/31#issuecomment-1506828360, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACA7UJXR57HL47WHWU67TXA7RZ7ANCNFSM6AAAAAAW456K2I . You are receiving this because you commented.Message ID: @.***>

pdumais commented 1 year ago

Our problem was that we needed to explicitely set OnlyStrictCompliance to true. But then XML is not working at all Our client is sending content-type and accept to yang-data+xml In that case, it should instead return a 415.

We're gonna have to request XML support. We can talk about this through another channel

** message edited