Verifying and publishing Swagger server

You can verify your Swagger server setup through the SwaggerUI, which will be located at http://localhost:3000/docs, or you can achieve a more integrated environment with the Preview Swagger extension in VS Code.

I will demonstrate how you can use this extension to test your API from within VS Code:

  1. Select the YAML file in Explorer
  2. Press Shift + Alt + and execute the Preview Swagger command
  3. You will see an interactive window to test your configuration, as illustrated:
Preview Swagger Extension in Visual Studio Code
  1. Click on the Get button for /users
  2. Click on Try it out to see the results
In OpenAPI 3.0.0, instead of schemes, you will see a list of servers, including local and remote resources. This is a very convenient tool to explore various data sources as you code your frontend application.

Now that you have verified your Swagger server, you can publish your server to make it accessible to team members or Automated Acceptance Test (AAT) environments that require a predictable dataset to execute successfully.

Perform the following steps, as covered in Chapter 3, Prepare Angular App for Production Release:

  1. Add npm Scripts for Docker to the root level package.json file
  2. Add a Dockerfile:
Dockerfile
FROM duluca/minimal-node-build-env:8.11.2

RUN mkdir -p /usr/src
WORKDIR /usr/src

COPY server .

RUN npm ci

CMD ["node", "index"]

Once you build the container, you are ready to deploy it.

I have published a sample server on Docker Hub at https://hub.docker.com/r/duluca/lemon-mart-swagger-server.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.144.170