Generating a Server Stub

With SwaggerHub, you can easily generate a server stub (an API implementation stub) for Node.js, ASP.NET, JAX-RS, and other servers and frameworks. The server stub is a good starting point for implementing your API – you can run and test it locally, implement the business logic for your API, and then deploy it to your server.

Anyone can generate a server stub for any API in SwaggerHub, unless the API owner disabled server generation in the code generation options.

Downloading a server stub

  1. Open the API page in SwaggerHub.

  2. If the API has several versions, select the version, for which you want to generate the code.

    Selecting an API version
  3. From the Export menu, select Server Stub, and then the desired language or framework.


    Languages marked with an asterisk * use custom code generation options as configured by the API editors.

    Generating an API server stub
  4. Download and unzip the server code.

Code generation options

API owners can customize the code generation options for their APIs.

Custom server generators

SwaggerHub On-Premise allows companies to create and use custom code generators. To learn more, see Using Custom Codegen Templates.

I have downloaded the server stub. Now what?

You can run and test the generated server locally. Note that the generated API code contains just stub methods that do not contain any actual programming logic. You need to implement the logic yourself to handle whatever work the API needs to do. Once the implementation is ready, you can deploy the API locally or on your server. See the file in the downloaded archive to get started.

See Also

Publication date: