openapi icon indicating copy to clipboard operation
openapi copied to clipboard

Support for $ref part 2

Open JordiPolo opened this issue 8 years ago • 4 comments

Support for $ref as text was added before. But ideally these $ref are deserialized into pointers to other structs or something like that. The deserialization should fail if the ref does not point to any known point. To validate if a ref exist in the doc I'm doing this really really terrible code: https://github.com/JordiPolo/oatool/blob/master/src/main.rs#L26

If real support is added, then all this code disappears as a non-proper ref would cause deserialization error.

JordiPolo avatar May 15 '17 14:05 JordiPolo

Hello @softprops, thanks for this crate. I'd like to ask whether there is a plan to support the deserialization of $ref to the corresponding struct (or reference to it) rather than to the struct containing the reference string? I'd would be super useful. Anyway, thanks for great work.

matusf avatar Feb 25 '21 19:02 matusf

@matusf I think I've implemented what you ask for https://github.com/JordiPolo/oas_proxy/blob/master/openapi_utils/src/dereferer.rs#L12-L31 It is published as the openapi_utils crate. It works well with the openapi files from the company I work for but we use a linter so our files all follow a specific pattern, I will not be surprised if this is not able to work for every file out there.

If @softprops would like this functionality in his library, I'm happy to open a PR with what I have and take it from there

JordiPolo avatar Feb 25 '21 20:02 JordiPolo

Thank you so much! It's exactly what I hoped for :)

matusf avatar Feb 25 '21 21:02 matusf

That would be great

softprops avatar Feb 28 '21 23:02 softprops