-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
[Question]: Why I cant see in swagger properties from model? #2301
Comments
can you share the generated json |
@DjordyKoert thx for response following nelmio dump output {
"openapi": "3.0.0",
"info": {
"title": "Test App",
"description": "This is test app api",
"version": "1.0.0"
},
"paths": {
"/api/test": {
"post": {
"tags": [
"test"
],
"summary": "Test summary",
"description": "Test description",
"operationId": "post_app_test",
"requestBody": {
"description": "User login credentials",
"content": {
"application/json": {
"schema": {
"properties": {
"test": {
"type": "string"
}
},
"type": "object"
}
}
}
},
"responses": {
"200": {
"description": "Test success response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TestModel"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"TestModel": {
"type": "object"
}
}
}
} See, at the bottom TestModel is empty, no fields descriptions :( Even when I'm making syntax errors in #[OA\Problablabla(type: 'string', maxLength: 255)]. What could it be? |
Hmm not sure.
|
Nope, nothing changed...:( |
Interesting bug, because I have the same problem, but only with private and protected properties. When I change the visibility of the property to public, it shows up in the swagger interface. DTO: namespace App\Controller;
use OpenApi\Attributes as SWG;
final class TestDto
{
public function __construct(
#[SWG\Property(type: 'integer', example: 12)]
private int $age
)
{
}
} Controller: namespace App\Controller;
use Nelmio\ApiDocBundle\Annotation\Model;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Attribute\Route;
use OpenApi\Attributes as SWG;
final class TestController extends AbstractController
{
#[SWG\Response(
response: 200,
description: 'Returns all available countries',
content: new Model(type: TestDto::class),
)]
#[Route('/api/test', name: 'test')]
public function index()
{
}
} JSON-OUTPUT: {
"openapi": "3.0.0",
"info": {
"title": "My App",
"description": "This is an awesome app!",
"version": "0.1.0"
},
"paths": {
"/api/test": {
"get": {
"operationId": "get_test",
"responses": {
"200": {
"description": "Returns all available countries",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TestDto"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"TestDto": {
"type": "object"
}
}
},
"tags": [
{
"name": "Location",
"description": "Location"
}
]
} PHP 8.2 Do you have any ideas on how I can solve the problem? |
Version
4.27.0
Question
Hi!
Cant get this to work so much time. I'm feeling the truth is somewhere nearby
Simple example, test controller, and test model. But I cant see properties on the response in swagger, its like it doesnt see attributes on the model property. I must to point NelmioApiDocBundle path where are all my classes with attributes in some way?
Will be grateful for any help, thx
Additional context
No response
The text was updated successfully, but these errors were encountered: