Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Get and modify existing Schema #1666

Open
Kiina opened this issue Oct 15, 2024 · 0 comments
Open

Get and modify existing Schema #1666

Kiina opened this issue Oct 15, 2024 · 0 comments
Labels

Comments

@Kiina
Copy link
Contributor

Kiina commented Oct 15, 2024

I have a class like this:

#[OA\Schema]
class Request{
    #[OA\Property]
    private int $code;
    #[OA\Property]
    private string $message;
    /**
     * @var JsonSerializable|array<string, mixed>|null
     */
    #[OA\Property]
    private JsonSerializable|array|null $payload;
}

Now I've written a processor that generates other schemas and I have a reflection class on the Request class.
Is there any way to get the schema for a corresponding class and change a property to insert a reference to another schema I've generated?

I tried using

$analysis->getSchemaForSource($namespace . $arg->value->class->name);

But the resulting Schema seems empty except for the line in which the class starts:

object(OpenApi\Attributes\Schema)#20252 (2) {
  ["_context"]=>
  object(OpenApi\Context)#20228 (1) {
    ["-"]=>
    string(84) "/composer/Payload/Request.php on line 16"
  }
  ["_unmerged"]=>
  array(0) {
  }
}

(btw that JsonSerializable part seems to kinda break generation, the output is:

payload:
  description: mixed>|null

)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants