Skip to content
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: Controller namespace issue for modules in urlPrefixes #38

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,20 @@
<?php

return [
'openApiPath' => '@specs/issue_fix/controller_namespace_issue_for_modules_in_urlprefixes/index.yaml',
'generateUrls' => true,
'generateModels' => false,
'excludeModels' => [
'Error',
],
'generateControllers' => true,
'generateMigrations' => false,
'useJsonApi' => true,
'urlPrefixes' => [
'animals' => '',
'/info' => ['module' =>'petinfo','namespace' => '\app\modules\petinfo\controllers'],
'/fgh' => ['namespace' => '\app\modules\fgh\controllers'],
'/fgh2' => ['path' => '@app/modules/fgh2/controllers', 'namespace' => '\app\fgh2\controllers'],
'/api/v1' => ['path' => '@app/modules/api/v1/controllers', 'namespace' => '\app\api\v1\controllers']
]
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: controller_namespace_issue_for_modules_in_urlprefixes
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/api/v1/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
'200':
description: A paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
'201':
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/animals/pets/{id}:
parameters:
- name: id
in: path
required: true
description: The id of the pet to update
schema:
type: string
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
responses:
'200':
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
patch:
summary: update a specific pet
operationId: updatePetById
tags:
- pets
responses:
'200':
description: The updated pet
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
delete:
summary: delete a specific pet
operationId: deletePetById
tags:
- pets
responses:
'204':
description: successfully deleted pet
/petComments:
get:
description: list all pet comments
responses:
'200':
description: list of comments
/info/pet-details:
get:
description: list all pet details
responses:
'200':
description: list of details
/fgh/pet-detail2s:
get:
description: list all pet details
responses:
'200':
description: list of details
/fgh2/pet-detail2s:
get:
description: list all pet details
responses:
'200':
description: list of details

components:
schemas:
Pet:
description: A Pet
required:
- id
- name
properties:
id:
type: integer
format: int64
readOnly: True
name:
type: string
store:
$ref: '#/components/schemas/Store'
tag:
type: string
x-faker: "$faker->randomElement(['one', 'two', 'three', 'four'])"
Store:
description: A store's description
required:
- id
- name
properties:
id:
type: integer
format: int64
readOnly: True
name:
type: string
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
14 changes: 14 additions & 0 deletions tests/unit/IssueFixTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,18 @@ public function test158BugGiiapiGeneratedRulesEnumWithTrim()
]);
$this->checkFiles($actualFiles, $expectedFiles);
}

//
public function testControllerNamespaceIssueForModulesInUrlPrefixes()
{
$testFile = Yii::getAlias("@specs/issue_fix/controller_namespace_issue_for_modules_in_urlprefixes/index.php");
$this->runGenerator($testFile);
$actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
'recursive' => true,
]);
$expectedFiles = FileHelper::findFiles(Yii::getAlias("@specs/issue_fix/controller_namespace_issue_for_modules_in_urlprefixes/mysql"), [
'recursive' => true,
]);
// $this->checkFiles($actualFiles, $expectedFiles);
}
}
Loading