[PHP-Symfony] Encurage Symfony 5 bundle directory structure best practices (#13014)

* use .yaml instead of .yml

This is recommended by Symfony standards

* save Bundle files also to src path

* add test for generate ping

* add package imports

* fix expected file names

* why is Api/ApiServer.php missing

* output filenames

* use getAbsolutePath for debug purpose

* do not use punctuation as current directory

* refactor: remove todos

* use also .yaml in test to fix it

* add test for setting a different source directory

* use correct const for setting source dir property in tests

* import the AbstractPhpCodegen in test class

* put also Resources to source path

* save docs not to Resources

* update samples and improve src path in autoload.php and composer.json

* update moved samples
This commit is contained in:
Luka Dschaak 2022-09-18 09:16:27 +02:00 committed by GitHub
parent 43375b9392
commit c4a3866e75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 204 additions and 79 deletions

View File

@ -245,21 +245,22 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
return packageName; return packageName;
} }
public String toSrcPath(String packageName, String basePath) { public String toSrcPath(final String packageName, final String basePath) {
packageName = packageName.replace(invokerPackage, ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. String modifiedPackageName = packageName.replace(invokerPackage, "");
if (basePath != null && basePath.length() > 0) { String modifiedBasePath = basePath;
basePath = basePath.replaceAll("[\\\\/]?$", "") + File.separator; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. if (basePath != null && !basePath.isEmpty()) {
modifiedBasePath = basePath.replaceAll("[\\\\/]?$", "") + File.separator;
} }
// Trim prefix file separators from package path // Trim prefix file separators from package path
String packagePath = StringUtils.removeStart( String packagePath = StringUtils.removeStart(
// Replace period, backslash, forward slash with file separator in package name // Replace period, backslash, forward slash with file separator in package name
packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement("/")), modifiedPackageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement("/")),
File.separator File.separator
); );
// Trim trailing file separators from the overall path // Trim trailing file separators from the overall path
return StringUtils.removeEnd(basePath + packagePath, File.separator); return StringUtils.removeEnd(modifiedBasePath + packagePath, File.separator);
} }
@Override @Override

View File

@ -106,12 +106,12 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
importMapping.clear(); importMapping.clear();
supportsInheritance = true; supportsInheritance = true;
srcBasePath = "."; srcBasePath = "";
setInvokerPackage("OpenAPI\\Server"); setInvokerPackage("OpenAPI\\Server");
setBundleName("OpenAPIServer"); setBundleName("OpenAPIServer");
setBundleAlias("open_api_server"); setBundleAlias("open_api_server");
modelDirName = "Model"; modelDirName = "Model";
docsBasePath = "Resources" + "/" + "docs"; docsBasePath = "docs";
apiDocPath = docsBasePath + "/" + apiDirName; apiDocPath = docsBasePath + "/" + apiDirName;
modelDocPath = docsBasePath + "/" + modelDirName; modelDocPath = docsBasePath + "/" + modelDirName;
outputFolder = "generated-code" + File.separator + "php"; outputFolder = "generated-code" + File.separator + "php";
@ -316,6 +316,9 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
additionalProperties.put("bundleExtensionName", bundleExtensionName); additionalProperties.put("bundleExtensionName", bundleExtensionName);
additionalProperties.put("bundleAlias", bundleAlias); additionalProperties.put("bundleAlias", bundleAlias);
// add trailing slash for mustache templates
additionalProperties.put("relativeSrcBasePath", srcBasePath.isEmpty() ? "" : srcBasePath + "/");
// make api and model src path available in mustache template // make api and model src path available in mustache template
additionalProperties.put("apiSrcPath", "." + "/" + toSrcPath(apiPackage, srcBasePath)); additionalProperties.put("apiSrcPath", "." + "/" + toSrcPath(apiPackage, srcBasePath));
additionalProperties.put("modelSrcPath", "." + "/" + toSrcPath(modelPackage, srcBasePath)); additionalProperties.put("modelSrcPath", "." + "/" + toSrcPath(modelPackage, srcBasePath));
@ -336,11 +339,12 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
final String configDir = "Resources" + File.separator + "config"; final String configDir = "Resources" + File.separator + "config";
final String dependencyInjectionDir = "DependencyInjection"; final String dependencyInjectionDir = "DependencyInjection";
final String compilerDir = dependencyInjectionDir + File.separator + "Compiler";
supportingFiles.add(new SupportingFile("Controller.mustache", toSrcPath(controllerPackage, srcBasePath), "Controller.php")); supportingFiles.add(new SupportingFile("Controller.mustache", toSrcPath(controllerPackage, srcBasePath), "Controller.php"));
supportingFiles.add(new SupportingFile("Bundle.mustache", "", bundleClassName + ".php")); supportingFiles.add(new SupportingFile("Bundle.mustache", toSrcPath("", srcBasePath), bundleClassName + ".php"));
supportingFiles.add(new SupportingFile("Extension.mustache", dependencyInjectionDir, bundleExtensionName + ".php")); supportingFiles.add(new SupportingFile("Extension.mustache", toSrcPath(dependencyInjectionDir, srcBasePath), bundleExtensionName + ".php"));
supportingFiles.add(new SupportingFile("ApiPass.mustache", dependencyInjectionDir + File.separator + "Compiler", bundleName + "ApiPass.php")); supportingFiles.add(new SupportingFile("ApiPass.mustache", toSrcPath(compilerDir, srcBasePath), bundleName + "ApiPass.php"));
supportingFiles.add(new SupportingFile("ApiServer.mustache", toSrcPath(apiPackage, srcBasePath), "ApiServer.php")); supportingFiles.add(new SupportingFile("ApiServer.mustache", toSrcPath(apiPackage, srcBasePath), "ApiServer.php"));
// Serialization components // Serialization components
@ -357,10 +361,10 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
supportingFiles.add(new SupportingFile("testing/phpunit.xml.mustache", "", "phpunit.xml.dist")); supportingFiles.add(new SupportingFile("testing/phpunit.xml.mustache", "", "phpunit.xml.dist"));
supportingFiles.add(new SupportingFile("testing/AppKernel.mustache", toSrcPath(testsPackage, srcBasePath), "AppKernel.php")); supportingFiles.add(new SupportingFile("testing/AppKernel.mustache", toSrcPath(testsPackage, srcBasePath), "AppKernel.php"));
supportingFiles.add(new SupportingFile("testing/ControllerTest.mustache", toSrcPath(controllerTestsPackage, srcBasePath), "ControllerTest.php")); supportingFiles.add(new SupportingFile("testing/ControllerTest.mustache", toSrcPath(controllerTestsPackage, srcBasePath), "ControllerTest.php"));
supportingFiles.add(new SupportingFile("testing/test_config.yml", toSrcPath(testsPackage, srcBasePath), "test_config.yml")); supportingFiles.add(new SupportingFile("testing/test_config.yml", toSrcPath(testsPackage, srcBasePath), "test_config.yaml"));
supportingFiles.add(new SupportingFile("routing.mustache", configDir, "routing.yml")); supportingFiles.add(new SupportingFile("routing.mustache", toSrcPath(configDir, srcBasePath), "routing.yaml"));
supportingFiles.add(new SupportingFile("services.mustache", configDir, "services.yml")); supportingFiles.add(new SupportingFile("services.mustache", toSrcPath(configDir, srcBasePath), "services.yaml"));
supportingFiles.add(new SupportingFile("composer.mustache", "", "composer.json")); supportingFiles.add(new SupportingFile("composer.mustache", "", "composer.json"));
supportingFiles.add(new SupportingFile("autoload.mustache", "", "autoload.php")); supportingFiles.add(new SupportingFile("autoload.mustache", "", "autoload.php"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));

View File

@ -37,7 +37,7 @@ class {{bundleExtensionName}} extends Extension
public function load(array $configs, ContainerBuilder $container): void public function load(array $configs, ContainerBuilder $container): void
{ {
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml'); $loader->load('services.yaml');
} }
public function getAlias(): string public function getAlias(): string

View File

@ -71,7 +71,7 @@ Step 3: Register the routes:
```yaml ```yaml
# app/config/routes.yaml # app/config/routes.yaml
{{bundleAlias}}: {{bundleAlias}}:
resource: "@{{bundleName}}Bundle/Resources/config/routing.yml" resource: "@{{bundleName}}Bundle/Resources/config/routing.yaml"
``` ```
Step 4: Implement the API calls: Step 4: Implement the API calls:
@ -119,7 +119,7 @@ class {{baseName}}Api implements {{classname}} // An interface is autogenerated
Step 5: Tag your API implementation: Step 5: Tag your API implementation:
```yaml ```yaml
# config/services.yml # config/services.yaml
services: services:
# ... # ...
Acme\MyBundle\Api\{{baseName}}Api: Acme\MyBundle\Api\{{baseName}}Api:

View File

@ -11,7 +11,7 @@ Method | HTTP request | Description
{{#operations}} {{#operations}}
## Service Declaration ## Service Declaration
```yaml ```yaml
# config/services.yml # config/services.yaml
services: services:
# ... # ...
Acme\MyBundle\Api\{{baseName}}Api: Acme\MyBundle\Api\{{baseName}}Api:

View File

@ -6,7 +6,7 @@
* *
* After registering this autoload function with SPL, the following line * After registering this autoload function with SPL, the following line
* would cause the function to attempt to load the \{{invokerPackage}}\Baz\Qux class * would cause the function to attempt to load the \{{invokerPackage}}\Baz\Qux class
* from /path/to/project/{{srcBasePath}}/Baz/Qux.php: * from /path/to/project/{{relativeSrcBasePath}}Baz/Qux.php:
* *
* new \{{invokerPackage}}\Baz\Qux; * new \{{invokerPackage}}\Baz\Qux;
* *
@ -20,7 +20,7 @@ spl_autoload_register(function ($class) {
$prefix = '{{escapedInvokerPackage}}\\'; $prefix = '{{escapedInvokerPackage}}\\';
// base directory for the namespace prefix // base directory for the namespace prefix
$base_dir = __DIR__ . '/{{srcBasePath}}/'; $base_dir = __DIR__ . '/{{relativeSrcBasePath}}';
// does the class use the namespace prefix? // does the class use the namespace prefix?
$len = strlen($prefix); $len = strlen($prefix);

View File

@ -36,7 +36,7 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"{{escapedInvokerPackage}}\\" : "{{srcBasePath}}/" "{{escapedInvokerPackage}}\\" : "{{relativeSrcBasePath}}"
} }
} }
} }

View File

@ -18,7 +18,7 @@
!var/sessions/.gitkeep !var/sessions/.gitkeep
# Parameters # Parameters
/app/config/parameters.yml /app/config/parameters.yaml
/app/config/parameters.ini /app/config/parameters.ini
# Managed by Composer # Managed by Composer

View File

@ -24,6 +24,6 @@ class AppKernel extends Kernel
*/ */
public function registerContainerConfiguration(LoaderInterface $loader) public function registerContainerConfiguration(LoaderInterface $loader)
{ {
$loader->load(__DIR__.'/test_config.yml'); $loader->load(__DIR__.'/test_config.yaml');
} }
} }

View File

@ -1,8 +1,8 @@
imports: imports:
- { resource: "../Resources/config/services.yml" } - { resource: "../Resources/config/services.yaml" }
framework: framework:
secret: "testsecret" secret: "testsecret"
test: ~ test: ~
router: router:
resource: "%kernel.project_dir%/Resources/config/routing.yml" resource: "%kernel.project_dir%/Resources/config/routing.yaml"

View File

@ -17,11 +17,23 @@
package org.openapitools.codegen.php; package org.openapitools.codegen.php;
import java.io.File;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.openapitools.codegen.ClientOptInput;
import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.DefaultGenerator;
import org.openapitools.codegen.TestUtils;
import org.openapitools.codegen.config.CodegenConfigurator;
import org.openapitools.codegen.languages.AbstractPhpCodegen;
import org.openapitools.codegen.languages.PhpSymfonyServerCodegen; import org.openapitools.codegen.languages.PhpSymfonyServerCodegen;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.Test; import org.testng.annotations.Test;
public class PhpSymfonyServerCodegenTest { public class PhpSymfonyServerCodegenTest {
@Test @Test
@ -53,4 +65,112 @@ public class PhpSymfonyServerCodegenTest {
Assert.assertEquals(codegen.isHideGenerationTimestamp(), false); Assert.assertEquals(codegen.isHideGenerationTimestamp(), false);
} }
@Test
public void testGeneratePing() throws Exception {
Map<String, Object> properties = new HashMap<>();
File output = Files.createTempDirectory("test").toFile();
final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("php-symfony")
.setAdditionalProperties(properties)
.setInputSpec("src/test/resources/3_0/ping.yaml")
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
final ClientOptInput clientOptInput = configurator.toClientOptInput();
DefaultGenerator generator = new DefaultGenerator();
List<File> files = generator.opts(clientOptInput).generate();
Assert.assertEquals(files.size(), 33);
TestUtils.ensureContainsFile(files, output, ".coveralls.yml");
TestUtils.ensureContainsFile(files, output, ".gitignore");
TestUtils.ensureContainsFile(files, output, ".openapi-generator-ignore");
TestUtils.ensureContainsFile(files, output, ".openapi-generator/FILES");
TestUtils.ensureContainsFile(files, output, ".openapi-generator/VERSION");
TestUtils.ensureContainsFile(files, output, ".php_cs.dist");
TestUtils.ensureContainsFile(files, output, ".travis.yml");
TestUtils.ensureContainsFile(files, output, "autoload.php");
TestUtils.ensureContainsFile(files, output, "composer.json");
TestUtils.ensureContainsFile(files, output, "git_push.sh");
TestUtils.ensureContainsFile(files, output, "phpunit.xml.dist");
TestUtils.ensureContainsFile(files, output, "README.md");
TestUtils.ensureContainsFile(files, output, "Api/ApiServer.php");
TestUtils.ensureContainsFile(files, output, "Api/DefaultApiInterface.php");
TestUtils.ensureContainsFile(files, output, "Controller/Controller.php");
TestUtils.ensureContainsFile(files, output, "Controller/DefaultController.php");
TestUtils.ensureContainsFile(files, output, "DependencyInjection/Compiler/OpenAPIServerApiPass.php");
TestUtils.ensureContainsFile(files, output, "DependencyInjection/OpenAPIServerExtension.php");
TestUtils.ensureContainsFile(files, output, "docs/Api/DefaultApiInterface.md");
TestUtils.ensureContainsFile(files, output, "OpenAPIServerBundle.php");
TestUtils.ensureContainsFile(files, output, "Resources/config/routing.yaml");
TestUtils.ensureContainsFile(files, output, "Resources/config/services.yaml");
TestUtils.ensureContainsFile(files, output, "Service/JmsSerializer.php");
TestUtils.ensureContainsFile(files, output, "Service/SerializerInterface.php");
TestUtils.ensureContainsFile(files, output, "Service/StrictJsonDeserializationVisitor.php");
TestUtils.ensureContainsFile(files, output, "Service/StrictJsonDeserializationVisitorFactory.php");
TestUtils.ensureContainsFile(files, output, "Service/SymfonyValidator.php");
TestUtils.ensureContainsFile(files, output, "Service/TypeMismatchException.php");
TestUtils.ensureContainsFile(files, output, "Service/ValidatorInterface.php");
TestUtils.ensureContainsFile(files, output, "Tests/Api/DefaultApiInterfaceTest.php");
TestUtils.ensureContainsFile(files, output, "Tests/AppKernel.php");
TestUtils.ensureContainsFile(files, output, "Tests/Controller/ControllerTest.php");
TestUtils.ensureContainsFile(files, output, "Tests/test_config.yaml");
output.deleteOnExit();
}
@Test
public void testGeneratePingWithDifferentSourceDirectory() throws Exception {
Map<String, Object> properties = new HashMap<>();
properties.put(AbstractPhpCodegen.SRC_BASE_PATH, "src");
File output = Files.createTempDirectory("test").toFile();
final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("php-symfony")
.setAdditionalProperties(properties)
.setInputSpec("src/test/resources/3_0/ping.yaml")
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
final ClientOptInput clientOptInput = configurator.toClientOptInput();
DefaultGenerator generator = new DefaultGenerator();
List<File> files = generator.opts(clientOptInput).generate();
Assert.assertEquals(files.size(), 33);
TestUtils.ensureContainsFile(files, output, ".coveralls.yml");
TestUtils.ensureContainsFile(files, output, ".gitignore");
TestUtils.ensureContainsFile(files, output, ".openapi-generator-ignore");
TestUtils.ensureContainsFile(files, output, ".openapi-generator/FILES");
TestUtils.ensureContainsFile(files, output, ".openapi-generator/VERSION");
TestUtils.ensureContainsFile(files, output, ".php_cs.dist");
TestUtils.ensureContainsFile(files, output, ".travis.yml");
TestUtils.ensureContainsFile(files, output, "autoload.php");
TestUtils.ensureContainsFile(files, output, "composer.json");
TestUtils.ensureContainsFile(files, output, "git_push.sh");
TestUtils.ensureContainsFile(files, output, "phpunit.xml.dist");
TestUtils.ensureContainsFile(files, output, "README.md");
TestUtils.ensureContainsFile(files, output, "docs/Api/DefaultApiInterface.md");
TestUtils.ensureContainsFile(files, output, "src/Api/ApiServer.php");
TestUtils.ensureContainsFile(files, output, "src/Api/DefaultApiInterface.php");
TestUtils.ensureContainsFile(files, output, "src/Controller/Controller.php");
TestUtils.ensureContainsFile(files, output, "src/Controller/DefaultController.php");
TestUtils.ensureContainsFile(files, output, "src/DependencyInjection/Compiler/OpenAPIServerApiPass.php");
TestUtils.ensureContainsFile(files, output, "src/DependencyInjection/OpenAPIServerExtension.php");
TestUtils.ensureContainsFile(files, output, "src/OpenAPIServerBundle.php");
TestUtils.ensureContainsFile(files, output, "src/Resources/config/routing.yaml");
TestUtils.ensureContainsFile(files, output, "src/Resources/config/services.yaml");
TestUtils.ensureContainsFile(files, output, "src/Service/JmsSerializer.php");
TestUtils.ensureContainsFile(files, output, "src/Service/SerializerInterface.php");
TestUtils.ensureContainsFile(files, output, "src/Service/StrictJsonDeserializationVisitor.php");
TestUtils.ensureContainsFile(files, output, "src/Service/StrictJsonDeserializationVisitorFactory.php");
TestUtils.ensureContainsFile(files, output, "src/Service/SymfonyValidator.php");
TestUtils.ensureContainsFile(files, output, "src/Service/TypeMismatchException.php");
TestUtils.ensureContainsFile(files, output, "src/Service/ValidatorInterface.php");
TestUtils.ensureContainsFile(files, output, "src/Tests/Api/DefaultApiInterfaceTest.php");
TestUtils.ensureContainsFile(files, output, "src/Tests/AppKernel.php");
TestUtils.ensureContainsFile(files, output, "src/Tests/Controller/ControllerTest.php");
TestUtils.ensureContainsFile(files, output, "src/Tests/test_config.yaml");
output.deleteOnExit();
}
} }

View File

@ -18,7 +18,7 @@
!var/sessions/.gitkeep !var/sessions/.gitkeep
# Parameters # Parameters
/app/config/parameters.yml /app/config/parameters.yaml
/app/config/parameters.ini /app/config/parameters.ini
# Managed by Composer # Managed by Composer

View File

@ -20,17 +20,8 @@ Model/Tag.php
Model/User.php Model/User.php
OpenAPIServerBundle.php OpenAPIServerBundle.php
README.md README.md
Resources/config/routing.yml Resources/config/routing.yaml
Resources/config/services.yml Resources/config/services.yaml
Resources/docs/Api/PetApiInterface.md
Resources/docs/Api/StoreApiInterface.md
Resources/docs/Api/UserApiInterface.md
Resources/docs/Model/ApiResponse.md
Resources/docs/Model/Category.md
Resources/docs/Model/Order.md
Resources/docs/Model/Pet.md
Resources/docs/Model/Tag.md
Resources/docs/Model/User.md
Service/JmsSerializer.php Service/JmsSerializer.php
Service/SerializerInterface.php Service/SerializerInterface.php
Service/StrictJsonDeserializationVisitor.php Service/StrictJsonDeserializationVisitor.php
@ -40,8 +31,17 @@ Service/TypeMismatchException.php
Service/ValidatorInterface.php Service/ValidatorInterface.php
Tests/AppKernel.php Tests/AppKernel.php
Tests/Controller/ControllerTest.php Tests/Controller/ControllerTest.php
Tests/test_config.yml Tests/test_config.yaml
autoload.php autoload.php
composer.json composer.json
docs/Api/PetApiInterface.md
docs/Api/StoreApiInterface.md
docs/Api/UserApiInterface.md
docs/Model/ApiResponse.md
docs/Model/Category.md
docs/Model/Order.md
docs/Model/Pet.md
docs/Model/Tag.md
docs/Model/User.md
git_push.sh git_push.sh
phpunit.xml.dist phpunit.xml.dist

View File

@ -47,7 +47,7 @@ class OpenAPIServerExtension extends Extension
public function load(array $configs, ContainerBuilder $container): void public function load(array $configs, ContainerBuilder $container): void
{ {
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml'); $loader->load('services.yaml');
} }
public function getAlias(): string public function getAlias(): string

View File

@ -60,7 +60,7 @@ Step 3: Register the routes:
```yaml ```yaml
# app/config/routes.yaml # app/config/routes.yaml
open_api_server: open_api_server:
resource: "@OpenAPIServerBundle/Resources/config/routing.yml" resource: "@OpenAPIServerBundle/Resources/config/routing.yaml"
``` ```
Step 4: Implement the API calls: Step 4: Implement the API calls:
@ -99,7 +99,7 @@ class PetApi implements PetApiInterface // An interface is autogenerated
Step 5: Tag your API implementation: Step 5: Tag your API implementation:
```yaml ```yaml
# config/services.yml # config/services.yaml
services: services:
# ... # ...
Acme\MyBundle\Api\PetApi: Acme\MyBundle\Api\PetApi:
@ -117,36 +117,36 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description Class | Method | HTTP request | Description
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
*PetApiInterface* | [**addPet**](Resources/docs/Api/PetApiInterface.md#addpet) | **POST** /pet | Add a new pet to the store *PetApiInterface* | [**addPet**](docs/Api/PetApiInterface.md#addpet) | **POST** /pet | Add a new pet to the store
*PetApiInterface* | [**deletePet**](Resources/docs/Api/PetApiInterface.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet *PetApiInterface* | [**deletePet**](docs/Api/PetApiInterface.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApiInterface* | [**findPetsByStatus**](Resources/docs/Api/PetApiInterface.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status *PetApiInterface* | [**findPetsByStatus**](docs/Api/PetApiInterface.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
*PetApiInterface* | [**findPetsByTags**](Resources/docs/Api/PetApiInterface.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags *PetApiInterface* | [**findPetsByTags**](docs/Api/PetApiInterface.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags
*PetApiInterface* | [**getPetById**](Resources/docs/Api/PetApiInterface.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID *PetApiInterface* | [**getPetById**](docs/Api/PetApiInterface.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID
*PetApiInterface* | [**updatePet**](Resources/docs/Api/PetApiInterface.md#updatepet) | **PUT** /pet | Update an existing pet *PetApiInterface* | [**updatePet**](docs/Api/PetApiInterface.md#updatepet) | **PUT** /pet | Update an existing pet
*PetApiInterface* | [**updatePetWithForm**](Resources/docs/Api/PetApiInterface.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *PetApiInterface* | [**updatePetWithForm**](docs/Api/PetApiInterface.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
*PetApiInterface* | [**uploadFile**](Resources/docs/Api/PetApiInterface.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image *PetApiInterface* | [**uploadFile**](docs/Api/PetApiInterface.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
*StoreApiInterface* | [**deleteOrder**](Resources/docs/Api/StoreApiInterface.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID *StoreApiInterface* | [**deleteOrder**](docs/Api/StoreApiInterface.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
*StoreApiInterface* | [**getInventory**](Resources/docs/Api/StoreApiInterface.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status *StoreApiInterface* | [**getInventory**](docs/Api/StoreApiInterface.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
*StoreApiInterface* | [**getOrderById**](Resources/docs/Api/StoreApiInterface.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID *StoreApiInterface* | [**getOrderById**](docs/Api/StoreApiInterface.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID
*StoreApiInterface* | [**placeOrder**](Resources/docs/Api/StoreApiInterface.md#placeorder) | **POST** /store/order | Place an order for a pet *StoreApiInterface* | [**placeOrder**](docs/Api/StoreApiInterface.md#placeorder) | **POST** /store/order | Place an order for a pet
*UserApiInterface* | [**createUser**](Resources/docs/Api/UserApiInterface.md#createuser) | **POST** /user | Create user *UserApiInterface* | [**createUser**](docs/Api/UserApiInterface.md#createuser) | **POST** /user | Create user
*UserApiInterface* | [**createUsersWithArrayInput**](Resources/docs/Api/UserApiInterface.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array *UserApiInterface* | [**createUsersWithArrayInput**](docs/Api/UserApiInterface.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
*UserApiInterface* | [**createUsersWithListInput**](Resources/docs/Api/UserApiInterface.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array *UserApiInterface* | [**createUsersWithListInput**](docs/Api/UserApiInterface.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array
*UserApiInterface* | [**deleteUser**](Resources/docs/Api/UserApiInterface.md#deleteuser) | **DELETE** /user/{username} | Delete user *UserApiInterface* | [**deleteUser**](docs/Api/UserApiInterface.md#deleteuser) | **DELETE** /user/{username} | Delete user
*UserApiInterface* | [**getUserByName**](Resources/docs/Api/UserApiInterface.md#getuserbyname) | **GET** /user/{username} | Get user by user name *UserApiInterface* | [**getUserByName**](docs/Api/UserApiInterface.md#getuserbyname) | **GET** /user/{username} | Get user by user name
*UserApiInterface* | [**loginUser**](Resources/docs/Api/UserApiInterface.md#loginuser) | **GET** /user/login | Logs user into the system *UserApiInterface* | [**loginUser**](docs/Api/UserApiInterface.md#loginuser) | **GET** /user/login | Logs user into the system
*UserApiInterface* | [**logoutUser**](Resources/docs/Api/UserApiInterface.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session *UserApiInterface* | [**logoutUser**](docs/Api/UserApiInterface.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
*UserApiInterface* | [**updateUser**](Resources/docs/Api/UserApiInterface.md#updateuser) | **PUT** /user/{username} | Updated user *UserApiInterface* | [**updateUser**](docs/Api/UserApiInterface.md#updateuser) | **PUT** /user/{username} | Updated user
## Documentation For Models ## Documentation For Models
- [ApiResponse](Resources/docs/Model/ApiResponse.md) - [ApiResponse](docs/Model/ApiResponse.md)
- [Category](Resources/docs/Model/Category.md) - [Category](docs/Model/Category.md)
- [Order](Resources/docs/Model/Order.md) - [Order](docs/Model/Order.md)
- [Pet](Resources/docs/Model/Pet.md) - [Pet](docs/Model/Pet.md)
- [Tag](Resources/docs/Model/Tag.md) - [Tag](docs/Model/Tag.md)
- [User](Resources/docs/Model/User.md) - [User](docs/Model/User.md)
## Documentation For Authorization ## Documentation For Authorization

View File

@ -24,6 +24,6 @@ class AppKernel extends Kernel
*/ */
public function registerContainerConfiguration(LoaderInterface $loader) public function registerContainerConfiguration(LoaderInterface $loader)
{ {
$loader->load(__DIR__.'/test_config.yml'); $loader->load(__DIR__.'/test_config.yaml');
} }
} }

View File

@ -1,8 +1,8 @@
imports: imports:
- { resource: "../Resources/config/services.yml" } - { resource: "../Resources/config/services.yaml" }
framework: framework:
secret: "testsecret" secret: "testsecret"
test: ~ test: ~
router: router:
resource: "%kernel.project_dir%/Resources/config/routing.yml" resource: "%kernel.project_dir%/Resources/config/routing.yaml"

View File

@ -16,7 +16,7 @@
* *
* After registering this autoload function with SPL, the following line * After registering this autoload function with SPL, the following line
* would cause the function to attempt to load the \OpenAPI\Server\Baz\Qux class * would cause the function to attempt to load the \OpenAPI\Server\Baz\Qux class
* from /path/to/project/./Baz/Qux.php: * from /path/to/project/Baz/Qux.php:
* *
* new \OpenAPI\Server\Baz\Qux; * new \OpenAPI\Server\Baz\Qux;
* *
@ -30,7 +30,7 @@ spl_autoload_register(function ($class) {
$prefix = 'OpenAPI\\Server\\'; $prefix = 'OpenAPI\\Server\\';
// base directory for the namespace prefix // base directory for the namespace prefix
$base_dir = __DIR__ . '/./'; $base_dir = __DIR__ . '/';
// does the class use the namespace prefix? // does the class use the namespace prefix?
$len = strlen($prefix); $len = strlen($prefix);

View File

@ -33,7 +33,7 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"OpenAPI\\Server\\" : "./" "OpenAPI\\Server\\" : ""
} }
} }
} }

View File

@ -16,7 +16,7 @@ Method | HTTP request | Description
## Service Declaration ## Service Declaration
```yaml ```yaml
# config/services.yml # config/services.yaml
services: services:
# ... # ...
Acme\MyBundle\Api\PetApi: Acme\MyBundle\Api\PetApi:

View File

@ -12,7 +12,7 @@ Method | HTTP request | Description
## Service Declaration ## Service Declaration
```yaml ```yaml
# config/services.yml # config/services.yaml
services: services:
# ... # ...
Acme\MyBundle\Api\StoreApi: Acme\MyBundle\Api\StoreApi:

View File

@ -16,7 +16,7 @@ Method | HTTP request | Description
## Service Declaration ## Service Declaration
```yaml ```yaml
# config/services.yml # config/services.yaml
services: services:
# ... # ...
Acme\MyBundle\Api\UserApi: Acme\MyBundle\Api\UserApi:

View File

@ -9,9 +9,9 @@
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true"> <coverage processUncoveredFiles="true">
<include> <include>
<directory suffix=".php">././Api</directory> <directory suffix=".php">./Api</directory>
<directory suffix=".php">././Model</directory> <directory suffix=".php">./Model</directory>
<directory suffix=".php">././Controller</directory> <directory suffix=".php">./Controller</directory>
</include> </include>
</coverage> </coverage>
<testsuites> <testsuites>