Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Falcon OpenApi is a plugin for the Falcon Web Framework.
pip3 install falcon-openapi
Reads an openapi spec and provides automatic routing to Falcon resources. This is achieved by defining either an operationId or x-falcon property on an endpoint. This removes the need to define all endpoints in your main Falcon file. Instead just set the router to OpenApiRouter.
This router inherits from the default Falcon CompiledRouter class, so it supports all methods available to the default router.
Supports json files, yaml files, raw json strings, and raw yaml strings. If no params are specified the plugin will attempt to find openapi-spec.yml
or openapi-spec.yaml
in the current working directory (see example for structure).
import falcon
import json
import yaml
from falcon_openapi import OpenApiRouter
spec = {
'paths': {
'/foo': {
'get': {
'operationId': 'controllers.foo.Foo.on_get'
}
}
}
}
# load from file
app = falcon.API(
router=OpenApiRouter(file_path='openapi-spec.yml')
)
# load from raw json
app = falcon.API(
router=OpenApiRouter(raw_json=json.dumps(spec))
)
# load from raw yaml
app = falcon.API(
router=OpenApiRouter(raw_yaml=yaml.dump(spec))
)
The example below will route all GET
/foo
requests to controllers.foo.Foo.on_get
. Where controllers.foo
is the module name, Foo
is the class name, and on_get
is the method name. Every operationId in your spec should be unique (See openapi operationId). All three parts of the operationId must be specified for the router to work.
openapi: "3.0.0"
info:
version: 1.0.0
title: Falcon Openapi Demo
paths:
/foo:
get:
summary: Do foo things
operationId: controllers.foo.Foo.on_get
I am unsure if operationId will make it into the final version. I may change this to only check for the x-falcon property. I plan on doing more research to determine if this an appropriate way to use the operationId property.
The example below will route all POST
/foo
requests to the module controllers.foo
, the class Foo
, and the method on_post
. Note: the standard in Falcon is to use the naming scheme on_get, on_post, etc. If no method name is defined in x-falcon, the plugin will attempt to route to the appropriate on_* method.
openapi: "3.0.0"
info:
version: 1.0.0
title: Falcon Openapi Demo
paths:
/foo:
post:
summary: Do foo things
x-falcon:
module: controllers.foo
class: Foo
method: on_post
FAQs
Falcon router to map openapi spec to resources
We found that falcon-openapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.