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.

OpenAPI.next: Allow recursive paths

See original GitHub issue

In OpenAPI 2.0 paths like /user/{userId}/ and /user/{userId}/history considered as totally separate paths with nothing in common even path parameters. Moreover, you can’t define global parameters. I propose to allow for recursive paths, it would look like that:

paths:
  '/':
    parameters:
        - in: query
          name: globalParam
          type: string
    '/user/{userId}/':
       parameters:
          - in: path
            name: userId
            type: string
       get:
           #....
       '/history':
          get:
             #...

Pros:

  • non-breaking change, you can still define old style with /user/{userId}/ and /user/{userId}/history as separate paths.
  • allow for global parameters similar to #633, but without breaking change and JSON pointer stay nice and short #/parameters/<name>.
  • remove duplication for path parameters
  • at least party address @webron concern about adding description into pathObject see https://github.com/OAI/OpenAPI-Specification/pull/632#issuecomment-208094651
  • doesn’t conflict with possible extensions to path template mechanism, since recursive paths just concatenate.
  • if things like consume, produce, responses will be added into pathObject, remove a lot of duplication.
  • Easy to implement validation in JSON Schema using patternProperties.

Cons:

  • force tooling to process recursion and parameter merging

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:11
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
pduchesnecommented, Dec 5, 2018

This looks to me like a very useful feature, and i’m not sure why it was closed. Is it abandoned ?

Anyway, allow me to expose a legitimate usecase that only this nesting feature would fulfill (as fas as I understand): service composition. I’d happy to know if there’s another way to implement it.

Let’s say we have two independent services, A and B, each coming with their respective service descriptions serviceA.yaml, serviceB.yaml embedded at their roots. These services can potentially be deployed as standalone applications, on arbitrary URL subpaths, e.g. http://foo.com/serviceA, with its description then sitting at http://foo.com/serviceA/serviceA.yaml and looking like

servers:
  - description: Service A
    url: .
paths:
    ...

Then there’s a need to deploy a service C, that composes A and B under two subpaths : http://foo.com/serviceC/serviceA and http://foo.com/serviceC/serviceB. It should be possible to declare this composition in http://foo.com/serviceC/serviceC.yaml, containing something like :

servers:
  - description: Composed Service C
    url: .
paths:
  /serviceA:
    $ref: 'serviceA/serviceA.yaml'
  /serviceB:
    $ref: 'serviceB/serviceB.yaml'

Can you comment on this usecase ?

3reactions
IvanGoncharovcommented, Apr 11, 2016

It’s not an argument, just thing to note. Such functionality supported in WADL, Google Discovery, I/O Docs, RAML and probably other formats. So it looks like industry-wide practice, so it worth to consider.

But I don’t say OpenAPI should automatically borrow from other formats, especially from WADL.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to specify recursive paths in OpenAPI / Swagger
If I were using regex style, I would use something like this in the API spec: ... paths: /docs/{document-id}: get: ... /docs/{document-id}(/section ...
Read more >
Using $ref - Swagger
A common misconception is that $ref is allowed anywhere in an OpenAPI specification file. Actually $ref is only allowed in places where the...
Read more >
Customization - OpenAPI Generator
The empty object definition following AUTHORS.md allows the tool to infer the target output filename in the root of the output directory.
Read more >
An adventure in OpenAPI V3 code generation | Mux blog
OpenAPI Generator provides tooling which allows you to extract the ... any OpenAPI files using $ref parameters in paths would no-longer pass ...
Read more >
Your first OpenAPI document (Part II: data model) - Medium
OpenAPI is an open standard to describe REST APIs in a machine ... OpenAPI document, while in the next one we will cover...
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