Skip to content

FractalAction not generated for root path #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

return [
'openApiPath' => '@specs/issue_fix/102_fractalaction_not_generated_for_root_path/index.yml',
'generateUrls' => true,
'generateModels' => false,
'excludeModels' => [
'Error',
],
'generateControllers' => true,
'generateMigrations' => false,
'generateModelFaker' => false,
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: 96_component_schema_should_be_optional

paths:
'/':
get:
x-route: fruit/mango/alphonso/list # action ID `list` is mandatory for fractal standalone action generation
operationId: listTasks
responses:
'200':
$ref: '#/components/responses/Tasks'


components:
schemas:
_TaskResource:
type: object
properties:
id:
type: integer
example: 1
type:
type: string
enum:
- tasks
attributes:
$ref: '#/components/schemas/Task'
relationships:
type: object
JSONAPI_links:
type: object
example:
self: 'https://api.example.com/...'
additionalProperties:
oneOf:
- type: string
- type: object
properties:
href:
type: string
meta:
type: object
Task:
type: object
properties:
id:
type: integer
title:
type: string
responses:
Task:
description: Task
content:
application/vnd.api+json:
schema:
type: object
properties:
data:
$ref: '#/components/schemas/_TaskResource'
links:
$ref: '#/components/schemas/JSONAPI_links'
Tasks:
description: 'An array of Tasks'
content:
application/vnd.api+json:
schema:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/_TaskResource'
links:
$ref: '#/components/schemas/JSONAPI_links'
25 changes: 25 additions & 0 deletions tests/unit/issues/Issue102Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace tests\unit\issues;

use tests\DbTestCase;
use Yii;

class Issue102Test extends DbTestCase
{
// https://github.com/php-openapi/yii2-openapi/issues/102
public function test102FractalactionNotGeneratedForRootPath()
{
$testFile = Yii::getAlias("@specs/issue_fix/102_fractalaction_not_generated_for_root_path/index.php");

$this->runGenerator($testFile);
// TODO
// $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
// 'recursive' => true,
// ]);
// $expectedFiles = FileHelper::findFiles(Yii::getAlias("@specs/issue_fix/102_fractalaction_not_generated_for_root_path/mysql"), [
// 'recursive' => true,
// ]);
// $this->checkFiles($actualFiles, $expectedFiles);
}
}