Skip to content

Multipart section with '$ref' showing as required even when it's not #1139

@bart-acc

Description

@bart-acc

When loading the following reproducer in RapiDoc

{
    "openapi": "3.1.0",
    "info": {
        "title": "minimal example",
        "description": "of a section not being required but rendering as if it was",
        "license": {
            "name": "Proprietary"
        },
        "version": "0.0.1"
    },
    "paths": {
		"/minimal_json": {
            "post": {
                "tags": ["example"],
                "summary": "example of the problem",
                "description": "the not required field shows as if it's required",
                "operationId": "with_presentation_value",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/MinimalRequest"
                            }
                        }
                    },
                    "required": true
                }
            }
        },
        "/minimal_multipart": {
            "post": {
                "tags": ["example"],
                "summary": "example of the problem",
                "description": "the not required field shows as if it's required",
                "operationId": "with_presentation_value",
                "requestBody": {
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "$ref": "#/components/schemas/MinimalRequest"
                            }
                        }
                    },
                    "required": true
                }
            }
        }
    },
    "components": {
        "schemas": {
            "MinimalRequest": {
                "type": "object",
                "required": ["section_1_1","section_2_1"],
                "properties": {
                    "section_1_1": {
                        "type": "string",
                        "description": "required"
                    },
					"section_1_2": {
                        "type": "string",
                        "description": "not required"
                    },
                    "section_2_1": {
                        "$ref": "#/components/schemas/MinimalRequestOptions",
                        "description": "required"
                    },
					"section_2_2": {
                        "$ref": "#/components/schemas/MinimalRequestOptions",
                        "description": "not required"
                    }
                }
            },
            "MinimalRequestOptions": {
                "type": "object",
                "required": ["member_1"],
                "properties": {
                    "member_1": {
                        "type": "boolean",
                        "description": "a bool, required"
                    },
					"member_2": {
                        "type": "boolean",
                        "description": "another bool, not required"
                    }
                }
            }
        }
    }
}

When looking at the schema of /minimal_json everything is correctly rendered as required or not. However when looking at /minimal_multipart section_2_2 is shown as required (the red star/* next to its name) while it's clearly not marked as such in the api description json.

Image

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