HTTP API define readOnly and requiered fields for struct properties in service builder

Hello:

Open API specification allows to set readOnly and requiered properties on definitions sections such as:

    "definitions": {
        "MyObject": {
            "type": "object",
            "properties": {
                "Id": {
                    "type": "integer",
                    "format": "int32",
                    "readOnly": true
                },
                "Name": {
                    "type": "string"
                },
                "Description": {
                    "type": "string"
                }
            },
            "required": ["Name", "Description"]
        }

This results in two great effects in documentation when referenced from an API path/method:

  1. readOnly fields are only presented on GET methods, indicating that is not necessary to provide them on PUT nor on POST (this is a very cummon case for generated values)
  2. requiered fields are presented as such

We use service builder / *.rodl file to define our API and I can’t figure out how to specify this properties. Is this possible?

Hi,

Remoting SDK doesn’t support readOnly properties.


from OpenAPI-Specification/versions/2.0.md at main · OAI/OpenAPI-Specification · GitHub regarding readOnly properties:

Relevant only for Schema "properties" definitions. Declares the property as “read only”. This means that it MAY be sent as part of a response but MUST NOT be sent as part of the request. Properties marked as readOnly being true SHOULD NOT be in the required list of the defined schema. Default value is false .

as a workaround: your method can accept Struct1 but should return descendant of Struct1 with additional fields (i.e. Struct2).

Thanks EvgenyK,

I’ll look into implementing the workaround.

I’m wondering… Is it posible to define the requiered list of the schema?

Hi,

even you specify required in the schema in some way, server-side doesn’t support it.
as a result it may just fail

Oh I see, that clears things out.

Thanks again EvengyK.