Search code examples
spring-bootibm-cloudmicroservicesapiconnect

The right way to define an API's base path in Api Connect


Problem:

I have two micro services (in Spring Boot) published in Bluemix's Api Connect. I want to assign a base path to each one so that we have a way to separate them. I.E.:

Path to API 1: https://api.us.apiconnect.ibmcloud.com/[organization]/[catalog]/api1/[endpoint-of-api1] Path to API 2: https://api.us.apiconnect.ibmcloud.com/[organization]/[catalog]/api2/[endpoint-of-api2]


My solution:

Assign a context path to each Api in their application.yml file:

server:
  contextPath: /api1

Even though this works, it doesn't seem right to have a base path for the entire server, when the microservice shouldn't be aware of its external context (the reason for a base path is exclusively to have a separation in Api Connect)

Any ideas?


Solution

  • In the API Designer you can edit the Base Path and the specific API Paths:

    Base Path: Edit Base Path

    API Paths Edit API Path

    To get to these Design settings complete the following steps:

    1. In your API Connect service, click the Drafts section in the Navigation pane and then click the APIs tab:

    API Manager

    1. Click the corresponding API you want to edit and the API Designer will be displayed. Here you can edit the Base Path and API Paths as seen in the sections below:

    API Designer

    For more information, please see the following documentation Defining Paths for a REST API.