Code Monkey home page Code Monkey logo

falcon-openapi's People

Contributors

sam-kleiner avatar tomskikh avatar tuohis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

falcon-openapi's Issues

falcon-openapi does not work with Falcon >= 2.0.0

Falcon 2.0.0 brought breaking changes to the CompiledRouter.add_route() API. App launching fails with the error:

  File "/home/tuohis/test/openapi_test.py", line 18, in <module>
    router=OpenApiRouter(raw_json=json.dumps(spec))
  File "/home/tuohis/test/.venv/lib/python3.5/site-packages/falcon_openapi/router.py", line 56, in __init__
    self.add_route(path, method_map, Class)
  File "falcon/routing/compiled.py", line 121, in falcon.routing.compiled.CompiledRouter.add_route
TypeError: add_route() takes exactly 3 positional arguments (4 given)

Allow user to select order of precedence for x-falcon and operationId

Hi,
Currently I wish to use OpenAPI schema as a contract between frontend and backend in my project.
However both js libs and falcon-openapi uses operationId and assumes different format (in js it is translated directly into method). Change of order of precedence would solve issue. Due to backward compatibility I propose to add parameter to OpenApiRouter, which will switch from operationId first to x-falcon first if needed (for the sake of backward-compatibility).

Regards,
Adrian

ValueError: attempted relative import beyond top-level package

This error occurs when:

test\
  api\
    controller.py
  model\
    model.py
  app.py
  api.yml

api.yaml

paths:
  /controller:
    get:
      summary: summary
      operationId: api.controller.controller1.on_get

app.py

import falcon
from falcon_openapi import OpenApiRouter

app = falcon.API(
    router=OpenApiRouter(file_path='api.yml'),
)

model\ model.py

class model1:
    pass

api\controller.py

from ..model.model import model1

class controller1(object):
    def on_get(self, req, resp):
        resp.body = 'test'

Traceback

Traceback (most recent call last):
  ...
  ...
  ...
  File "/test/api/controller.py", line 1, in <module>
	from ..model.model import model1
  ValueError: attempted relative import beyond top-level package

Typo or intentional?

I saw this in router.py. Look at the last line:

class OpenApiRouter(CompiledRouter):
    def __init__(self, file_path='openapi-spec.yml', raw_json='', raw_yaml=''):
        super().__init__()

        if raw_json != '':
            self.openapi = json.loads(raw_json)
        elif raw_yaml != '':
            self.openapi = yaml.load(raw_yaml)
        else:
            if not Path(file_path).exists() and file_path == 'openapi-spec.yml':
                file_path = 'openapi-spec.yaml'

It seems that, if the user specified "openapi-spec.yml," they did not mean "openapi-spec.yaml."

URI path from servers not obeyed?

I created a new example while testing out. As an aside, you are free to use this example for your project. I think it would be useful to show people that you need to qualify that the controllers are a part of the falcon-openapi module and importing from the users' own module to the falcon-openapi controllers need to be properly qualified on the import.

The problem I'm having is that the servers URI path is not being obeyed in the YAML file, e.g.:

---
info:
  version: 0.0.0
  title: Example
  license:
    name: MIT
servers:
  - url: http://localhost/example/v1
paths:
    "/health":
        get:
            summary: A simple health check.
            responses:
                200:
                    content:
                        application/json:
                            schema:
                                type: object
                                properties:
                                    name: string
                                    version: string
                                    git_hash: string
            x-falcon:
                module: controllers.health
                class: HealthCheck
                method: on_get

I expect to need to access the controller with the URI: http://localhost:8000/example/v1/health but only http://localhost:8000/healthworks. Is this by design? I didn't have time to look at the implementation. You can see the sample project here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.