Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative and absolute paths and rewriting #94

Open
ghost opened this issue Sep 5, 2018 · 1 comment
Open

Relative and absolute paths and rewriting #94

ghost opened this issue Sep 5, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Sep 5, 2018

The OpenApi spec allows relative and absolute paths to be used in $ref yet when we attempt this we get told the specification file cannot be loaded.

I have looked at rewriting this, and the best we have come up with is -spec-rewrite-url=./=http://localhost:3123/ \ and prefixing all of our paths with ./.

This will not scale well, as any paths that contain ../ to go up a level will also be rewritten incorrectly.

I would like to posit that the replacement become anchored to the beginning of the $ref string, and not all matches within the string.

@ghost
Copy link
Author

ghost commented Sep 5, 2018

If I try to do this with simple specification allowed relative paths, here is the command I run:

./dapperdox \
    -spec-dir=spec/ \
    -spec-filename=/openapi.yaml \
    -bind-addr=0.0.0.0:3123 \
    -site-url=http://localhost:3123 \
    -log-level=debug

Heres the cli output:

2018/09/05 21:53:51 DapperDox server version 1.2.2 starting
2018/09/05 21:53:51 Configuration:
2018/09/05 21:53:51 	          BindAddr: 0.0.0.0:3123
2018/09/05 21:53:51 	         AssetsDir: 
2018/09/05 21:53:51 	  DefaultAssetsDir: assets
2018/09/05 21:53:51 	           SpecDir: spec/
2018/09/05 21:53:51 	      SpecFilename: [/openapi.yaml]
2018/09/05 21:53:51 	             Theme: 
2018/09/05 21:53:51 	          ThemeDir: 
2018/09/05 21:53:51 	          LogLevel: debug
2018/09/05 21:53:51 	           SiteURL: http://localhost:3123
2018/09/05 21:53:51 	    SpecRewriteURL: []
2018/09/05 21:53:51 	DocumentRewriteURL: []
2018/09/05 21:53:51 	     ForceSpecList: %!s(bool=false)
2018/09/05 21:53:51 	        ShowAssets: %!s(bool=false)
2018/09/05 21:53:51 	         ProxyPath: []
2018/09/05 21:53:51 	    TLSCertificate: 
2018/09/05 21:53:51 	            TLSKey: 
2018/09/05 21:53:51 listening on 0.0.0.0:3123
2018/09/05 21:53:51 Registering specifications
2018/09/05 21:53:51 - Scanning base directory /Volumes/Projects/thoughtriver/openapi/dapperdox/spec
2018/09/05 21:53:51   - /Volumes/Projects/dapperdox/spec/openapi.yaml
2018/09/05 21:53:51     = URL : /openapi.yaml
2018/09/05 21:53:51   - /Volumes/Projects/dapperdox/spec/paths.yaml
2018/09/05 21:53:51     = URL : /paths.yaml
2018/09/05 21:53:51 Importing OpenAPI specifications from http://127.0.0.1:3123/openapi.yaml
2018/09/05 21:53:51 [XVlBzgbaiCMRAjWwhTHc] [info] GET /openapi.yaml (200, 487µs)
2018/09/05 21:53:51 Load specification error: open paths.yaml: no such file or directory

Here's the openapi.yaml contents:

openapi: "3.0.0"
info:
  version: 0.1.0
  title: Test Api
paths:
  "/pets":
    $ref: "paths.yaml#/pets"

Heres the paths.yaml contents:

pets:
  get:
    description: Returns all pets from the system that the user has access to
    responses:
      '200':
        description: A list of pets.
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/pet'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants