简体   繁体   中英

How do I specify a "JSON Raw Message" in API object using Swagger 2.0 or OpenApi 3.x?

I am documenting a REST API (developed in Go) using Swagger 2.0 and one of the structures used by an API Response includes several fields that are declared to be of type "Json.RawMessage" in Go. I can't find any appropriate "data type" in the Swagger specification that would cover this. The closest that I could imagine would be a string in "byte" format. But that isn't even close. Any ideas would be of great help.

json.RawMessage is just way of parsing of json message. It allows to delay parsing of some fields or all the message.

It doesn't affect structure or format of response so you don't need to specify it in openapi spec by any way.

The only thing I can guess, that some of the fields could have different schemas from one response to another. So you can't document all of them in the same time (as far as I know openapi features), and all you can do is to describe it as just general "object" . And describe possible schemas somewhere in documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM