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
Really love this package by the way!
I've been having some issues recently where I have been trying to use the OpenAPI schema generated by scribe for codegeneration clientside. The main issue is that I can't seem to find a way to make it generate a schema that respects that response fields are required in the output (i.e. not nullable/undefined). Essentially, I have this resource
classTelemetryResourceextendsJsonResource
{
/** * Transform the resource into an array. * * @responseField latitude float required Telemetry latitude * @responseField longitude float required Telemetry Longitude * @responseField heading int required Magnetic Heading * @responseField source string Data source Example: VATSIM * @responseField next_update string DateTime of next expected data update * * @param \Illuminate\Http\Request $request * @return array */publicfunctiontoArray($request)
{
return [
'latitude' => $this->latitude,
'longitude' => $this->longitude,
'heading' => $this->heading,
'source' => $this->source ? $this->source->description : null,
'next_update' => $this->expectedNextUpdate(),
];
}
}
being returned from this endpoint
/** * User Telemetry * * Access OAuth user's flight simulator telemetry, if any is available. Requies the oauth:telemetry:view scope * * @apiResource App\Http\Resources\User\TelemetryResource * * @response status=404 scenario="no telemetry available" {"message": "No telemetry currently available for this user"} * * @apiResourceModel App\Models\User\Telemetry */publicfunctiontelemetry(Request$request)
{
$telemetry = $request->user()->activeTelemetry();
return$telemetry ? TelemetryResource::make($request->user()->activeTelemetry()) : abort(404, 'No telemetry currently available for this user');
}
This gives a nominal response type that looks like:
Scribe version
4.19.0
Your question
Hello,
Really love this package by the way!
I've been having some issues recently where I have been trying to use the OpenAPI schema generated by scribe for codegeneration clientside. The main issue is that I can't seem to find a way to make it generate a schema that respects that response fields are required in the output (i.e. not nullable/undefined). Essentially, I have this resource
being returned from this endpoint
This gives a nominal response type that looks like:
However, inside the OpenAPI schema generated by Scribe, the inner properties of the
data
object does not include the necessaryrequired
entry.Current OpenAPI Schema
Expected OpenAPI Schema
Am I missing something or is this not possible? I've trawled through the docs and can't seem to find a way to do this. Thanks!
Docs
The text was updated successfully, but these errors were encountered: