How can I return an object?

Created on 15 November 2023, about 1 year ago

Problem/Motivation

I'm trying to return a complicated object via JSON:RPC and I'm getting an error.

My code looks like this (simplified):

  public function execute(ParameterBag $params) {
    $public_key_credential_creation_options = PublicKeyCredentialCreationOptions::create(
      $rp_entity,
      $user_entity,
      $challenge,
      [],
    return $public_key_credential_creation_options;
  }

  public static function outputSchema(): array {
    return ['type' => 'object'];
  }

And I'm getting this error:

Error: Cannot modify readonly property Webauthn\PublicKeyCredentialOptions::$challenge in JsonSchema\Constraints\ObjectConstraint->getProperty() (line 164 of /var/www/html/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.php).

I don't think that's the root error. If I return a string (return json_encode($public_key_credential_creation_options);), then I get the object returned as a string. But how can I return the object as a JSON object?

Do I need to provide a full schema in outputSchema()?

💬 Support request
Status

Active

Version

2.0

Component

Documentation

Created by

🇯🇵Japan ptmkenny

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024