Created by: ybelenko
PR checklist
-
Read the contribution guidelines. -
If contributing template-only or documentation-only changes which will change sample output, build the project before. -
Run the shell script(s) under ./bin/
(or Windows batch scripts under.\bin\windows
) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the code or mustache templates for a language ({LANG}
) (e.g. php, ruby, python, etc). -
File the PR against the correct branch: master
,4.3.x
,5.0.x
. Default:master
. -
Copy the technical committee to review the pull request if your PR is targeting a particular programming language.
Current progress
<?php
require __DIR__ . '/vendor/autoload.php';
use OpenAPIServer\Mock\OpenApiDataMocker as Mocker;
$mocker = new Mocker();
$data = [
'Integer from 1 to 100' => $mocker->mockInteger(null, 1, 100),
'Float from -3 to 3' => $mocker->mockNumber(null, -3, 3),
'String 10 chars' => $mocker->mockString(null, 10, 10),
'Boolean' => $mocker->mockBoolean(),
'Array of strings' => $mocker->mockArray(
[
'type' => 'string',
'maxLength' => 20,
]
),
'Object' => $mocker->mockObject([
'id' => [
'type' => 'integer',
'minimum' => 1,
'maximum' => 10
],
'username' => [
'type' => 'string',
'maxLength' => 10,
]
])
];
echo json_encode($data, JSON_PRETTY_PRINT);
output:
{
"Integer from 1 to 100": 62,
"Float from -3 to 3": 2.9062,
"String 10 chars": "Lorem ipsu",
"Boolean": true,
"Array of strings": [
"Lore"
],
"Object": {
"id": 1,
"username": "Lorem ip"
}
}
How to test
Show boring command line instructions
- Checkout into feature branch
$ git checkout -b ybelenko-slim_data_mocker_object master
$ git pull https://github.com/ybelenko/openapi-generator.git slim_data_mocker_object
- Generate new Slim4 samples and go to just created build
$ mvn clean package
$ bin/php-slim4-server-petstore.sh
$ cd samples/server/petstore/php-slim4
- Start Composer installation and run unit tests
$ composer install
$ composer test
$ composer phpcs
Related to #3545 (closed)
cc @jebentier, @dkarlovi, @mandrean, @jfastnacht, @ackintosh, @renepardon