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

Example is not using factory #854

Open
1 task done
piovezanfernando opened this issue May 15, 2024 · 1 comment
Open
1 task done

Example is not using factory #854

piovezanfernando opened this issue May 15, 2024 · 1 comment
Labels

Comments

@piovezanfernando
Copy link

Scribe version

4.35.0

Your question

I'm using scribe with the same settings I used previously, but it's not using the factories when generating the examples.

Scribe version
4.35.0

PHP version
8.3.6

Framework
Laravel

Framework version
v11.4.0

title => "Documenta\u00e7\u00e3o da API"
base_url => "http://localhost"
type => "laravel"
strategies.urlParameters => added Knuckles\Scribe\Extracting\Strategies\UrlParameters\GetFromLumenAPI
strategies.queryParameters => added App\Docs\Strategies\AddParams
strategies.headers => added Knuckles\Scribe\Extracting\Strategies\Headers\GetFromRouteRules: removed [
    'override',
    [
        'Content-Type' => 'application/json',
        'Accept' => 'application/json',
    ],
]
strategies.responses => added Knuckles\Scribe\Extracting\Strategies\Responses\ResponseCalls: removed [
    'Knuckles\\Scribe\\Extracting\\Strategies\\Responses\\ResponseCalls',
    [
        'only' => [
            'GET *',
        ],
    ],
]
database_connections_to_transact.0 => null

Factory File

return [
            'name'                 => $this->faker->name,
            'description'          => $this->faker->text($this->faker->numberBetween(5, 300)),
            'phone_number'         => $this->faker->numerify('0##########'),
            'visible_contact_page' => $this->faker->boolean,
            'phone_category_id'    => $phoneCategoryId,
            'company_id'           => $company->id,
            'is_active'            => $this->faker->boolean,
        ];

Example generated

        [
            'name' => 'pbbxqpnycjv',
            'description' => 'Nostrum sunt sequi adipisci nulla et explicabo magni.',
            'phone_number' => 'jzlrzwotnkiyoboepadcb',
            'visible_contact_page' => true,
            'phone_category_id' => 'aut',
            'is_active' => false,
        ]

I tried to find in the code where the problem could be and the only strange thing I found was that InstantiatesExampleModels is not accessed on any endpoint and UseResponseAttributes.extractFromAttributes all parameters are blank.

Docs

@shalvah
Copy link
Contributor

shalvah commented May 27, 2024

Are you sure this is right? Your factory is for a model, but the example generated looks like Scribe generated values for individual fields. If they are individual fields on the request, a factory probably won't be used.

@shalvah shalvah removed the triage label May 27, 2024
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