Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] [php-nextgen] Nullable mixed type is not allowed #20354

Closed
5 of 6 tasks
lucajung opened this issue Dec 19, 2024 · 1 comment
Closed
5 of 6 tasks

[BUG] [php-nextgen] Nullable mixed type is not allowed #20354

lucajung opened this issue Dec 19, 2024 · 1 comment

Comments

@lucajung
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The generated client has an optional mixed type. Mixed already contains null values.
PHP Fatal error: Type mixed cannot be marked as nullable since mixed already includes null

/**
 * Operation setValue
 *
 * @param  mixed|null $body body (optional)
 * 
 * @throws ApiException
 * @return ApiResult
 */
public function setValue(?mixed $body = null): ApiResult
{
  list($response) = $this->setValueWithHttpInfo($body);
  return $response;
}
openapi-generator version

7.10.0

OpenAPI declaration
"/api/value": {
    "post": {
        "tags": [
            "Value"
        ],
        "operationId": "SetValue",
        "parameters": [],
        "requestBody": {
            "content": {
                "application/json": {
                    "schema": {}
                }
            }
        },
        "responses": {
            "200": {
                "description": "OK",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/ApiResponse"
                        }
                    },
                }
            },
            "401": {
                "description": "Unauthorized"
            },
            "403": {
                "description": "Forbidden"
            }
        },
        "security": [
            {
                "apiKey": [
                    "Key"
                ],
            }
        ]
    }
},
Generation Details
  • x
Steps to reproduce

Create the PHP API client with optional POST body

Related issues/PRs
  • x
Suggest a fix

Remove the ? if the type is mixed.

@lucajung
Copy link
Author

It has been found that this is only the case if the endpoint does not accept valid JSON. In this case, simply “string”. Nevertheless, the generator should be able to generate error-free php code.

JulianVennen added a commit to JulianVennen/openapi-generator that referenced this issue Dec 20, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant