You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a Schema is created inside of the ResponseFactory it's in included in the generated document.
However, when a a Schema is created and implements Reusable, generated document adds a reference to it, but doesn't generate the actual code.
Code
// ValidResponse.phpuseGoldSpecDigital\ObjectOrientedOAS\Objects\MediaType;
useGoldSpecDigital\ObjectOrientedOAS\Objects\Response;
useVyuldashev\LaravelOpenApi\Factories\ResponseFactory;
useApp\Modules\Clients\OpenApi\Schemas\ClientSchema;
class ValidResponse extends ResponseFactory {
publicfunctionbuild(): Response {
return Response::ok()
->description('User is logged and cookie was decrypted')
->content(MediaType::json()->schema(ClientSchema::ref()));
}
}
// ClientSchema.phpuseGoldSpecDigital\ObjectOrientedOAS\Contracts\SchemaContract;
useGoldSpecDigital\ObjectOrientedOAS\Objects\Schema;
useVyuldashev\LaravelOpenApi\Contracts\Reusable;
useVyuldashev\LaravelOpenApi\Factories\SchemaFactory;
class ClientSchema extends SchemaFactory implements Reusable {
/** * @return Schema */publicfunctionbuild(): SchemaContract {
return Schema::object('Client')->properties(
Schema::string('id')->default(0),
Schema::string('name')->default('NULL'),
);
}
}
// ClientController.php
#[OpenApi\PathItem]
class ClientController extends Controller {
/** * Get the current authenticated user. */
#[OpenApi\Operation]
#[
OpenApi\Response(
factory: ValidResponse::class,
statusCode: HTTPResponse::HTTP_OK,
),
]
publicfunctionme(Request$request): Client {
return$request->user();
}
}
Result
{
"openapi": "3.0.2",
"info": {
"title": "My API",
"version": "1.0.0"
},
"servers": [
{
"url": "http://localhost"
}
],
"paths": {
"/users/me": {
"get": {
"summary": "Get the current authenticated user.",
"responses": {
"204": {
"description": "User is not authenticated or invalid cookie"
},
"200": {
"description": "User is logged",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Client"
}
}
}
}
}
}
}
}
}
The text was updated successfully, but these errors were encountered:
When a Schema is created inside of the
ResponseFactory
it's in included in the generated document.However, when a a Schema is created and implements
Reusable
, generated document adds a reference to it, but doesn't generate the actual code.Code
Result
The text was updated successfully, but these errors were encountered: