question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support API mounting

See original GitHub issue

This follows a comment on issue #647.

It would be great to be able to mount API specs onto another spec for service composition.

As an example, I have two independent services A and B, both having their own OAS files. I would like to ‘merge’ A and B together into a single, centralized spec.

If both services have, say, a /resource endpoint, I would like to discriminate them by prefixing their paths with the name of the services, /A and /B respectively (resulting in /A/resource and /B/resource).

One naive solution would be to list and redefine each path in the root OAS file and $ref the related A or B content, but changing the design of either A or B would require updating the root OAS file.

A possible alternative would be to support path nesting (discarded here):

paths:
  '/A':
    '/resource':
       get:
           # ....
  '/B':
    '/resource':
       get:
           # ....

I suggest considering introducing a mount field under Path Item Objects and taking a Paths Object:

paths:
  '/A':
    mount:
      $ref: 'A.yaml#/paths'
  '/B':
    mount:
      $ref: 'B.yaml#/paths'

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

1reaction
nickshoecommented, Mar 2, 2022

@MaxenceMaire thanks for clarifying the use of $ref.

My example was an alternative proposal. Anyways, I like your proposal too (I’ve put a thumbs up).

We ended up defining separate OpenAPI documents for each microservice and using them independently. It would be nice to be able to squash together separate specs, without having to break them down according to the root keys of the spec. If conflicts arise, then one should handle them by changing one of the sub-specs.

1reaction
MaxenceMairecommented, Feb 28, 2022

I have the same use case, but I would rather show in some way, that under this path there is another API with its own spec and so I would rather reference not the paths included in its OAS, but the full OAS file. So more like a link to another API than a $ref.

@SmallhillCZ You make a good point. Especially since mounted APIs can live on different servers (or to specify useful metadata), I think it makes sense to include a complete OAS and not just the paths. A $ref could still work though I guess? (e.g. $ref: 'A.yaml' instead of $ref: 'A.yaml#/paths').

Read more comments on GitHub >

github_iconTop Results From Across the Web

Welcome - AWS Support - AWS Documentation
The AWS Support API Reference is intended for programmers who need detailed information about the AWS Support operations and data types. You can...
Read more >
api-mount - npm
Library for making communication between front-end and back-end simple. Latest version: 1.0.13, last published: 2 years ago.
Read more >
Cloud Support API V2 User Guide - Documentation
This page describes how to get started with version 2 of the cloudsupport.googleapis.com API, in particular, the v2beta endpoint. You can integrate the...
Read more >
Mount API · Issue #977 · encode/httpx - GitHub
Here's a bit of a proposal for how a more consistent, and generalised mount API might look... Support a .transports = {'http': ...,...
Read more >
Installing and maintaining IBM API Connect
To ensure that your IBM API Connect cloud functions, your cloud must have the necessary system requirements to support the installation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found