Scribe version
5.4.0
PHP version
8.4
Laravel version
12.35.0
Scribe config
What happened?
Currently the OpenAPI generation ignores the nullable parameter for ResponseFields. (which is valid for OpenAPI 3.0)
After digging the sources a naive "fix" would be:
- Add
public $nullable; to camel/Extraction/ResponseField.php
- Under
generateSchemaForResponseValue() in src/Writing/OpenApiSpecGenerators/BaseGenerator.php add
L568
$this->setDescription($schema, $endpoint, $path);
//either it's explicitly nullable or the value is null (don't know if this is legit?)
if ((isset($endpoint->responseFields[$path]->nullable) && $endpoint->responseFields[$path]->nullable) || $value === null) {
$schema['nullable'] = true;
}
However I also stumbled over you comment here https://scribe.knuckles.wtf/laravel/migrating#more-configurable-openapi-generation - would it be possible and do you recommend to use this approach to add the nullable parameter to responseField? Or do you prefer an enhancement like the above code?
Docs
Scribe version
5.4.0
PHP version
8.4
Laravel version
12.35.0
Scribe config
What happened?
Currently the OpenAPI generation ignores the
nullableparameter for ResponseFields. (which is valid for OpenAPI 3.0)After digging the sources a naive "fix" would be:
public $nullable;tocamel/Extraction/ResponseField.phpgenerateSchemaForResponseValue()insrc/Writing/OpenApiSpecGenerators/BaseGenerator.phpaddL568
However I also stumbled over you comment here https://scribe.knuckles.wtf/laravel/migrating#more-configurable-openapi-generation - would it be possible and do you recommend to use this approach to add the nullable parameter to responseField? Or do you prefer an enhancement like the above code?
Docs