Skip to content

Understanding the generated code

jrgsanchez edited this page Jan 10, 2017 · 2 revisions

Once you have downloaded the zip file, let's take a tour at the files have been generated.

For Java options:

  • Model folder: The generator creates a JAVA class per each object what has been defined in definitions field in your API specification. They will have the necessary methods to fill the class variables randomly if you need. These classes are compiled and packaged in JAR files with Maven.
  • Generator folder:
    • Rest-interfaces: Two JAVA interfaces with the dependencies are packaged in JAR files:
      • IRestHandler: Interface with the methods which help to define the endpoints. These methods match with the paths field of the API specification.
      • IRestListener: Interface with the methods which will help you to implement the methods with the logic you wish. These methods match with the paths field of your API specification.
    • Rest-impl: In JAR files, there is a class which implements 'IRestHandler' and defines the endpoints (parameters, responses, HTTP methods, ...) detailed in your API specification in order to create the controller.
    • Example: You can find two JAVA files:
      • Launcher class with the main method to start the server side.
      • MyListener class implements 'IRestListener' and contains the methods with the logic to return random values. This logic can be replaced freely, always keeping the method's signatures.
  • Installation files: Two executable files (Unix and Windows) to install the JAR files with Maven in your local repository.

For TypeScript client option:

You will find the necessary files to deploy a web page. This client will help you to test the server's endpoints. Under js, there is a couple of interesting things:

  • 'generated' folder: It contains the js files to send requests to the server and parse the results.
  • Model: The generator creates a js file per each object what has been defined in definitions field in your API specification.
  • Rest:
    • RestHandler: In this file, you can find the functions to send the requests.
    • RestListener: It has the functions which will be called when the request obtains the result. By default, these functions just print the results.
  • Example: It runs the selected tests. In this file, if the address of your back-end server has been changed, you just need to add this new address as second parameter where the RestHandler is instantiated.(e.g. "192.168.2.36:5060").

Clone this wiki locally