Skip to content

Commit 905d925

Browse files
committed
Add stub
1 parent 649743c commit 905d925

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
return [
4+
'openApiPath' => '@specs/issue_fix/102_fractalaction_not_generated_for_root_path/index.yml',
5+
'generateUrls' => true,
6+
'generateModels' => false,
7+
'excludeModels' => [
8+
'Error',
9+
],
10+
'generateControllers' => true,
11+
'generateMigrations' => false,
12+
'generateModelFaker' => false,
13+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
openapi: "3.0.0"
2+
info:
3+
version: 1.0.0
4+
title: 96_component_schema_should_be_optional
5+
6+
paths:
7+
'/':
8+
get:
9+
x-route: fruit/mango/alphonso/list # action ID `list` is mandatory for fractal standalone action generation
10+
operationId: listTasks
11+
responses:
12+
'200':
13+
$ref: '#/components/responses/Tasks'
14+
15+
16+
components:
17+
schemas:
18+
_TaskResource:
19+
type: object
20+
properties:
21+
id:
22+
type: integer
23+
example: 1
24+
type:
25+
type: string
26+
enum:
27+
- tasks
28+
attributes:
29+
$ref: '#/components/schemas/Task'
30+
relationships:
31+
type: object
32+
JSONAPI_links:
33+
type: object
34+
example:
35+
self: 'https://api.example.com/...'
36+
additionalProperties:
37+
oneOf:
38+
- type: string
39+
- type: object
40+
properties:
41+
href:
42+
type: string
43+
meta:
44+
type: object
45+
Task:
46+
type: object
47+
properties:
48+
id:
49+
type: integer
50+
title:
51+
type: string
52+
responses:
53+
Task:
54+
description: Task
55+
content:
56+
application/vnd.api+json:
57+
schema:
58+
type: object
59+
properties:
60+
data:
61+
$ref: '#/components/schemas/_TaskResource'
62+
links:
63+
$ref: '#/components/schemas/JSONAPI_links'
64+
Tasks:
65+
description: 'An array of Tasks'
66+
content:
67+
application/vnd.api+json:
68+
schema:
69+
type: object
70+
properties:
71+
data:
72+
type: array
73+
items:
74+
$ref: '#/components/schemas/_TaskResource'
75+
links:
76+
$ref: '#/components/schemas/JSONAPI_links'

tests/unit/issues/Issue102Test.php

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace tests\unit\issues;
4+
5+
use tests\DbTestCase;
6+
use Yii;
7+
8+
class Issue102Test extends DbTestCase
9+
{
10+
// https://github.com/php-openapi/yii2-openapi/issues/102
11+
public function test102FractalactionNotGeneratedForRootPath()
12+
{
13+
$testFile = Yii::getAlias("@specs/issue_fix/102_fractalaction_not_generated_for_root_path/index.php");
14+
15+
$this->runGenerator($testFile);
16+
// TODO
17+
// $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
18+
// 'recursive' => true,
19+
// ]);
20+
// $expectedFiles = FileHelper::findFiles(Yii::getAlias("@specs/issue_fix/102_fractalaction_not_generated_for_root_path/mysql"), [
21+
// 'recursive' => true,
22+
// ]);
23+
// $this->checkFiles($actualFiles, $expectedFiles);
24+
}
25+
}

0 commit comments

Comments
 (0)