Make WordPress Core

Ticket #38583: 38583.2.diff

File 38583.2.diff, 26.8 KB (added by TimothyBlynJacobs, 7 years ago)
  • src/wp-includes/rest-api.php

    diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
    index 06bb9f9..df4c9bc 100644
    a b function rest_get_avatar_sizes() { 
    10361036 * @return true|WP_Error
    10371037 */
    10381038function rest_validate_value_from_schema( $value, $args, $param = '' ) {
     1039
     1040        if ( $args === true ) {
     1041                return true;
     1042        }
     1043
     1044        if ( $args === false ) {
     1045                return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not allowed.' ), $param ) );
     1046        }
     1047
     1048        if ( is_array( $args['type'] ) ) {
     1049                $is_valid = false;
     1050
     1051                foreach ( $args['type'] as $type ) {
     1052                        $single_typed = $args;
     1053                        $single_typed['type'] = $type;
     1054
     1055                        $is_valid = rest_validate_value_from_schema( $value, $single_typed, $param );
     1056
     1057                        if ( $is_valid === true ) {
     1058                                return true;
     1059                        }
     1060                }
     1061
     1062                if ( false === $is_valid || is_wp_error( $is_valid ) ) {
     1063                        /* translators: %s: parameter, %l: list of types */
     1064                        return new WP_Error( 'rest_invalid_param', wp_sprintf( __( '%s is not of type %l.' ), $param, $args['type'] ) );
     1065                }
     1066        }
     1067
    10391068        if ( 'array' === $args['type'] ) {
    10401069                if ( ! is_array( $value ) ) {
    10411070                        $value = preg_split( '/[\s,]+/', $value );
    function rest_validate_value_from_schema( $value, $args, $param = '' ) { 
    10511080                        }
    10521081                }
    10531082        }
     1083
     1084        if ( 'object' === $args['type'] ) {
     1085                if ( ! is_array( $value ) ) {
     1086                        /* translators: 1: parameter, 2: type name */
     1087                        return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'object' ) );
     1088                }
     1089
     1090                // How to validate properties that are not registered.
     1091                $additional = isset( $args['additionalProperties'] ) ? $args['additionalProperties'] : true;
     1092
     1093                foreach ( $value as $property => $v ) {
     1094
     1095                        $validate = isset( $args['properties'][ $property ] ) ? $args['properties'][ $property ] : $additional;
     1096                        $is_valid = rest_validate_value_from_schema( $v, $validate, $param . '[' . $property . ']' );
     1097
     1098                        if ( is_wp_error( $is_valid ) ) {
     1099                                return $is_valid;
     1100                        }
     1101                }
     1102        }
     1103
    10541104        if ( ! empty( $args['enum'] ) ) {
    10551105                if ( ! in_array( $value, $args['enum'], true ) ) {
    10561106                        /* translators: 1: parameter, 2: list of valid values */
    function rest_validate_value_from_schema( $value, $args, $param = '' ) { 
    11521202 *
    11531203 * @param mixed $value The value to sanitize.
    11541204 * @param array $args  Schema array to use for sanitization.
    1155  * @return true|WP_Error
     1205 * @return mixed The sanitized value.
    11561206 */
    11571207function rest_sanitize_value_from_schema( $value, $args ) {
     1208
     1209        if ( is_array( $args['type'] ) ) {
     1210
     1211                $changed = $same = array();
     1212                $empty = null;
     1213
     1214                foreach ( $args['type'] as $type ) {
     1215                        $single_typed = $args;
     1216                        $single_typed['type'] = $type;
     1217
     1218                        $sanitized = rest_sanitize_value_from_schema( $value, $single_typed );
     1219
     1220                        if ( empty( $sanitized ) && ! is_bool( $sanitized ) ) {
     1221                                if ( $empty === null ) {
     1222                                        $empty = $sanitized;
     1223                                }
     1224                        } elseif ( $sanitized !== $value ) {
     1225                                $changed[] = $sanitized;
     1226                        } else {
     1227                                return $sanitized;
     1228                        }
     1229                }
     1230
     1231                if ( $changed ) {
     1232                        return $changed[0];
     1233                }
     1234
     1235                return $empty;
     1236        }
     1237
    11581238        if ( 'array' === $args['type'] ) {
    11591239                if ( empty( $args['items'] ) ) {
    11601240                        return (array) $value;
    function rest_sanitize_value_from_schema( $value, $args ) { 
    11701250                $value = array_values( $value );
    11711251                return $value;
    11721252        }
     1253
     1254        if ( 'object' === $args['type'] ) {
     1255                if ( ! is_array( $value ) ) {
     1256                        return array();
     1257                }
     1258
     1259                // How to sanitize properties that are not registered.
     1260                $additional = isset( $args['additionalProperties'] ) ? $args['additionalProperties'] : true;
     1261
     1262                foreach ( $value as $property => $v ) {
     1263                        $sanitize = isset( $args['properties'][ $property ] ) ? $args['properties'][ $property ] : $additional;
     1264                        $value[ $property ] = is_bool( $sanitize ) ? $v : rest_sanitize_value_from_schema( $v, $sanitize );
     1265                }
     1266
     1267                return $value;
     1268        }
     1269
    11731270        if ( 'integer' === $args['type'] ) {
    11741271                return (int) $value;
    11751272        }
    function rest_sanitize_value_from_schema( $value, $args ) { 
    12021299        }
    12031300
    12041301        if ( 'string' === $args['type'] ) {
    1205                 return strval( $value );
     1302                return is_scalar( $value ) ? (string) $value : '';
    12061303        }
    12071304
    12081305        return $value;
  • src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
    index 76802fe..f24103d 100644
    a b class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    387387
    388388                $schema['properties']['caption'] = array(
    389389                        'description' => __( 'The attachment caption.' ),
    390                         'type'        => 'object',
     390                        'type'        => array( 'object', 'string' ),
    391391                        'context'     => array( 'view', 'edit', 'embed' ),
    392392                        'arg_options' => array(
    393393                                'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database()
    class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    409409
    410410                $schema['properties']['description'] = array(
    411411                        'description' => __( 'The attachment description.' ),
    412                         'type'        => 'object',
     412                        'type'        => array( 'object', 'string' ),
    413413                        'context'     => array( 'view', 'edit' ),
    414414                        'arg_options' => array(
    415415                                'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database()
  • src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
    index e91fce2..0ea97b3 100644
    a b class WP_REST_Comments_Controller extends WP_REST_Controller { 
    11951195                                ),
    11961196                                'content'          => array(
    11971197                                        'description'     => __( 'The content for the object.' ),
    1198                                         'type'            => 'object',
     1198                                        'type'            => array( 'object', 'string' ),
    11991199                                        'context'         => array( 'view', 'edit', 'embed' ),
    12001200                                        'arg_options'     => array(
    12011201                                                'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database()
  • src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php
    index e04193a..dbc3da3 100644
    a b abstract class WP_REST_Controller { 
    236236                                continue;
    237237                        }
    238238
    239                         if ( 'object' === $schema['properties'][ $key ]['type'] && ! empty( $schema['properties'][ $key ]['properties'] ) ) {
     239                        $type = (array) $schema['properties'][ $key ]['type'];
     240
     241                        if ( in_array( 'object', $type, true ) && ! empty( $schema['properties'][ $key ]['properties'] ) ) {
    240242                                foreach ( $schema['properties'][ $key ]['properties'] as $attribute => $details ) {
    241243                                        if ( empty( $details['context'] ) ) {
    242244                                                continue;
  • src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
    index f9de736..4780505 100644
    a b class WP_REST_Posts_Controller extends WP_REST_Controller { 
    18411841                                case 'title':
    18421842                                        $schema['properties']['title'] = array(
    18431843                                                'description' => __( 'The title for the object.' ),
    1844                                                 'type'        => 'object',
     1844                                                'type'        => array( 'object', 'string' ),
    18451845                                                'context'     => array( 'view', 'edit', 'embed' ),
    18461846                                                'arg_options' => array(
    18471847                                                        'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database()
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    18651865                                case 'editor':
    18661866                                        $schema['properties']['content'] = array(
    18671867                                                'description' => __( 'The content for the object.' ),
    1868                                                 'type'        => 'object',
     1868                                                'type'        => array( 'object', 'string' ),
    18691869                                                'context'     => array( 'view', 'edit' ),
    18701870                                                'arg_options' => array(
    18711871                                                        'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database()
    class WP_REST_Posts_Controller extends WP_REST_Controller { 
    19031903                                case 'excerpt':
    19041904                                        $schema['properties']['excerpt'] = array(
    19051905                                                'description' => __( 'The excerpt for the object.' ),
    1906                                                 'type'        => 'object',
     1906                                                'type'        => array( 'object', 'string' ),
    19071907                                                'context'     => array( 'view', 'edit', 'embed' ),
    19081908                                                'arg_options' => array(
    19091909                                                        'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database()
  • tests/phpunit/tests/rest-api/rest-schema-sanitization.php

    diff --git a/tests/phpunit/tests/rest-api/rest-schema-sanitization.php b/tests/phpunit/tests/rest-api/rest-schema-sanitization.php
    index e1ae29d..da6d2a4 100644
    a b class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { 
    146146                $this->assertEquals( array( '1', '2' ), rest_sanitize_value_from_schema( array( 'first' => '1', 'second' => '2' ), $schema ) );
    147147        }
    148148
     149        public function test_type_object() {
     150                $schema = array(
     151                        'type'       => 'object',
     152                        'properties' => array(
     153                                'a' => array(
     154                                        'type' => 'number'
     155                                ),
     156                        ),
     157                );
     158                $this->assertEquals( array( 'a' => 1 ), rest_sanitize_value_from_schema( array( 'a' => 1 ), $schema ) );
     159                $this->assertEquals( array( 'a' => 1 ), rest_sanitize_value_from_schema( array( 'a' => '1' ), $schema ) );
     160        }
     161
     162        public function test_type_object_additionalProperties_not_set() {
     163                $schema = array(
     164                        'type'       => 'object',
     165                        'properties' => array(
     166                                'a' => array(
     167                                        'type' => 'number'
     168                                ),
     169                        ),
     170                );
     171                $this->assertEquals( array( 'a' => 1 ), rest_sanitize_value_from_schema( array( 'a' => 1 ), $schema ) );
     172                $this->assertEquals( array( 'b' => '1' ), rest_sanitize_value_from_schema( array( 'b' => '1' ), $schema ) );
     173        }
     174
     175        public function test_type_object_additionalProperties_true() {
     176                $schema = array(
     177                        'type'       => 'object',
     178                        'properties' => array(
     179                                'a' => array(
     180                                        'type' => 'number'
     181                                ),
     182                        ),
     183                        'additionalProperties' => true,
     184                );
     185                $this->assertEquals( array( 'a' => 1 ), rest_sanitize_value_from_schema( array( 'a' => 1 ), $schema ) );
     186                $this->assertEquals( array( 'b' => '1' ), rest_sanitize_value_from_schema( array( 'b' => '1' ), $schema ) );
     187        }
     188
     189        public function test_type_object_additionalProperties_false() {
     190                $schema = array(
     191                        'type'       => 'object',
     192                        'properties' => array(
     193                                'a' => array(
     194                                        'type' => 'number'
     195                                ),
     196                        ),
     197                        'additionalProperties' => false,
     198                );
     199                $this->assertEquals( array( 'a' => 1 ), rest_sanitize_value_from_schema( array( 'a' => 1 ), $schema ) );
     200                $this->assertEquals( array( 'b' => '1' ), rest_sanitize_value_from_schema( array( 'b' => '1' ), $schema ) );
     201        }
     202
     203        public function test_type_object_additionalProperties_schema() {
     204                $schema = array(
     205                        'type'       => 'object',
     206                        'properties' => array(
     207                                'a' => array(
     208                                        'type' => 'number'
     209                                ),
     210                        ),
     211                        'additionalProperties' => array(
     212                                'type' => 'boolean'
     213                        ),
     214                );
     215                $this->assertEquals( array( 'a' => 1 ), rest_sanitize_value_from_schema( array( 'a' => 1 ), $schema ) );
     216                $this->assertEquals( array( 'b' => true ), rest_sanitize_value_from_schema( array( 'b' => '1' ), $schema ) );
     217                $this->assertEquals( array( 'b' => true ), rest_sanitize_value_from_schema( array( 'b' => true ), $schema ) );
     218                $this->assertEquals( array( 'b' => false ), rest_sanitize_value_from_schema( array( 'b' => 'false' ), $schema ) );
     219        }
     220
     221        public function test_type_object_nested() {
     222                $schema = array(
     223                        'type' => 'object',
     224                        'properties' => array(
     225                                'a' => array(
     226                                        'type'  => 'object',
     227                                        'properties' => array(
     228                                                'b' => array( 'type' => 'number' ),
     229                                                'c' => array( 'type' => 'number' ),
     230                                        )
     231                                )
     232                        ),
     233                );
     234
     235                $this->assertEquals(
     236                        array( 'a' => array( 'b' => 1, 'c' => 3 ) ),
     237                        rest_sanitize_value_from_schema( array( 'a' => array( 'b' => '1', 'c' => '3' ) ), $schema )
     238                );
     239                $this->assertEquals(
     240                        array( 'a' => array( 'b' => 1, 'c' => 3, 'd' => '1' ), 'b' => '1' ),
     241                        rest_sanitize_value_from_schema( array( 'a' => array( 'b' => '1', 'c' => '3', 'd' => '1' ), 'b' => 1 ), $schema )
     242                );
     243                $this->assertEquals( array( 'a' => array() ), rest_sanitize_value_from_schema( array( 'a' => null ), $schema ) );
     244        }
     245
     246        public function test_multiple_types() {
     247                $schema = array(
     248                        'type' => array( 'object', 'string' )
     249                );
     250                $this->assertEquals( 'The content', rest_sanitize_value_from_schema( 'The content', $schema ) );
     251
     252                $object = array( 'raw' => 'The content', 'rendered' => 'The rendered content' );
     253                $this->assertEquals( $object, rest_sanitize_value_from_schema( $object, $schema ) );
     254        }
     255
     256        public function test_multiple_types_applies_sanitization() {
     257                $schema = array(
     258                        'type' => array( 'object', 'boolean' )
     259                );
     260                $this->assertEquals( false, rest_sanitize_value_from_schema( 'false', $schema ) );
     261
     262                $object = array( 'prop' => 'false' );
     263                $this->assertEquals( $object, rest_sanitize_value_from_schema( $object, $schema ) );
     264        }
     265
     266        public function test_multiple_types_empty() {
     267                $this->assertEquals( array(), rest_sanitize_value_from_schema( null, array( 'type' => array( 'object', 'string' ) ) ) );
     268                $this->assertEquals( '', rest_sanitize_value_from_schema( null, array( 'type' => array( 'string', 'object' ) ) ) );
     269        }
     270
     271        public function test_multiple_types_prefers_data_without_change() {
     272                $schema = array(
     273                        'type' => array( 'number', 'string' )
     274                );
     275                $this->assertEquals( '1', rest_sanitize_value_from_schema( '1', $schema ) );
     276        }
     277
    149278        public function test_type_unknown() {
    150279                $schema = array(
    151280                        'type' => 'lalala',
  • tests/phpunit/tests/rest-api/rest-schema-validation.php

    diff --git a/tests/phpunit/tests/rest-api/rest-schema-validation.php b/tests/phpunit/tests/rest-api/rest-schema-validation.php
    index 82f58e5..e610592 100644
    a b class WP_Test_REST_Schema_Validation extends WP_UnitTestCase { 
    181181                $this->assertWPError( rest_validate_value_from_schema( array( 'first' => '1', 'second' => '2' ), $schema ) );
    182182        }
    183183
     184        public function test_type_object() {
     185                $schema = array(
     186                        'type'       => 'object',
     187                        'properties' => array(
     188                                'a' => array(
     189                                        'type' => 'number'
     190                                ),
     191                        ),
     192                );
     193                $this->assertTrue( rest_validate_value_from_schema( array( 'a' => 1 ), $schema ) );
     194                $this->assertWPError( rest_validate_value_from_schema( array( 'a' => 'invalid' ), $schema ) );
     195        }
     196
     197        public function test_type_object_additionalProperties_not_set() {
     198                $schema = array(
     199                        'type'       => 'object',
     200                        'properties' => array(
     201                                'a' => array(
     202                                        'type' => 'number'
     203                                ),
     204                        ),
     205                );
     206                $this->assertTrue( rest_validate_value_from_schema( array( 'b' => 1 ), $schema ) );
     207        }
     208
     209        public function test_type_object_additionalProperties_true() {
     210                $schema = array(
     211                        'type'       => 'object',
     212                        'properties' => array(
     213                                'a' => array(
     214                                        'type' => 'number'
     215                                ),
     216                        ),
     217                        'additionalProperties' => true,
     218                );
     219                $this->assertTrue( rest_validate_value_from_schema( array( 'a' => 1 ), $schema ) );
     220                $this->assertTrue( rest_validate_value_from_schema( array( 'b' => 1 ), $schema ) );
     221        }
     222
     223        public function test_type_object_additionalProperties_false() {
     224                $schema = array(
     225                        'type'       => 'object',
     226                        'properties' => array(
     227                                'a' => array(
     228                                        'type' => 'number'
     229                                ),
     230                        ),
     231                        'additionalProperties' => false,
     232                );
     233                $this->assertTrue( rest_validate_value_from_schema( array( 'a' => 1 ), $schema ) );
     234                $this->assertWPError( rest_validate_value_from_schema( array( 'b' => 1 ), $schema ) );
     235        }
     236
     237        public function test_type_object_additionalProperties_schema() {
     238                $schema = array(
     239                        'type'       => 'object',
     240                        'properties' => array(
     241                                'a' => array(
     242                                        'type' => 'number'
     243                                ),
     244                        ),
     245                        'additionalProperties' => array(
     246                                'type' => 'boolean'
     247                        ),
     248                );
     249                $this->assertTrue( rest_validate_value_from_schema( array( 'a' => 1 ), $schema ) );
     250                $this->assertTrue( rest_validate_value_from_schema( array( 'b' => true ), $schema ) );
     251                $this->assertWPError( rest_validate_value_from_schema( array( 'b' => 'invalid' ), $schema ) );
     252        }
     253
     254        public function test_type_object_nested() {
     255                $schema = array(
     256                        'type' => 'object',
     257                        'properties' => array(
     258                                'a' => array(
     259                                        'type'  => 'object',
     260                                        'properties' => array(
     261                                                'b' => array( 'type' => 'number' ),
     262                                                'c' => array( 'type' => 'number' ),
     263                                        )
     264                                )
     265                        ),
     266                );
     267                $this->assertTrue( rest_validate_value_from_schema( array( 'a' => array( 'b' => 1, 'c' => 3 ) ), $schema ) );
     268                $this->assertWPError( rest_validate_value_from_schema( array( 'a' => array( 'b' => 1, 'c' => 'invalid' ) ), $schema ) );
     269                $this->assertWPError( rest_validate_value_from_schema( array( 'a' => 1 ), $schema ) );
     270        }
     271
    184272        public function test_type_unknown() {
    185273                $schema = array(
    186274                        'type'  => 'lalala',
  • tests/qunit/fixtures/wp-api-generated.js

    diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js
    index 679d024..9076538 100644
    a b mockedApiResponse.Schema = { 
    400400                        "title": {
    401401                            "required": false,
    402402                            "description": "The title for the object.",
    403                             "type": "object"
     403                            "type": [
     404                                "object",
     405                                "string"
     406                            ]
    404407                        },
    405408                        "content": {
    406409                            "required": false,
    407410                            "description": "The content for the object.",
    408                             "type": "object"
     411                            "type": [
     412                                "object",
     413                                "string"
     414                            ]
    409415                        },
    410416                        "author": {
    411417                            "required": false,
    mockedApiResponse.Schema = { 
    415421                        "excerpt": {
    416422                            "required": false,
    417423                            "description": "The excerpt for the object.",
    418                             "type": "object"
     424                            "type": [
     425                                "object",
     426                                "string"
     427                            ]
    419428                        },
    420429                        "featured_media": {
    421430                            "required": false,
    mockedApiResponse.Schema = { 
    583592                        "title": {
    584593                            "required": false,
    585594                            "description": "The title for the object.",
    586                             "type": "object"
     595                            "type": [
     596                                "object",
     597                                "string"
     598                            ]
    587599                        },
    588600                        "content": {
    589601                            "required": false,
    590602                            "description": "The content for the object.",
    591                             "type": "object"
     603                            "type": [
     604                                "object",
     605                                "string"
     606                            ]
    592607                        },
    593608                        "author": {
    594609                            "required": false,
    mockedApiResponse.Schema = { 
    598613                        "excerpt": {
    599614                            "required": false,
    600615                            "description": "The excerpt for the object.",
    601                             "type": "object"
     616                            "type": [
     617                                "object",
     618                                "string"
     619                            ]
    602620                        },
    603621                        "featured_media": {
    604622                            "required": false,
    mockedApiResponse.Schema = { 
    10041022                        "title": {
    10051023                            "required": false,
    10061024                            "description": "The title for the object.",
    1007                             "type": "object"
     1025                            "type": [
     1026                                "object",
     1027                                "string"
     1028                            ]
    10081029                        },
    10091030                        "content": {
    10101031                            "required": false,
    10111032                            "description": "The content for the object.",
    1012                             "type": "object"
     1033                            "type": [
     1034                                "object",
     1035                                "string"
     1036                            ]
    10131037                        },
    10141038                        "author": {
    10151039                            "required": false,
    mockedApiResponse.Schema = { 
    10191043                        "excerpt": {
    10201044                            "required": false,
    10211045                            "description": "The excerpt for the object.",
    1022                             "type": "object"
     1046                            "type": [
     1047                                "object",
     1048                                "string"
     1049                            ]
    10231050                        },
    10241051                        "featured_media": {
    10251052                            "required": false,
    mockedApiResponse.Schema = { 
    11591186                        "title": {
    11601187                            "required": false,
    11611188                            "description": "The title for the object.",
    1162                             "type": "object"
     1189                            "type": [
     1190                                "object",
     1191                                "string"
     1192                            ]
    11631193                        },
    11641194                        "content": {
    11651195                            "required": false,
    11661196                            "description": "The content for the object.",
    1167                             "type": "object"
     1197                            "type": [
     1198                                "object",
     1199                                "string"
     1200                            ]
    11681201                        },
    11691202                        "author": {
    11701203                            "required": false,
    mockedApiResponse.Schema = { 
    11741207                        "excerpt": {
    11751208                            "required": false,
    11761209                            "description": "The excerpt for the object.",
    1177                             "type": "object"
     1210                            "type": [
     1211                                "object",
     1212                                "string"
     1213                            ]
    11781214                        },
    11791215                        "featured_media": {
    11801216                            "required": false,
    mockedApiResponse.Schema = { 
    15421578                        "title": {
    15431579                            "required": false,
    15441580                            "description": "The title for the object.",
    1545                             "type": "object"
     1581                            "type": [
     1582                                "object",
     1583                                "string"
     1584                            ]
    15461585                        },
    15471586                        "author": {
    15481587                            "required": false,
    mockedApiResponse.Schema = { 
    15881627                        "caption": {
    15891628                            "required": false,
    15901629                            "description": "The attachment caption.",
    1591                             "type": "object"
     1630                            "type": [
     1631                                "object",
     1632                                "string"
     1633                            ]
    15921634                        },
    15931635                        "description": {
    15941636                            "required": false,
    15951637                            "description": "The attachment description.",
    1596                             "type": "object"
     1638                            "type": [
     1639                                "object",
     1640                                "string"
     1641                            ]
    15971642                        },
    15981643                        "post": {
    15991644                            "required": false,
    mockedApiResponse.Schema = { 
    16821727                        "title": {
    16831728                            "required": false,
    16841729                            "description": "The title for the object.",
    1685                             "type": "object"
     1730                            "type": [
     1731                                "object",
     1732                                "string"
     1733                            ]
    16861734                        },
    16871735                        "author": {
    16881736                            "required": false,
    mockedApiResponse.Schema = { 
    17281776                        "caption": {
    17291777                            "required": false,
    17301778                            "description": "The attachment caption.",
    1731                             "type": "object"
     1779                            "type": [
     1780                                "object",
     1781                                "string"
     1782                            ]
    17321783                        },
    17331784                        "description": {
    17341785                            "required": false,
    17351786                            "description": "The attachment description.",
    1736                             "type": "object"
     1787                            "type": [
     1788                                "object",
     1789                                "string"
     1790                            ]
    17371791                        },
    17381792                        "post": {
    17391793                            "required": false,
    mockedApiResponse.Schema = { 
    30913145                        "content": {
    30923146                            "required": false,
    30933147                            "description": "The content for the object.",
    3094                             "type": "object"
     3148                            "type": [
     3149                                "object",
     3150                                "string"
     3151                            ]
    30953152                        },
    30963153                        "date": {
    30973154                            "required": false,
    mockedApiResponse.Schema = { 
    32153272                        "content": {
    32163273                            "required": false,
    32173274                            "description": "The content for the object.",
    3218                             "type": "object"
     3275                            "type": [
     3276                                "object",
     3277                                "string"
     3278                            ]
    32193279                        },
    32203280                        "date": {
    32213281                            "required": false,