Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

permissions:
contents: read

jobs:
tests:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2', '8.3', '8.4']

name: PHP ${{ matrix.php-version }}

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring
coverage: none

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run tests
run: vendor/bin/phpunit
6 changes: 1 addition & 5 deletions src/Models/Routing/Parameters/Base/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ class Parameter implements RouteMutator, Property
*/
protected $in;

/**
* @var string
*/
protected $type = 'string';

/**
* @var Route
*/
Expand Down Expand Up @@ -103,6 +98,7 @@ public function __construct($name, $type)
{
$this->name = $name;
$this->in = $type;
$this->type = 'string';
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Resolvers/ResolverBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ResolverBase
{
public const CHILDPATH_PATH_SEPARATOR = '.';

public const CHILDPATH_PARAMETER_SEPARATOR = '|';
public const CHILDPATH_PARAMETER_SEPARATOR = ':';

public const CHILDPATH_VARIABLE_OPEN = '{';

Expand Down Expand Up @@ -177,6 +177,10 @@ protected function parseParameters(
*/
protected function getValueFromEntity($entity, $name, array $getterParameters, Context $context)
{
if ($entity === null) {
return null;
}

// Check for get method
if ($this->methodExists($entity, 'get'.ucfirst($name))) {
return call_user_func_array([$entity, 'get'.ucfirst($name)], $getterParameters);
Expand Down
2 changes: 1 addition & 1 deletion tests/Models/MockPropertyResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MockPropertyResolver extends \CatLab\Charon\Resolvers\PropertyResolver
* @param string $path
* @return mixed
*/
protected function splitPathParameters(string $path): array
public function splitPathParameters(string $path): array
{
return parent::splitPathParameters($path);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

declare(strict_types=1);

require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/../vendor/autoload.php';
47 changes: 28 additions & 19 deletions tests/swagger/description.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"swagger": "2.0",
"host": "localhost",
"basePath": "\/",
"basePath": "/",
"info": {
"title": "Pet store API",
"description": "This pet store api allows you to buy pets",
"contact": {
"name": "CatLab Interactive",
"url": "https:\/\/www.catlab.eu\/",
"url": "https://www.catlab.eu/",
"email": "info@catlab.eu"
},
"version": "1.0"
},
"paths": {
"api\/v1\/description.{format}": {
"api/v1/description.{format}": {
"get": {
"responses": {
"403": {
Expand Down Expand Up @@ -47,12 +47,12 @@
}
}
},
"api\/v1\/pets.{format}": {
"api/v1/pets.{format}": {
"get": {
"responses": {
"200": {
"schema": {
"$ref": "#\/definitions\/Pet_index_items"
"$ref": "#/definitions/Pet_index_items"
},
"description": "Returns many Tests\\Petstore\\Models\\Pet"
},
Expand Down Expand Up @@ -135,7 +135,7 @@
"type": "array",
"in": "query",
"required": false,
"description": "Define fields to return. Separate multiple values with comma. Values: *, pet-id, name, category, category.*, category.name, category.category-description, photos, photos.*, photos.url, tags, tags.*, tags.name, status",
"description": "Define fields to return. Separate multiple values with comma. Values: *, pet-id, name, category, category.*, category.category-id, category.name, category.category-description, photos, photos.*, photos.photo-id, photos.url, tags, tags.*, tags.tag-id, tags.name, status",
"items": {
"type": "string"
},
Expand All @@ -145,13 +145,16 @@
"name",
"category",
"category.*",
"category.category-id",
"category.name",
"category.category-description",
"photos",
"photos.*",
"photos.photo-id",
"photos.url",
"tags",
"tags.*",
"tags.tag-id",
"tags.name",
"status"
]
Expand All @@ -164,12 +167,12 @@
}
}
},
"api\/v1\/pets\/{id}.{format}": {
"api/v1/pets/{id}.{format}": {
"get": {
"responses": {
"200": {
"schema": {
"$ref": "#\/definitions\/Pet_view"
"$ref": "#/definitions/Pet_view"
},
"description": "Returns one Tests\\Petstore\\Models\\Pet"
},
Expand Down Expand Up @@ -219,7 +222,7 @@
"type": "array",
"in": "query",
"required": false,
"description": "Define fields to return. Separate multiple values with comma. Values: *, pet-id, name, category, category.*, category.name, category.category-description, photos, photos.*, photos.url, tags, tags.*, tags.name, status",
"description": "Define fields to return. Separate multiple values with comma. Values: *, pet-id, name, category, category.*, category.category-id, category.name, category.category-description, photos, photos.*, photos.photo-id, photos.url, tags, tags.*, tags.tag-id, tags.name, status",
"items": {
"type": "string"
},
Expand All @@ -229,13 +232,16 @@
"name",
"category",
"category.*",
"category.category-id",
"category.name",
"category.category-description",
"photos",
"photos.*",
"photos.photo-id",
"photos.url",
"tags",
"tags.*",
"tags.tag-id",
"tags.name",
"status"
]
Expand All @@ -251,7 +257,7 @@
"responses": {
"200": {
"schema": {
"$ref": "#\/definitions\/Pet_view"
"$ref": "#/definitions/Pet_view"
},
"description": "Returns one Tests\\Petstore\\Models\\Pet"
},
Expand Down Expand Up @@ -286,7 +292,7 @@
"in": "body",
"required": false,
"schema": {
"$ref": "#\/definitions\/Pet_edit"
"$ref": "#/definitions/Pet_edit"
}
},
{
Expand All @@ -309,7 +315,7 @@
"type": "array",
"in": "query",
"required": false,
"description": "Define fields to return. Separate multiple values with comma. Values: *, pet-id, name, category, category.*, category.name, category.category-description, photos, photos.*, photos.url, tags, tags.*, tags.name, status",
"description": "Define fields to return. Separate multiple values with comma. Values: *, pet-id, name, category, category.*, category.category-id, category.name, category.category-description, photos, photos.*, photos.photo-id, photos.url, tags, tags.*, tags.tag-id, tags.name, status",
"items": {
"type": "string"
},
Expand All @@ -319,20 +325,23 @@
"name",
"category",
"category.*",
"category.category-id",
"category.name",
"category.category-description",
"photos",
"photos.*",
"photos.photo-id",
"photos.url",
"tags",
"tags.*",
"tags.tag-id",
"tags.name",
"status"
]
}
],
"consumes": [
"application\/json"
"application/json"
],
"security": {
"oauth2": [
Expand All @@ -357,7 +366,7 @@
"items": {
"type": "array",
"items": {
"$ref": "#\/definitions\/Pet_index"
"$ref": "#/definitions/Pet_index"
}
}
}
Expand Down Expand Up @@ -407,10 +416,10 @@
"type": "string"
},
"photos": {
"$ref": "#\/definitions\/Photo_create_items"
"$ref": "#/definitions/Photo_create_items"
},
"tags": {
"$ref": "#\/definitions\/Tag_identifier_items"
"$ref": "#/definitions/Tag_identifier_items"
}
}
},
Expand All @@ -428,7 +437,7 @@
"items": {
"type": "array",
"items": {
"$ref": "#\/definitions\/Photo_create"
"$ref": "#/definitions/Photo_create"
}
}
}
Expand All @@ -447,7 +456,7 @@
"items": {
"type": "array",
"items": {
"$ref": "#\/definitions\/Tag_identifier"
"$ref": "#/definitions/Tag_identifier"
}
}
}
Expand All @@ -456,7 +465,7 @@
"securityDefinitions": {
"oauth2": {
"type": "oauth2",
"authorizationUrl": "oauth\/authorize",
"authorizationUrl": "oauth/authorize",
"flow": "implicit",
"scopes": {
"full": "Full access"
Expand Down