スワップ基本注
1814 ワード
Swaggerコア注釈モデルクラスを使用して他のメタデータを提供するのと同じで、コントローラとその方法と方法のパラメータを注釈することができます。
@Appは、コントローラ全体について説明しています。メソッドレベルの説明@App Paramをメソッドパラメータに使用します。
@Request Mapping(「/v 2/persons/」)@Appi(description=「Set of endpoints for Creating,Retrieving,Updating and Deleting of Persons.」)public class Persontroller{
@Appは、コントローラ全体について説明しています。メソッドレベルの説明@App Paramをメソッドパラメータに使用します。
@Request Mapping(「/v 2/persons/」)@Appi(description=「Set of endpoints for Creating,Retrieving,Updating and Deleting of Persons.」)public class Persontroller{
private PersonService personService;
@RequestMapping(method = RequestMethod.GET, produces = "application/json")
@ApiOperation("Returns list of all Persons in the system.")
public List getAllPersons() {
return personService.getAllPersons();
}
@RequestMapping(method = RequestMethod.GET, path = "/{id}", produces = "application/json")
@ApiOperation("Returns a specific person by their identifier. 404 if does not exist.")
public Person getPersonById(@ApiParam("Id of the person to be obtained. Cannot be empty.")
@PathVariable int id) {
return personService.getPersonById(id);
}
@RequestMapping(method = RequestMethod.DELETE, path = "/{id}")
@ApiOperation("Deletes a person from the system. 404 if the person's identifier is not found.")
public void deletePerson(@ApiParam("Id of the person to be deleted. Cannot be empty.")
@PathVariable int id) {
personService.deletePerson(id);
}
@RequestMapping(method = RequestMethod.POST, produces = "application/json")
@ApiOperation("Creates a new person.")
public Person createPerson(@ApiParam("Person information for a new person to be created.")
@RequestBody Person person) {
return personService.createPerson(person);
}
@Autowired
public void setPersonService(PersonService personService) {
this.personService = personService;
}
)