Plugin Directory

Changeset 3358117


Ignore:
Timestamp:
09/08/2025 06:24:59 PM (5 months ago)
Author:
moon0326
Message:

Release v1.0.22

Location:
wp-openapi/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • wp-openapi/trunk/readme.txt

    r3330759 r3358117  
    55Tested up to: 6.7.2
    66Requires PHP: 7.1
    7 Stable tag: 1.0.21
     7Stable tag: 1.0.22
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
  • wp-openapi/trunk/src/SchemaGenerator.php

    r3330759 r3358117  
    7373                    $schema = call_user_func( $options['schema'] );
    7474                    if ( isset( $schema['title'] ) ) {
    75                         $schemaTitle                                   = $schema['title'];
     75                        $title = Util::normalizeSchemaTitle( $schema['title'] );
     76                        $schemaTitle                                   = $title;
    7677                        $base['components']['schemas'][ $schemaTitle ] = $schema;
    7778                    }
     
    152153        }
    153154
     155        // Manually fix these endpoints from WooCommerce.
     156        $fixList = [
     157            'install_async_schema',
     158            'install_and_activate_schema',
     159            'count_low_in_stock_items'
     160        ];
     161
     162        // Hate this fix, but we don't have control over other plugins.
     163        foreach ($fixList as $schemaKey) {
     164            if (isset($base['components']['schemas'][$schemaKey]) && isset($base['components']['schemas'][$schemaKey]['properties']['properties'])) {
     165                $base['components']['schemas'][$schemaKey]['properties'] = $base['components']['schemas'][$schemaKey]['properties']['properties']; 
     166                foreach ($base['components']['schemas'][$schemaKey]['properties'] as $key => $property) {
     167                    if (is_string($property)) {
     168                        $base['components']['schemas'][$schemaKey]['properties'][$key] = array('type' => Util::normalzieInvalidType($property));
     169                    }
     170                }
     171            }
     172        }
     173
    154174        return $base;
    155175    }
  • wp-openapi/trunk/src/Spec/Operation.php

    r3330759 r3358117  
    183183                    }
    184184                }
     185
     186                // Loop through again make sure it's not an empty array.
     187                foreach ($properties as $key => $property) {
     188                    if (is_array($property) && count($property) === 0) {
     189                        $properties[$key] = new \stdClass();
     190                    }
     191                    foreach ($property as $propKey => $propValue) {
     192                        if ($propKey === 'items' && is_string($propValue)) {
     193                            $properties[$key]['items'] = array('type' => Util::normalzieInvalidType($propValue));
     194                        }
     195                    }
     196                }
     197
     198
    185199                return $properties;
    186200            });
  • wp-openapi/trunk/src/Util.php

    r3269185 r3358117  
    7070        return $enum;
    7171    }
     72
     73    public static function normalizeSchemaTitle( $title ) {
     74        // Remove invalid characters for schema titles.
     75        // Only allow alphanumeric characters and underscores.
     76        $title = preg_replace( '/[^a-zA-Z0-9_]/', '_', $title );
     77        // Ensure the title starts with an alphabetic character or underscore.
     78        if ( ! preg_match( '/^[a-zA-Z_]/', $title ) ) {
     79            $title = '_' . $title;
     80        }
     81
     82
     83        return strtolower( $title );
     84    }
    7285}
  • wp-openapi/trunk/vendor/composer/installed.php

    r3330759 r3358117  
    44        'pretty_version' => 'dev-main',
    55        'version' => 'dev-main',
    6         'reference' => 'a3c9ca1226d1e30a10ce9268ca8d91e72f855570',
     6        'reference' => '08ebd2d7eca722986a50dc7da97d0277bb53b3ba',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-main',
    1515            'version' => 'dev-main',
    16             'reference' => 'a3c9ca1226d1e30a10ce9268ca8d91e72f855570',
     16            'reference' => '08ebd2d7eca722986a50dc7da97d0277bb53b3ba',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
  • wp-openapi/trunk/wp-openapi.php

    r3330759 r3358117  
    1010 * Plugin Name: WP OpenAPI
    1111 * Plugin URI: https://github.com/moon0326/wp-openapi
    12  * Version:     1.0.21
     12 * Version:     1.0.22
    1313 * Author:      Moon K
    1414 * Author URI: https://github.com/moon0326
Note: See TracChangeset for help on using the changeset viewer.