Skip to content

Instantly share code, notes, and snippets.

@DariuszLuber
Created August 30, 2017 22:14
Show Gist options
  • Save DariuszLuber/38830e73a1c38eaeb21e7168c30b3adb to your computer and use it in GitHub Desktop.
Save DariuszLuber/38830e73a1c38eaeb21e7168c30b3adb to your computer and use it in GitHub Desktop.
api-platform - swagger anotation
@ApiResource(
attributes={
"filters"={"apiOrder", "searchFilter"},
"pagination_items_per_page"=50,
"normalization_context"={"groups"={"drugs_unified"}},
},
itemOperations={
"get"={"method"="GET"},
"put"={"method"="PUT"},
"special"={
"route_name"="api_drugunifieds_add_drug",
"swagger_context" = {
"parameters" = {
{
"name" = "id",
"in" = "path",
"required" = "true",
"type" = "string"
},
{
"name" = "drugs",
"in" = "body",
"required" = "true",
"type" = "object",
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string"
}
}
},
"style": "simple"
}
},
"responses" = {
"200" = {
"description" = "drugs added",
"schema" = {
"type" = "object",
"required" = {
"email",
"username"
},
"properties" = {
"email" = {
"type" = "string"
},
"fullname" = {
"type" = "string"
},
"username" = {
"type" = "string"
}
}
}
},
"400" = {
"description" = "Invalid input"
},
"404" = {
"description" = "resource not found"
}
},
"summary" = "Add drugs to drugs_unified",
"consumes" = {
"application/json",
"text/html",
},
"produces" = {
"application/json"
}
}
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment