Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagexml
titleendpoint.xml
collapsetrue
<endpoint xmlns="http://www.knubisoft.com/api/schema/endpoint">

	<swagger>
		<operationId>addFirmInformation</operationId>
		<summary>Add firm information</summary>
		<description>Add firm information</description>
		<tags>
			<tag>Company</tag>
		</tags>
	</swagger>

	<post>
		<response include="firmInformationResponse.xml"/>
		<request/>
	</post>

</endpoint>

Response & request

Both response and request mostly contain an information about an object to which API is intended to work with. So usually it is different data like company name, number of employees, dates of contracts establishment and so on. And all these data can be described in response/request.

Creating

You can create file 'response.xml' ('request.xml') right in the folder where your endpoint.xml is placed (in such case you needn't use 'include' attribute in appropriate tags in endpoint.xml) or you can create it in folder spec/src/main/resources/spec/__def__/models/static and pass its name to 'include' attribute of appropriate tag in endpoint.xml. No matter what you choose, it's up to you.

Describing

For both response and request you need to use tag <class>. It can contain

  • <byte>
  • <short>
  • <integer>
  • <long>
  • <float>
  • <double>
  • <biginteger>
  • <bigdecimal>
  • <string>
  • <boolean>
  • <char>
  • <localdate>
  • <localtime>
  • <localdatetime>
  • <instant>
  • <offsettime>
  • <offsetdatetime>
  • <zoneddatetime>
  • <object>
  • <enum>
  • <array>
  • <list>
  • <set>

So you are able to use type which you need. Each of these tags has different attributes (more info here) but they have several one in common. It's 'name' and 'description'. 'name' value is used to generate field with specified name in the class which represents the response/request. 'description' value is needed for you and others to understand why this tag was created and also for swagger.

Example


Code Block
languagexml
titleresponse.xml
collapsetrue
<class name="FirmInformationRequest" xmlns="http://www.knubisoft.com/api/schema/class" >
	<string name="firmName" description="Firm name"/>
	<string name="country" description="Country"/>
	<string name="state" description="State"/>
	<string name="city" description="City "/>
	<string name="firstAddress" description="First address"/>
	<string name="secondAddress" description="Second address"/>
	<integer name="postCode" description="Post code"/>
	<localdate name="establishDate" description="The date of establishing"/>
</class>


Put it all together

As a result you should get the following structure:

...