I write API in Php Laravel and use swagger (2.0) annotations (lib: darkaonline/l5-swagger which use swagger-php) to generate swagger.json. I have following swagger:
@SWG\Definition(
definition="Space",
@SWG\Property( property="id", type="integer", example=33),
@SWG\Property( property="name", type="string" ),
@SWG\Property( property="dataA", type="string", example="very long data string" ),
@SWG\Property( property="dataB", type="string", example="very long data string" ),
),
@SWG\Get(
path="/api/v1/client/space/list",
@SWG\Response( response=200, description="OK",
@SWG\Schema(
type="array",
@SWG\Items(ref="#/definitions/Space"),
)
)
)
Above api should return list of Spaces (to show in table) but I only need to get id and name - however Space also have very heavy fields dataA and dataB - which are non needed in table. Is there a way to exclude these fields without creating separate Space definition for response (to avoid breaking "don't repeat yourself" rule)? Is there some mechanism to do something like this:
@SWG\Items(ref="#/definitions/Space", exclude={"dataA","dataB"}),
And/or exclude more nested fields like
exclude={"dataA.securityField","dataA.someList[].heavyField"}
?
PS: I also report this as question/issue here.