knuckleswtf / knuckleswtf/scribe

Example is not using factory

Open
#854 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
PHP
Stars
2.3k
Forks
357
PR merge metrics
No merged PRs in 30d

Description

### 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

- [X] I've checked [the docs](https://scribe.knuckles.wtf/laravel), the [troubleshooting guide](https://scribe.knuckles.wtf/laravel/troubleshooting), and [existing issues](https://github.com/knuckleswtf/scribe/issues?q=is%3Aissue+), but I didn't find a solution

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the example generation with the reported Laravel 11.4.0 configuration, then trace the paths involving InstantiatesExampleModels and UseResponseAttributes. Compare the generated example with the factory file and determine why the factory-derived values are not being used; done means the reported model attributes are generated from the factory.

Written by the indexing model from the issue text.

Assessment

Tech stack
laravel, php
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.