Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1558057
feat: add recommend models
damcou Mar 17, 2022
bb780ab
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Mar 17, 2022
604dee4
feat(php): enhance PHP doc and regenerate models
damcou Apr 4, 2022
8d3497b
feat(php): add models
damcou Apr 4, 2022
156fbde
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Apr 4, 2022
067d2d0
feat(php): updated generate.ts
damcou Apr 4, 2022
2c0d5be
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Apr 4, 2022
c6ae5ca
feat(php): delete generated files
damcou Apr 4, 2022
f070d7b
feat(php): checkout the clients
damcou Apr 4, 2022
fecebbf
feat(php): fix generate script
damcou Apr 4, 2022
d919515
feat(php): Update Abtesting folder name
damcou Apr 4, 2022
0430431
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Apr 4, 2022
100b8a9
feat(php): Update CI cache for PHP models
damcou Apr 4, 2022
55f2835
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Apr 4, 2022
79b8483
Merge branch 'feat/APIC-355/php-models-returns' of https://github.com…
damcou Apr 4, 2022
cd5f6b6
feat(php): Update CI cache for PHP models (paths)
damcou Apr 4, 2022
f5801e8
feat(php): Update check.yml file with PHP path
damcou Apr 5, 2022
ed67777
feat(php): Bump cache to 7.0.3
damcou Apr 5, 2022
817ced9
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Apr 5, 2022
0a43166
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Apr 5, 2022
78646dd
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Apr 5, 2022
944f98d
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Apr 5, 2022
edc998f
feat: add recommend models
damcou Mar 17, 2022
63584dd
feat(php): enhance PHP doc and regenerate models
damcou Apr 4, 2022
ea88a1c
feat(php): add models
damcou Apr 4, 2022
52227c1
feat(php): updated generate.ts
damcou Apr 4, 2022
8496087
feat(php): delete generated files
damcou Apr 4, 2022
e0eaa38
feat(php): fix generate script
damcou Apr 4, 2022
35f5837
feat(php): Update Abtesting folder name
damcou Apr 4, 2022
257f314
feat(php): Update CI cache for PHP models
damcou Apr 4, 2022
83937b7
feat(php): Update CI cache for PHP models (paths)
damcou Apr 4, 2022
2f3633f
feat(php): Update check.yml file with PHP path
damcou Apr 5, 2022
63fcdf1
feat(php): Bump cache to 7.0.3
damcou Apr 5, 2022
035b9f7
rebase main
shortcuts Apr 5, 2022
87c53a5
fix config name
shortcuts Apr 5, 2022
ff4c6c6
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Apr 7, 2022
60448b9
feat(php): Model cleaning
damcou Apr 7, 2022
8b86cf7
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Apr 7, 2022
59e4a91
Merge branch 'feat/APIC-355/php-models-returns' of https://github.com…
damcou Apr 7, 2022
1c1ca6c
Merge branch 'feat/APIC-355/php-models-returns' of https://github.com…
damcou Apr 7, 2022
88d842b
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Apr 8, 2022
f34d571
feat(php): remove unused dep
damcou Apr 8, 2022
c0e7cc4
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Apr 8, 2022
d9b346d
feat(php): model changes after review
damcou Apr 8, 2022
6618aca
Merge branch 'feat/APIC-355/php-models-returns' of https://github.com…
damcou Apr 8, 2022
f2c7f9d
Update clients/algoliasearch-client-php/lib/Model/AbstractModel.php
damcou Apr 8, 2022
98ce634
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Apr 8, 2022
46bfecd
feat(php): fix unwanted space
damcou Apr 8, 2022
ccfc187
feat(php): script changes after review
damcou Apr 8, 2022
83a01b2
feat(php): linter
damcou Apr 8, 2022
b87b4b4
Merge branch 'main' into feat/APIC-355/php-models-returns
damcou Apr 8, 2022
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
35 changes: 28 additions & 7 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,15 @@ runs:
if: ${{ inputs.job == 'cts' || inputs.job == 'codegen' }}
uses: actions/cache@v2
with:
path: clients/algoliasearch-client-php/lib/Api/SearchApi.php
path: |
clients/algoliasearch-client-php/lib/Api/SearchApi.php
clients/algoliasearch-client-php/lib/Model/Search/**
key: |
${{ env.CACHE_VERSION }}-${{
hashFiles(
'clients/algoliasearch-client-php/lib/Api/SearchApi.php',
'clients/algoliasearch-client-php/lib/Configuration/SearchConfig.php',
'clients/algoliasearch-client-php/lib/Model/Search/**',
'specs/bundled/search.yml',
'templates/php/**',
'generators/src/**'
Expand All @@ -382,12 +385,15 @@ runs:
if: ${{ inputs.job == 'cts' || inputs.job == 'codegen' }}
uses: actions/cache@v2
with:
path: clients/algoliasearch-client-php/lib/Api/RecommendApi.php
path: |
clients/algoliasearch-client-php/lib/Api/RecommendApi.php
clients/algoliasearch-client-php/lib/Model/Recommend/**
key: |
${{ env.CACHE_VERSION }}-${{
hashFiles(
'clients/algoliasearch-client-php/lib/Api/RecommendApi.php',
'clients/algoliasearch-client-php/lib/Configuration/RecommendConfig.php',
'clients/algoliasearch-client-php/lib/Model/Recommend/**',
'specs/bundled/recommend.yml',
'templates/php/**',
'generators/src/**'
Expand All @@ -397,12 +403,15 @@ runs:
if: ${{ inputs.job == 'cts' || inputs.job == 'codegen' }}
uses: actions/cache@v2
with:
path: clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php
path: |
clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php
clients/algoliasearch-client-php/lib/Model/Personalization/**
key: |
${{ env.CACHE_VERSION }}-${{
hashFiles(
'clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php',
'clients/algoliasearch-client-php/lib/Configuration/PersonalizationConfig.php',
'clients/algoliasearch-client-php/lib/Model/Personalization/**',
'specs/bundled/personalization.yml',
'templates/php/**',
'generators/src/**'
Expand All @@ -412,12 +421,15 @@ runs:
if: ${{ inputs.job == 'cts' || inputs.job == 'codegen' }}
uses: actions/cache@v2
with:
path: clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php
path: |
clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php
clients/algoliasearch-client-php/lib/Model/Analytics/**
key: |
${{ env.CACHE_VERSION }}-${{
hashFiles(
'clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php',
'clients/algoliasearch-client-php/lib/Configuration/AnalyticsConfig.php',
'clients/algoliasearch-client-php/lib/Model/Analytics/**',
'specs/bundled/analytics.yml',
'templates/php/**',
'generators/src/**'
Expand All @@ -427,12 +439,15 @@ runs:
if: ${{ inputs.job == 'cts' || inputs.job == 'codegen' }}
uses: actions/cache@v2
with:
path: clients/algoliasearch-client-php/lib/Api/InsightsApi.php
path: |
clients/algoliasearch-client-php/lib/Api/InsightsApi.php
clients/algoliasearch-client-php/lib/Model/Insights/**
key: |
${{ env.CACHE_VERSION }}-${{
hashFiles(
'clients/algoliasearch-client-php/lib/Api/InsightsApi.php',
'clients/algoliasearch-client-php/lib/Configuration/InsightsConfig.php',
'clients/algoliasearch-client-php/lib/Model/Insights/**',
'specs/bundled/insights.yml',
'templates/php/**',
'generators/src/**'
Expand All @@ -442,12 +457,15 @@ runs:
if: ${{ inputs.job == 'cts' || inputs.job == 'codegen' }}
uses: actions/cache@v2
with:
path: clients/algoliasearch-client-php/lib/Api/AbtestingApi.php
path: |
clients/algoliasearch-client-php/lib/Api/AbtestingApi.php
clients/algoliasearch-client-php/lib/Model/Abtesting/**
key: |
${{ env.CACHE_VERSION }}-${{
hashFiles(
'clients/algoliasearch-client-php/lib/Api/AbtestingApi.php',
'clients/algoliasearch-client-php/lib/Configuration/AbtestingConfig.php',
'clients/algoliasearch-client-php/lib/Model/Abtesting/**',
'specs/bundled/abtesting.yml',
'templates/php/**',
'generators/src/**'
Expand All @@ -457,12 +475,15 @@ runs:
if: ${{ inputs.job == 'cts' || inputs.job == 'codegen' }}
uses: actions/cache@v2
with:
path: clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php
path: |
clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php
clients/algoliasearch-client-php/lib/Model/QuerySuggestions/**
key: |
${{ env.CACHE_VERSION }}-${{
hashFiles(
'clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php',
'clients/algoliasearch-client-php/lib/Configuration/QuerySuggestionsConfig.php',
'clients/algoliasearch-client-php/lib/Model/QuerySuggestions/**',
'specs/bundled/query-suggestions.yml',
'templates/php/**',
'generators/src/**'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ jobs:
id: cache
uses: actions/cache@v2
with:
path: ${{ format('{0}/lib/Api/{1}.php', matrix.client.folder, matrix.client.api) }}
path: |
${{ format('{0}/lib/Api/{1}.php', matrix.client.folder, matrix.client.api) }}
${{ format('{0}/lib/Model/{1}/**', matrix.client.folder, matrix.client.capitalizedName) }}
key: |
${{ env.CACHE_VERSION }}-${{
hashFiles(
Expand Down
2 changes: 0 additions & 2 deletions clients/algoliasearch-client-php/.openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

docs/**
test/**
lib/Model/**
lib/Model/

.travis.yml
README.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

namespace Algolia\AlgoliaSearch\Configuration;

class AbTestingConfig extends ConfigWithRegion
class AbtestingConfig extends ConfigWithRegion
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

namespace Algolia\AlgoliaSearch\Configuration;

class RecommendConfig extends ConfigWithRegion
class RecommendConfig extends Configuration
{
}
50 changes: 50 additions & 0 deletions clients/algoliasearch-client-php/lib/Model/AbstractModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Algolia\AlgoliaSearch\Model;

use \Algolia\AlgoliaSearch\ObjectSerializer;

/**
* Abstract class extended by each models
*
* @category Class
* @package Algolia\AlgoliaSearch
*/
abstract class AbstractModel
{
/**
* Serializes the object to a value that can be serialized natively by json_encode().
*
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource
*/
public function jsonSerialize()
{
return ObjectSerializer::sanitizeForSerialization($this);
}

/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString()
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}

/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue()
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}
14 changes: 7 additions & 7 deletions openapitools.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-php",
"invokerPackage": "Algolia\\AlgoliaSearch",
"globalProperty": "apis,supportingFiles",
"modelPackage": "Model\\Search",
"additionalProperties": {
"configClassname": "SearchConfig",
"useCache": true,
Expand All @@ -283,7 +283,7 @@
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-php",
"invokerPackage": "Algolia\\AlgoliaSearch",
"globalProperty": "apis,supportingFiles",
"modelPackage": "Model\\Recommend",
"additionalProperties": {
"configClassname": "RecommendConfig",
"useCache": true,
Expand All @@ -302,7 +302,7 @@
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-php",
"invokerPackage": "Algolia\\AlgoliaSearch",
"globalProperty": "apis,supportingFiles",
"modelPackage": "Model\\Personalization",
"additionalProperties": {
"configClassname": "PersonalizationConfig",
"hasRegionalHost": true,
Expand All @@ -325,7 +325,7 @@
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-php",
"invokerPackage": "Algolia\\AlgoliaSearch",
"globalProperty": "apis,supportingFiles",
"modelPackage": "Model\\Analytics",
"additionalProperties": {
"configClassname": "AnalyticsConfig",
"hasRegionalHost": true,
Expand All @@ -349,7 +349,7 @@
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-php",
"invokerPackage": "Algolia\\AlgoliaSearch",
"globalProperty": "apis,supportingFiles",
"modelPackage": "Model\\Insights",
"additionalProperties": {
"configClassname": "InsightsConfig",
"hasRegionalHost": true,
Expand All @@ -373,7 +373,7 @@
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-php",
"invokerPackage": "Algolia\\AlgoliaSearch",
"globalProperty": "apis,supportingFiles",
"modelPackage": "Model\\Abtesting",
"additionalProperties": {
"configClassname": "AbtestingConfig",
"hasRegionalHost": true,
Expand All @@ -397,7 +397,7 @@
"gitUserId": "algolia",
"gitRepoId": "algoliasearch-client-php",
"invokerPackage": "Algolia\\AlgoliaSearch",
"globalProperty": "apis,supportingFiles",
"modelPackage": "Model\\QuerySuggestions",
"additionalProperties": {
"configClassname": "QuerySuggestionsConfig",
"hasRegionalHost": true,
Expand Down
3 changes: 3 additions & 0 deletions scripts/ci/createMatrix.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CLIENTS, GENERATORS } from '../common';
import { createClientName } from '../cts/utils';
import type { Language } from '../types';

import { getNbGitDiff } from './utils';
Expand All @@ -14,6 +15,7 @@ type ClientMatrix = {
folder: string;
config?: string;
api?: string;
capitalizedName?: string;
};

type Matrix<TMatrix> = {
Expand Down Expand Up @@ -70,6 +72,7 @@ async function getClientMatrix({
'Config',
'Api'
);
matchedGenerator.capitalizedName = createClientName(client, 'php');
}

matrix.client.push(matchedGenerator);
Expand Down
4 changes: 4 additions & 0 deletions scripts/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
getLanguageFolder,
getLanguageModelFolder,
} from './config';
import { createClientName } from './cts/utils';
import { formatter } from './formatter';
import { createSpinner } from './oraLog';
import { setHostsOptions } from './pre-gen/setHostsOptions';
Expand All @@ -33,6 +34,9 @@ async function removeExistingModel(
case 'java':
clientModel = client;
break;
case 'php':
clientModel = createClientName(client, 'php');
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
<?php

namespace Algolia\AlgoliaSearch\Model;
namespace {{modelPackage}};

/**
* Interface abstracting model access.
*
* @package Algolia\AlgoliaSearch\Model
* @package {{modelPackage}}
*/
interface ModelInterface
{
/**
* The original name of the model.
*
* @return string
*/
public function getModelName();

/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array
*/
public static function openAPITypes();
public static function modelTypes();

/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array
*/
public static function openAPIFormats();

/**
* Array of attributes where the key is the local name, and the value is the original name
*
* @return array
*/
public static function attributeMap();
public static function modelFormats();

/**
* Array of attributes to setter functions (for deserialization of responses)
Expand Down
14 changes: 10 additions & 4 deletions templates/php/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts;
{{/hasRegionalHost}}

/**
* Instantiate the client with congiguration
* Instantiate the client with configuration
*
* @param {{configClassname}} $config Configuration
*/
Expand Down Expand Up @@ -134,10 +134,16 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts;
*
{{/description}}
{{#allParams}}
* @param {{#isString}}string{{/isString}}{{#isInteger}}int{{/isInteger}}{{^isString}}{{^isInteger}}array{{/isInteger}}{{/isString}} ${{paramName}}{{#description}} {{.}}{{/description}}{{^description}} {{paramName}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
* @param {{#isString}}string{{/isString}}{{#isInteger}}int{{/isInteger}}{{#isBoolean}}bool{{/isBoolean}}{{^isString}}{{^isInteger}}{{^isBoolean}}array{{/isBoolean}}{{/isInteger}}{{/isString}} ${{paramName}}{{#description}} {{.}}{{/description}}{{^description}} {{paramName}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
{{#isModel}}
{{#vars}}
* - ${{paramName}}{{> arrayParam}}
{{/vars}}
* @see {{{dataType}}}
{{/isModel}}
{{/allParams}}
*
* @return array<string, mixed>
* @return {{#returnType}}{{#responses}}{{#dataType}}{{#-first}}array<string, mixed>|{{{dataType}}}{{/-first}}{{/dataType}}{{/responses}}{{/returnType}}{{^returnType}}void{{/returnType}}
{{#isDeprecated}}
* @deprecated
{{/isDeprecated}}
Expand Down Expand Up @@ -241,7 +247,7 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts;
if (${{paramName}} !== null) {
$resourcePath = str_replace(
{{=<% %>=}}'{<%baseName%>}'<%={{ }}=%>,
{{#x-is-custom-request}}{{paramName}}{{/x-is-custom-request}}{{^x-is-custom-request}}ObjectSerializer::toPathValue(${{paramName}}){{/x-is-custom-request}},
{{#x-is-custom-request}}${{paramName}}{{/x-is-custom-request}}{{^x-is-custom-request}}ObjectSerializer::toPathValue(${{paramName}}){{/x-is-custom-request}},
$resourcePath
);
}
Expand Down
1 change: 1 addition & 0 deletions templates/php/arrayParam.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
['{{{baseName}}}'] => ({{#isString}}string{{/isString}}{{#isInteger}}int{{/isInteger}}{{#isBoolean}}bool{{/isBoolean}}{{^isString}}{{^isInteger}}{{^isBoolean}}array{{/isBoolean}}{{/isInteger}}{{/isString}}) {{{description}}}{{#required}} (required){{/required}}
Loading