Skip to content

Customising the displayed base URL for API endpoints #963

@Luthien-in-edhil

Description

@Luthien-in-edhil

Hi,

I'm trying to figure out whether it is possible to customise how our API endpoints vs. the base URL (basePath in JSON output) appears? For instance (how it appears in the Swagger UI):

hierarchical_records:

GET /v2/record/{collectionId}/{recordId}/ancestor-self-siblings.json
GET /v2/record/{collectionId}/{recordId}/children.json
GET /v2/record/{collectionId}/{recordId}/parent.json
GET /v2/record/{collectionId}/{recordId}/self.json

(...)
[ base url: /api , api version: 1.0 ]

... while we would like to present it like this:

hierarchical_records:

GET /record/{collectionId}/{recordId}/ancestor-self-siblings.json
GET /record/{collectionId}/{recordId}/children.json
GET /record/{collectionId}/{recordId}/parent.json
GET /record/{collectionId}/{recordId}/self.json

(...)
[ base url: /api/v2 , api version: 1.0 ]

I understand that the base_url annotation has been deprecated since Swagger 2.0, and I assume that Swagger retrieves the endpoint urls from the Spring @RequestMapping annotations.
However, we have @RequestMapping annotations in our controllers with URL's that include the /v2 bit:
@RequestMapping(value = "/v2/user/saveditem.json" (...)
but also some without it:
@RequestMapping(value = "/{collectionId}/{recordId}/parent.json" (...)
according to how things are set in the *mvc.xml Spring configuration.

Swagger (Springfox?) seems to be smart enough to figure this out by itself and present all endpoints with the same unified cut between base url and endpoint url, which makes me think that it should be possible to somehow influence the choice where that cut is made.

But how?

Thanks in advance!

Using Springfox 2.2.2 Swagger, Java 7, Spring 2.2.0 (no JAX-RS),
Project: https://github.com/europeana/api2/ (develop)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions