Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added missing json-schema properties
  • Loading branch information
bfanger committed Apr 27, 2015
1 parent fdfc507 commit dc86e14
Show file tree
Hide file tree
Showing 18 changed files with 1,836 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Examples/Examples.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## petstore.swagger.io

Using swagger-php to generate the [example for swagger-ui](http://petstore.swagger.io/)

## swagger-spec

Expand Down
30 changes: 30 additions & 0 deletions Examples/petstore.swagger.io/ApiResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace PetstoreIO;

/**
* @SWG\Definition(
* @SWG\Xml(name="##default")
* )
*/
class ApiResponse {

/**
* @SWG\Property(format="int32")
* @var int
*/
public $code;

/**
* @SWG\Property
* @var string
*/
public $type;

/**
* @SWG\Property
* @var string
*/
public $message;

}
322 changes: 322 additions & 0 deletions Examples/petstore.swagger.io/controllers/PetController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,322 @@
<?php

namespace PetstoreIO;

class PetController {

/**
* @SWG\Get(
* path="/pet/findByTags",
* summary="Finds Pets by tags",
* tags={"pet"},
* description="Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
* operationId="findPetsByTags",
* consumes={"application/xml", "application/json"},
* produces={"application/xml", "application/json"},
* @SWG\Parameter(
* name="tags",
* in="query",
* description="Tags to filter by",
* required=false,
* type="array",
* @SWG\Items(type="string"),
* collectionFormat="multi"
* ),
* @SWG\Response(
* response=200,
* description="successful operation",
* @SWG\Schema(
* type="array",
* @SWG\Items(ref="#/definitions/Pet")
* ),
* ),
* @SWG\Response(
* response="400",
* description="Invalid tag value",
* ),
* security={
* {
* "petstore_auth": {"write:pets", "read:pets"}
* }
* }
* )
*/
function findByTags() {

}

/**
* @SWG\Get(
* path="/pet/findByStatus",
* summary="Finds Pets by status",
* description="Multiple status values can be provided with comma seperated strings",
* operationId="findPetsByStatus",
* consumes={"application/xml", "application/json"},
* produces={"application/xml", "application/json"},
* tags={"pet"},
* @SWG\Parameter(
* name="status",
* in="query",
* description="Status values that need to be considered for filter",
* required=false,
* type="array",
* @SWG\Items(type="string"),
* collectionFormat="multi",
* default="available",
* enum={"available", "pending", "sold"}
* ),
* @SWG\Response(
* response=200,
* description="successful operation",
* @SWG\Schema(
* type="array",
* @SWG\Items(ref="#/definitions/Pet")
* ),
* ),
* @SWG\Response(
* response="400",
* description="Invalid status value",
* ),
* security={
* {"petstore_auth": {"write:pets", "read:pets"}}
* }
* )
*/
function findByStatus() {

}

/**
* @SWG\Get(
* path="/pet/{petId}",
* summary="Find pet by ID",
* description="Returns a single pet",
* operationId="getPetById",
* tags={"pet"},
* consumes={
* "application/xml",
* "application/json",
* "application/x-www-form-urlencoded"
* },
* produces={"application/xml", "application/json"},
* @SWG\Parameter(
* description="ID of pet to return",
* in="path",
* name="petId",
* required=true,
* type="integer",
* format="int64"
* ),
* @SWG\Response(
* response=200,
* description="successful operation",
* @SWG\Schema(ref="#/definitions/Pet")
* ),
* @SWG\Response(
* response="400",
* description="Invalid ID supplied"
* ),
* @SWG\Response(
* response="404",
* description="Pet not found"
* ),
* security={
* {"api_key": {}},
* {"petstore_auth": {"write:pets", "read:pets"}}
* }
* )
*/
function getPetById() {

}

/**
* @SWG\Post(
* path="/pet",
* tags={"pet"},
* operationId="addPet",
* summary="Add a new pet to the store",
* description="",
* consumes={"application/json", "application/xml"},
* produces={"application/xml", "application/json"},
* @SWG\Parameter(
* name="body",
* in="body",
* description="Pet object that needs to be added to the store",
* required=false,
* @SWG\Schema(ref="#/definitions/Pet"),
* ),
* @SWG\Response(
* response=405,
* description="Invalid input",
* ),
* security={{"petstore_auth":{"write:pets", "read:pets"}}}
* )
*/
function addPet() {

}

/**
* @SWG\Put(
* path="/pet",
* tags={"pet"},
* operationId="updatePet",
* summary="Update an existing pet",
* description="",
* consumes={"application/json", "application/xml"},
* produces={"application/xml", "application/json"},
* @SWG\Parameter(
* name="body",
* in="body",
* description="Pet object that needs to be added to the store",
* required=false,
* @SWG\Schema(ref="#/definitions/Pet"),
* ),
* @SWG\Response(
* response=400,
* description="Invalid ID supplied",
* ),
* @SWG\Response(
* response=404,
* description="Pet not found",
* ),
* @SWG\Response(
* response=405,
* description="Validation exception",
* ),
* security={{"petstore_auth":{"write:pets", "read:pets"}}}
* )
*/
function updatePet() {

}

/**
* @SWG\Delete(
* path="/pet/{petId}",
* summary="Deletes a pet",
* description="",
* operationId="deletePet",
* consumes={"application/xml", "application/json", "multipart/form-data", "application/x-www-form-urlencoded"},
* produces={"application/xml", "application/json"},
* tags={"pet"},
* @SWG\Parameter(
* description="Pet id to delete",
* in="path",
* name="petId",
* required=true,
* type="integer",
* format="int64"
* ),
* @SWG\Parameter(
* name="api_key",
* in="header",
* description="",
* required=false,
* type="string"
* ),
* @SWG\Response(
* response=400,
* description="Invalid pet value"
* ),
* security={{"petstore_auth":{"write:pets", "read:pets"}}}
* )
*/
function deletePet() {

}

/**
* @SWG\Post(
* path="/pet/{petId}",
* tags={"pet"},
* summary="Updates a pet in the store with form data",
* description="",
* operationId="updatePetWithForm",
* consumes={"application/x-www-form-urlencoded"},
* produces={"application/xml", "application/json"},
* @SWG\Parameter(
* name="petId",
* in="path",
* description="ID of pet that needs to be updated",
* required=true,
* type="string"
* ),
* @SWG\Parameter(
* name="name",
* in="formData",
* description="Updated name of the pet",
* required=false,
* type="string"
* ),
* @SWG\Parameter(
* name="status",
* in="formData",
* description="Updated status of the pet",
* required=false,
* type="string"
* ),
* @SWG\Response(response="405",description="Invalid input"),
* security={{
* "petstore_auth": {"write:pets", "read:pets"}
* }}
* )
*/
function updatePetWithForm() {

}

/**
* @SWG\Post(
* path="/pet/{petId}/uploadImage",
* consumes={"multipart/form-data"},
* description="",
* operationId="uploadFile",
* @SWG\Parameter(
* description="Additional data to pass to server",
* in="formData",
* name="additionalMetadata",
* required=false,
* type="string"
* ),
* @SWG\Parameter(
* description="file to upload",
* in="formData",
* name="file",
* required=false,
* type="file"
* ),
* @SWG\Parameter(
* description="ID of pet to update",
* format="int64",
* in="path",
* name="petId",
* required=true,
* type="integer"
* ),
* produces={"application/json"},
* @SWG\Response(
* response="200",
* description="successful operation",
* @SWG\Schema(ref="#/definitions/ApiResponse")
* ),
* security={
* {
* "petstore_auth": {
* "read:pets",
* "write:pets"
* }
* }
* },
* summary="uploads an image",
* tags={
* "pet"
* }
* )
* */
function uploadFile() {

}

}
Loading

0 comments on commit dc86e14

Please sign in to comment.