Skip to content

Use *content* application/json for OpenAPI complex parameters serialization #1308

@valerii15298

Description

@valerii15298

Describe the feature

The one place where oRPC does not adhere to OpenAPI specification is complex parameters serialization.

From oRPC docs: https://orpc.dev/docs/openapi/bracket-notation

Image

This way of serializing parameters is not OpenAPI compliant, is tool specific and not portable. OpenAPI parameter style deepObject can only handle one level of nesting.

The better way would be to use content application/json for complex parameters.
Example openapi schema(you can test it in https://editor.swagger.io):

openapi: 3.1.0
info:
  version: ''
  title: ''

paths:
  /test:
    get: 
      parameters: 
        - name: test
          in: query
          content: 
            application/json: 
              schema: 
                type: object
                properties: 
                  arr:
                    type: array
                    items: 
                      type: number
                  num:
                    type: object
                    properties: 
                      a:
                        type: string
                      b:
                        type: number
        
      responses: 
        2XX: 
          description: hello
          content: 
            application/json: 
              schema:
                type: string
    

In this way we can define any complex parameters (objects inside object etc...) because it is just serialized as json and it would be fully OpenAPI compliant and portable.

Would be great for oRPC to generate such parameter definition for OpenAPI when it is a complex object.

References:
https://spec.openapis.org/oas/v3.1.2.html#fixed-fields-for-use-with-content

Image

This feature request is for oRPC 2.0

Related: https://github.com/unnoq/orpc/issues/518

Additional information

  • Would you be willing to help implement this feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions