Skip to content

Class is not generated #8

@gigi

Description

@gigi

Hi again!
One more unexpected behavior. Can you help, пожалуйста?)

allOf.json

{
  "$id": "allOf.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "description": "All of data",
  "allOf": [
    {
      "$ref": "ref.json"
    },
    {
      "required": ["field1"]
    }
  ]
}

ref.json

{
  "$id": "ref.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "description": "Ref data",
  "properties": {
    "field1": {
      "type": "object",
      "properties": {
        "field1_sub": {
          "type": "string"
        }
      },
      "required": ["field1_sub"]
    }
  }
}
public function testGenerateAllOf()
{
        $appPath = realpath(__DIR__ . '/../../Tmp') . '/Issue8';
        $appNs = 'Swaggest\PhpCodeBuilder\Tests\Tmp\\Issue8';

        $app = new PhpApp();
        $app->setNamespaceRoot($appNs, '.');

        $schema = Schema::import(__DIR__ . '/../../../resources/allOf.json');
  
        $builder = new PhpBuilder();
        $builder->buildSetters = false;
        $builder->makeEnumConstants = true;

        $builder->classCreatedHook = new ClassHookCallback(
            function (PhpClass $class, $path, $schema) use ($app, $appNs) {
                $class->setNamespace($appNs);
                if ('#' === $path) {
                    $class->setName('Sample'); // Class name for root schema
                }
                $app->addClass($class);
            }
        );


        $builder->getType($schema);

        $app->clearOldFiles($appPath);
        $app->store($appPath);
}

I expect 3 generated classes: RefJson.php, RefJsonField1.php and AllOf.php. But there is only two: RefJson.php and RefJsonField1.php

Maybe something missed in the schemas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions