openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[php] Question on schema->class Name

Open MR4online opened this issue 8 months ago • 0 comments

Hi there,

My OpenAPI schema looks like this:

...
      "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/_default"
                }
              }
            }
          },
....
  "components": {
    "schemas": {
      "_default": {
        "type": "object",
        "title": "DefaultResponse",
        "properties": {
          "msg": {
            "type": "string",
            "description": "Message to return on routes, without response data",
            "example": "done"
          }
        }
      },
...

Which results in invalid PHP Code:

class Default implements ModelInterface, ArrayAccess, \JsonSerializable
{
....
    protected static $openAPIModelName = '_default';
...

Of course "default" is reserved in PHP, but my actual Schema is not called "default". Is there a way to use the title "DefaultResponse" as Class-Name?

Thanks a lot!

MR4online avatar Jun 05 '25 11:06 MR4online