luciano-jr/swagger-php-skd-test

dev-master 2017-11-14 16:12 UTC

This package is not auto-updated.

Last update: 2024-09-20 02:04:30 UTC


README

这是一个示例服务器Petstore服务器。您可以在https://swagger.org.cnirc.freenode.net, #swagger上了解更多关于Swagger的信息。对于此示例,您可以使用api密钥special-key来测试授权过滤器。

此PHP包由Swagger Codegen项目自动生成

  • API版本:1.0.0
  • 构建包:io.swagger.codegen.languages.PhpClientCodegen

要求

PHP 5.5及以后版本

安装与使用

Composer

要通过Composer安装绑定,请将以下内容添加到composer.json

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
    }
  ],
  "require": {
    "GIT_USER_ID/GIT_REPO_ID": "*@dev"
  }
}

然后运行composer install

手动安装

下载文件并包含autoload.php

    require_once('/path/to/SwaggerClient-php/vendor/autoload.php');

测试

要运行单元测试

composer install
./vendor/bin/phpunit

入门指南

请按照安装过程进行操作,然后运行以下命令

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: petstore_auth
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');

$apiInstance = new Swagger\Client\Api\PetApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$body = new \Swagger\Client\Model\Pet(); // \Swagger\Client\Model\Pet | Pet object that needs to be added to the store

try {
    $apiInstance->addPet($body);
} catch (Exception $e) {
    echo 'Exception when calling PetApi->addPet: ', $e->getMessage(), PHP_EOL;
}

?>

API端点文档

所有URI均相对于http://petstore.swagger.io/v2

模型文档

授权文档

api_key

  • 类型: API密钥
  • API密钥参数名: api_key
  • 位置: HTTP头

petstore_auth

作者

apiteam@swagger.io