Skip to content

schema-style should also apply to JSON params of API with application/x-www-form-urlencoded content type #882

Open

Description

@ilPittiz

Imagine having a POST/PUT API whose requestBody has application/x-www-form-urlencoded content type, and having a parameter admitting a JSON as value.
Defining schema-style="table" doesn't affect the rendering of the parameter's schema, which complies instead to tree schema style.
Unless this is an intended design choice, I'd say a consistent rendering of all schemas would be preferable.

Full HTML example code:

<!doctype html>
<html>
<head>
    <script type="text/javascript" src="https://unpkg.com/[email protected]/dist/rapidoc-min.js" charset="UTF-8"></script>
</head>
<body>
<rapi-doc render-style="read" schema-style="table" default-schema-tab="schema"></rapi-doc>
<script>
    document.addEventListener('DOMContentLoaded', (event) => {
        let docEl = document.querySelector('rapi-doc');
        let objSpec = {
            "openapi": "3.0.3",
            "info": {
                "title": "",
                "version": "0.0.1"
            },
            "servers": [{
                "url": "https://localhost:8080"
            }],
            "tags": [{
                "name": "test"
            }],
            "paths": {
                "/test": {
                    "post": {
                        "tags": [
                            "test"
                        ],
                        "summary": "Test",
                        "description": "",
                        "operationId": "test",
                        "requestBody": {
                            "content": {
                                "application/x-www-form-urlencoded": {
                                    "schema": { "$ref": "#/components/schemas/obj" }
                                },
                                "application/json": {
                                    "schema": { "$ref": "#/components/schemas/obj" }
                                }
                            }
                        },
                        "responses": {
                            "200": {
                                "description": "",
                                "content": {
                                    "application/json": {
                                        "schema": { "$ref": "#/components/schemas/obj" },
                                        "example": {}
                                    }
                                }
                            }
                        }
                    }

                }
            },
            "components": {
                "schemas": {
                    "obj": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "super": {
                                "type": "object",
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "stuff": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                },
                                "required": [ "id" ],
                                "additionalProperties": false
                            }
                        },
                        "required": [ "id", "super" ],
                        "additionalProperties": false
                    }
                },
                "responses": {},
                "parameters": {}
            }
        };
        docEl.loadSpec(objSpec);
    });
</script>
</body>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions