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.
apispec plugin that generates OpenAPI specification (aka Swagger) for Falcon web applications.
pip install falcon-apispec
Works with apispec v1.0+
.
from apispec import APISpec
from apispec.ext.marshmallow import MarshmallowPlugin
import falcon
from falcon_apispec import FalconPlugin
from marshmallow import Schema, fields
# Optional marshmallow support
class CategorySchema(Schema):
id = fields.Int()
name = fields.Str(required=True)
class PetSchema(Schema):
category = fields.Nested(CategorySchema, many=True)
name = fields.Str()
# Create Falcon web app
app = falcon.API()
class RandomPetResource:
def on_get(self, req, resp):
"""A cute furry animal endpoint.
---
description: Get a random pet
responses:
200:
description: A pet to be returned
schema: PetSchema
"""
pet = get_random_pet() # returns JSON
resp.media = pet
# create instance of resource
random_pet_resource = RandomPetResource()
# pass into `add_route` for Falcon
app.add_route("/random", random_pet_resource)
# Create an APISpec
spec = APISpec(
title='Swagger Petstore',
version='1.0.0',
openapi_version='2.0',
plugins=[
FalconPlugin(app),
MarshmallowPlugin(),
],
)
# Register entities and paths
spec.components.schema('Category', schema=CategorySchema)
spec.components.schema('Pet', schema=PetSchema)
# pass created resource into `path` for APISpec
spec.path(resource=random_pet_resource)
spec.to_dict()
# {
# "info": {
# "title": "Swagger Petstore",
# "version": "1.0.0"
# },
# "swagger": "2.0",
# "paths": {
# "/random": {
# "get": {
# "description": "A cute furry animal endpoint.",
# "responses": {
# "200": {
# "schema": {
# "$ref": "#/definitions/Pet"
# },
# "description": "A pet to be returned"
# }
# },
# }
# }
# },
# "definitions": {
# "Pet": {
# "properties": {
# "category": {
# "type": "array",
# "items": {
# "$ref": "#/definitions/Category"
# }
# },
# "name": {
# "type": "string"
# }
# }
# },
# "Category": {
# "required": [
# "name"
# ],
# "properties": {
# "name": {
# "type": "string"
# },
# "id": {
# "type": "integer",
# "format": "int32"
# }
# }
# }
# },
# }
spec.to_yaml()
# definitions:
# Pet:
# enum: [name, photoUrls]
# properties:
# id: {format: int64, type: integer}
# name: {example: doggie, type: string}
# info: {description: 'This is a sample Petstore server. You can find out more ', title: Swagger Petstore, version: 1.0.0}
# parameters: {}
# paths: {}
# security:
# - apiKey: []
# swagger: '2.0'
# tags: []
pip install -r requirements.txt
pytest
FAQs
Falcon plugin for apispec documentation generator.
We found that falcon-apispec 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.