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

Overwriting paths in the spec #12

Closed
christian-heusel opened this issue Jan 27, 2019 · 1 comment
Closed

Overwriting paths in the spec #12

christian-heusel opened this issue Jan 27, 2019 · 1 comment

Comments

@christian-heusel
Copy link

Hey there! 😊
I wondered whether it would be possible to overwrite the paths that are currently taken from the decorator to something self-defined..

My problem is that my path is path='/api/exercises/{exercise_id:\d+}/{user_id:(\d+)+\/?}' but that should be kinda internal and I would like to overwrite this with path='/api/exercises/{exercise_id}/{user_id}' so I do not need to show my regex matches to the API user.

From the OpenAPI 2.0 standard:

paths:
  /users: <-- this 
    get:
      summary: Returns a list of users.

Currently this does not seem to be possible, atleast not from what I have tried... 😄
I would therefore suggest adding interpretion for the parameter path like this:

"""
---
path: 
  /api/exercises/{exercise_id}/{user_id}:
     get:
      tags:
        - "My API"
      summary: "return an exercise for given student"
      description: ""
      operationId: "exercise_student_get"
      produces:
        - "application/json"
      responses:
        200:
          description: successfull return of the exercise
          schema:
            $ref: "#/definitions/ExerciseStudent"
"""

Would that be possible?
All the best
Chris

@ergo
Copy link
Owner

ergo commented Jan 28, 2019

Hey @TheEbolaDoc,

I think when you do my_spec = spec.to_dict() you can easily alter the spec dictionary any way you want.
If you want add interpretation for docstring, that is handled directly by apispec package if I understood correctly what you want.

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

2 participants