Saravanan666/pypi-org huggingface dataset:
Package: openapi3-fuzzer
Simple fuzzer for OpenAPI 3 specification based APIsWhat does this fuzzer do?Sends various attack patterns to all the paths defined in an OpenAPI 3 definition file, using the OAS3 definition to create populate requests.Verifies if the responses matches those defined in the OAS3 definition file, complains and exit(2) if it doesn't.Complains loudly and exit(1) if a path returns an internal server error (status code 500 and higher)Why does this OpenAPI fuzzer exist?To make it easy to integrate an OpenAPI 3 fuzzer in an existing API.How do I use this?Install the fuzzer using itspip packageAdd at least the following packages to requirements-test.txt:coverage==5.0.3openapi3-fuzzeradal==1.2.2Flask-Testing==0.7.1Generate OpenAPI (https://github.com/OpenAPITools/openapi-generator)Create a test_fuzzing file in the test location using the template below:importadalimportconfigfromopenapi3_fuzzerimportFuzzItfromopenapi_server.testimportBaseTestCasedefget_token():"""Create a token for testing:return:"""oauth_expected_authenticator=authenticatoruriclient_id=appidclient_secret=secretresource=resource/audience# get an Azure access token using the adal librarycontext=adal.AuthenticationContext(oauth_expected_authenticator)token_response=context.acquire_token_with_client_credentials(resource,client_id,client_secret)access_token=token_response.get('accessToken')returnaccess_tokenclassTestvAPI(BaseTestCase):deftest_fuzzing(self):FuzzIt("openapi.yaml",get_token(),self)Run using ourunittest containeror via thePython Unittest FrameworkWhat OAS3 items are supported?Based onOpenAPI specification 3.0.2:OperationSupportedGETYesPOSTYesPUTYesDELETEYesHEADYesOPTIONSnoPATCHnoTRACEnoParameter inSupportedpathYesquerynoheadernocookienoProperty typesSupportedstringYesintegerYesnumberYesarrayYesnoneYesbooleannoExample outputInternal server error:GET fuzzing /managers/expenses/{expenses_id}/attachments

* INTERNAL SERVER ERROR
  Endpoint returned 500 but expected one of [200]
  GET https://dev.myapi.example/managers/expenses/99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999/attachmentsResponse doesn't conform to the OAS3 spec:--------------------------------------------
GET fuzzing /employees/expenses/{expenses_id}

- Unexpected status code
  Endpoint returned 404 but expected one of [200, 'default']
  GET https://dev.myapi.example/employees/expenses/)$#***^POST fuzzing /employees/expenses/{expenses_id}

- Unexpected status code
  Endpoint returned 400 but expected one of [201, 'default']
  POST https://dev.myapi.example/employees/expenses
{
    "amount": "123",
    "cost_type": "123",
    "note": ";sleep 10",
    "transaction_date": "123"
}ContributorsA special thanks to the contributors outside of VWT Digital.NameContributionJorrit FolmerStarted the project and created a base for the fuzzer.LICENSEGPL3
Package: openapi3-parser-x
OpenAPI ParserA simple package to parse your OpenAPI 3 documents into Python object to work with.How to installTo install package run the following commandpip install openapi3-parserHow to useExample of parser usage>>> from openapi_parser import parse
>>> content = parse('swagger.yml')
>>> print(content)Get application serversfromopenapi_parserimportparsespecification=parse('data/swagger.yml')print("Application servers")forserverinspecification.servers:print(f"{server.description}-{server.url}")# Output## >> Application servers# >> production - https://users.app# >> staging - http://stage.users.app# >> development - http://users.localGet list of application URLsfromopenapi_parserimportparsespecification=parse('tests/data/swagger.yml')urls=[x.urlforxinspecification.paths]print(urls)# Output## >> ['/users', '/users/{uuid}']Get operation with supported HTTP methodsfromopenapi_parserimportparsespecification=parse('tests/data/swagger.yml')forpathinspecification.paths:supported_methods=','.join([x.method.valueforxinpath.operations])print(f"Operation:{path.url}, methods:{supported_methods}")# Output## >> Operation: /users, methods: get,post# >> Operation: /users/{uuid}, methods: get,put
Package: openapi3v1
This project is forked fromhttps://github.com/Dorthu/openapi3Additional capabilities added on top of itA PythonOpenAPI 3 Specificationclient and validator for Python 3.Validation ModeThis module can be run against a spec file to validate it like so:python3 -m openapi3 /path/to/specUsage as a ClientThis library also functions as an interactive client for arbitrary OpenAPI 3
specs. For example, usingLinode’s OpenAPI 3 Specificationfor reference:from openapi3 import OpenAPI
import yaml

# load the spec file and read the yaml
with open('openapi.yaml') as f:
    spec = yaml.safe_load(f.read())

# parse the spec into python - this will raise if the spec is invalid
api = OpenAPI(spec)

# call operations and receive result models
regions = api.call_getRegions()

# authenticate using a securityScheme defined in the spec's components.securitySchemes
api.authenticate('personalAccessToken', my_token)

# call an operation that requires authentication
linodes  = api.call_getLinodeInstances()

# call an opertaion with parameters
linode = api.call_getLinodeInstance(parameters={"linodeId": 123})

# the models returns are all of the same (generated) type
print(type(linode))                      # openapi.schemas.Linode
type(linode) == type(linodes.data[0])    # True

# call an operation with a request body
new_linode = api.call_createLinodeInstance(data={"region":"us-east","type":"g6-standard-2"})

# the returned models is still of the correct type
type(new_linode) == type(linode)     # TrueHTTP basic authentication and HTTP digest authentication works like this:# authenticate using a securityScheme defined in the spec's components.securitySchemes
# Tuple with (username, password) as second argument
api.authenticate('basicAuth', ('username', 'password'))Running TestsThis project includes a test suite, run viapytest.  To run the test suite,
ensure that you’ve installed the dependencies and then runpytestin the root
of this project.RoadmapThe following features are planned for the future:Request body models, creation, and validation.Parameters interface with validation and explicit typing.Support for more authentication types.Support for non-json request/response content.Full support for all objects defined in the specification.
Package: openapi-annotations
OpenAPI Python annotationsGenerate OpenApi with code-first annotations. Use type-hint info and docstrings to document your API. This is an experimental library!Getting StartedInstall the packagepip install openapi-annotationsDocument a modelfromopenapi_annotationsimportapi_model,api_property,StringFormats@api_modelclassEvent:"""The first model from this API."""@propertydefid(self)->str:returnself._id@id.setter@api_property(data_format=StringFormats.Uuid,nullable=True)defid(self,value:str):"""The id of the object."""self._id=value@propertydefdocumented_property(self)->str:returnself._documented_property@documented_property.setter@api_property()defdocumented_property(self,value:str):"""Property documentation."""self._documented_property=valueDocument a routefromopenapi_annotationsimportapi_route,api_responsefromhttpimportHTTPStatusfrom.modelsimportEvent# My custom model@api_response(HTTPStatus.CREATED,Event)@api_response(HTTPStatus.BAD_REQUEST)@api_response(HTTPStatus.INTERNAL_SERVER_ERROR)@api_route(Methods.Post,f'events/{{eventId}}',Event)defevents_post(body=None):"""Creates a new event and returns it."""result={}returnjson.dumps(result),201View the swagger:import.controllers# Make sure you import all files containing annotationsfromopenapi_annotationsimportget_specimportjsonwithopen('./openapi.json','w')asfile:file.write(json.dumps(spec,indent=4))
Package: openapiart
openapiart - OpenAPI Artifact GeneratorTheOpenAPIArt(OpenAPI Artifact Generator) python package does the following:pre-processes OpenAPI yaml files according to theMODELGUIDEusing the path keyword bundles all dependency OpenAPI yaml files into a single openapi.yaml filepost-processes anyMODELGUIDEextensionsvalidates the bundled openapi.yaml filegenerates a.protofile from the openapi fileoptionally generates a static redocly documentation fileoptionally generates apython ux sdkfrom the openapi fileoptionally generates ago ux sdkfrom the openapi fileGetting startedInstall the packagepip install openapiartGenerate artifacts from OpenAPI files"""The following command will produce these artifacts:- ./artifacts/openapi.yaml- ./artifacts/openapi.json- ./artifacts/openapi.html- ./artifacts/sample.proto- ./artifacts/sample/__init__.py- ./artifacts/sample/sample.py- ./artifacts/sample/sample_pb2.py- ./artifacts/sample/sample_pb2_grpc.py- ./pkg/openapiart.go- ./pkg/go.mod- ./pkg/go.sum- ./pkg/sanity/sanity_grpc.pb.go- ./pkg/sanity/sanity.pb.go"""importopenapiart# bundle api files# validate the bundled file# generate the documentation fileart=openapiart.OpenApiArt(api_files=["./openapiart/tests/api/info.yaml","./openapiart/tests/common/common.yaml","./openapiart/tests/api/api.yaml",],artifact_dir="./artifacts",protobuf_name="sanity",extension_prefix="sanity",)# optionally generate a python ux sdk and python protobuf/grpc stubsart.GeneratePythonSdk(package_name="sanity")# optionally generate a go ux sdk and go protobuf/grpc stubsart.GenerateGoSdk(package_dir="github.com/open-traffic-generator/openapiart/pkg",package_name="openapiart")SpecificationsThis repository is based on theOpenAPI specificationwhich is a standard, language-agnostic interface to RESTful APIs.Modeling guide specific to this package
Package: openapi-bridge
openapi-bridgeOpenAPI endpoint decorator with pydantic (>=2.0.0) integration.Allows for almost seamless integration of pydantic models with OpenAPI,
generating YAML for the endpoint from type hints.Using the@endpointdecoratorExample:@endpoint("/foo/{foo_id}")deffoo(*,foo_id:int,debug:Optional[bool]=False)->pydantic_models.Foo:"""Foo summary.Lengthy foo description.@param foo_id The Foo ID in the database.@param debug Set to True to include debug information."""result=_do_something(id,debug)returnpydantic_models.Foo(**result)As you can see from the example, the decorator takes a path (which may include
a path parameter, in this caseid). You can also give it an HTTP method, a
path prefix (e.g. to distinguish between internal and external API functions),
and security directives.Information about the endpoint is gathered from both the type annotations of
the decorated function and its docstring.(!) Every parameter (except the optionaluser) must be keyword-only, have a
type hint and a @param help text in the docstring. Un-annotated or undocumented
parameters are considered to be a hard error and will raise an exception on
startup.Normally you can just return an instance of the annotated type, and the
decorator will handle it correctly, adding an HTTP status 200. If you need to
return something else, e.g. some redirect or a 204 ("no content"), you can to
return a(raw_content, http_status)tuple instead, e.g.:returnNone,204The docstring of an endpoint contains its summary, description, the section the
documentation is listed under, and parameter help, as well as (optionally) its
response in various circumstances.The summary is the first paragraph of the docstring; the description is taken
to be any further paragraphs until the first @keyword.We recognize the following keywords to designate parts of the documentation:@section <section name>: endpoint is listed in this section.@param <param name> <help text>: explanation of the given parameter.@example <param name> <example text>: example values of the parameter.@response <http status> <JSON>: allows for non-standard responses.YAML GenerationIf you're building a Connexion app, you can use the collected endpoints in yourcreate_app()function:defcreate_app():# TODO: import all modules with @endpoints here!!api_specs={"paths":openapi_bridge.PATHS["default"],**openapi_bridge.get_pydantic_schemata(pydantic_models),}connexion_app.add_api(api_specs)(!) You need to import all the modules with endpoints here in order to register
them. This is easy to forget! If you test a new endpoint and only ever get 404,
you might have forgotten to import that module ;-)
Package: openapi-client-generator
OpenAPI Client GeneratorThis CLI utility allows you to generate Python client packages from OpenAPI v3 specifications.
The project aims at supporting any generic valid specification.Featuresworks on Python 3.8 and above;generates clients with type hints to aid static analysis of higher level interfaces that would use the clients;supports streaming endpoints.InstallationYou can install it from PyPI:pipinstallopenapi-client-generatorAfterwards, use a CLI utility calledopenapi-client-generator:$openapi-client-generator--helpusage:openapi-client-generator[-h][-V]{gen}...OpenAPIClientGeneratoroptionalarguments:-h,--helpshowthishelpmessageandexit-V,--versionshowprogram'sversionnumberandexitsub-commands:validsub-commands{gen}additionalhelpgenGenerateclientforaprovidedschema(JSON,YAML).ContributingCloning this repoThe proper way to clone this repo is:gitclone--recurse-submodules<repo-url><local-project-root>cd<local-project-root># for showing submodule status with `git status`gitconfigstatus.submodulesummary1# for logging submodule diff with `git diff`gitconfigdiff.submodulelogTest frameworkThe project usesNixfor bootstrapping its dev environment.You can run existing test suite with$ nix-shell --run "make test"DocumentationDocumentation is hosted on ReadTheDocs:https://openapi-client-generator.readthedocs.io/en/develop/ChangelogSeeCHANGELOG.LICENSEMIT
Package: openapi-cli-tool
openapi-cli-toolOpenAPI (Swagger 3.x) CLI Tool.Supports multiple file extensions (json|yaml|yml).Can list up defined API paths.Display an API specification which is resolved ($ref).Bundle multi-file into one (output to json|yaml|html).OAS interactive scaffolding.RequirementsPython 2.7, 3.4 <=.InstallationWith pip:$pipinstallopenapi-cli-toolManually:Clone the repository and execute the Python installation command on your machine.$pip-rrequirements.txtinstall
$pythonsetup.pyinstallThenopenapi-cli-toolcommand is installed.Usage$ openapi-cli-tool --help
Usage: openapi-cli-tool [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  bundle    Bundle multiple files into one.
  list      List up API paths in a file or directory.
  resolve   Display `$ref` resolved API specification.
  scaffold  Interactively create a simple OpenAPI Specification.BundleBundle multi-file specifications into one, regardless of file extension (json|yaml|yml).$ openapi-cli-tool bundle --help
Usage: openapi-cli-tool bundle [OPTIONS] FILE_PATHS

  Bundle multiple files into one.

Options:
  -f, --file TEXT  Load common objects such as info and servers from a
                   specific file. Default is a file which is the top of list
                   command result.
  -t, --type TEXT  Export data type. {json|yaml|html}  [default: json]
  --help           Show this message and exit.example:$ openapi-cli-tool bundle -t html file1.json file2.yaml` > ./specification.htmlIn the html file, an unpkg version ofswagger-uiis embedded. Rendered screenshot below:ListList up API paths from a file/directory regardless of the file extension (json|yaml|yml).$openapi-cli-toollist`find./spec`MethodPathFile
-----------------------------------------------------------
PUT/avatar./tests/resources/spec/sample.yml
GET/follwers./tests/resources/spec/folder1/sample2.yaml
POST/follwers./tests/resources/spec/folder1/sample2.yaml
PUT/follwers./tests/resources/spec/folder1/sample2.yaml
POST/pets./tests/resources/spec/sample.yml
GET/posts./tests/resources/spec/folder1/sample.json
POST/posts./tests/resources/spec/folder1/sample.json
GET/users./tests/resources/spec/folder1/sample.json
POST/users./tests/resources/spec/folder1/sample.jsonResolveDisplay an API specification which is resolved from  a multi-file API specification via $ref pointers.Usage: openapi-cli-tool resolve [OPTIONS] METHOD PATH FILE_PATHS

  Display `$ref` resolved API specification.

Options:
  -t, --type TEXT  Export data type. {json|yaml}  [default: json]
  --help           Show this message and exit.example:$openapi-cli-toolresolvepost/cats`find./tests/resources/spec`ScaffoldInteractively input information of your API.A simple OpenAPI Specification is generated from your prompt.$openapi-cli-toolscaffold

Pleaseentertitle[""]:sample
Pleaseenterversion[v1.0]:
Pleaseenterlicense[Apache2.0]:
Pleaseenterserverurl[http://example.com]:
Pleaseenterpath[/]:/example
Pleaseentermethodfor/example[get|post|put|delete|head|option|trace]:get
Pleaseenterdescriptionforget/example[""]:samplegetendpoint
Pleaseenterresponsecodeforget/example[200]:
Package: openapi-core
AboutOpenapi-core is a Python library that adds client-side and server-side support
for theOpenAPI v3.0andOpenAPI v3.1specification.Key featuresValidationandunmarshallingof request and response data (including webhooks)Integrationwith popular libraries (Requests, Werkzeug) and frameworks (Django, Falcon, Flask, Starlette)Customization with media typedeserializersand formatunmarshallersSecuritydata providers (API keys, Cookie, Basic and Bearer HTTP authentications)DocumentationCheck documentation to see more details about the features. All documentation is in the “docs” directory and online atopenapi-core.readthedocs.ioInstallationRecommended way (via pip):pip install openapi-coreAlternatively you can download the code and install from the repository:pip install -e git+https://github.com/python-openapi/openapi-core.git#egg=openapi_coreFirst stepsFirstly create your OpenAPI object.fromopenapi_coreimportOpenAPIopenapi=OpenAPI.from_file_path('openapi.json')Now you can use it to validate and unmarshal against requests and/or responses.# raises error if request is invalidresult=openapi.unmarshal_request(request)Retrieve validated and unmarshalled request data# get parameterspath_params=result.parameters.pathquery_params=result.parameters.querycookies_params=result.parameters.cookiesheaders_params=result.parameters.headers# get bodybody=result.body# get security datasecurity=result.securityRequest object should implement OpenAPI Request protocol. CheckIntegrationsto find officially supported implementations.For more details read aboutUnmarshallingprocess.If you just want to validate your request/response data without unmarshalling, read aboutValidationinstead.Related projectsopenapi-spec-validatorPython library that validates OpenAPI Specs against the OpenAPI 2.0 (aka Swagger), OpenAPI 3.0 and OpenAPI 3.1 specification. The validator aims to check for full compliance with the Specification.openapi-schema-validatorPython library that validates schema against the OpenAPI Schema Specification v3.0 and OpenAPI Schema Specification v3.1.bottle-openapi-3OpenAPI 3.0 Support for the Bottle Web Frameworkpyramid_openapi3Pyramid addon for OpenAPI3 validation of requests and responses.tornado-openapi3Tornado OpenAPI 3 request and response validation library.LicenseThe project is under the terms of BSD 3-Clause License.
Package: openapi-drf-codegen
OpenAPI DRF CodegenCLI application for generating DRF serializers from openapi.yaml filesNOTE: This program was mostly written for personal use. You may also find it usefulInstallation:pipinstallopenapi-drf-codegen# orpoetryaddopenapi-drf-codegenUsage:openapi-drf-codegen-i/path/to/openapi/-ppackage-name-v0.0.1A new 'build' directory will be created in your directory where you are. To build a python package for installation, you can do the following:cdbuild/&&poetrybuildImportant: at the moment, the generator does not provide all possible cases for code generation. Maybe I'll add them in the future if I find themContributionIf you want to participate in the project and fix some details or add functionality - feel free to contribute
Package: openapi-elm-client
openapi-elm-clientgenerates Elm client code from OpenAPI 2.0 specification.UsageBasic usage is like this:openapi-elm-client my_spec.yaml Some.Module.NameThis will read the OpenAPI spec frommy_spec.yamland create an Elm module namedSome.Module.Name. This writes the
output to stdout, so a more typical invocation might be:openapi-elm-client my_spec.yaml Some.Module.Name > src/Some/Module/Name.elmGenerated codeopenapi-elm-clientproduces a named type alias for each definition in the input spec. It also produces a function for
calling each endpoint defined in the spec, along with appropriate JSON encoders and decoders.TestsYou can run the tests by first installing the test dependencies:pip install ".[test]"and then invoking pytest:pytest testsApproval testsopenapi-elm-clientusesgodkjennfor approval testing. We
have collection of input specs along with “approved” versions of the code generated byopenapi-elm-client; if the
generated code ever changes, we have to see if it’s still correct.
Package: openapi-ext-tools
openapi-ext-toolsextended tools for openapi specbundle multiple yaml files into single openapi.yaml$openapi-spec-cli--help
usage:openapi-spec-cli[-h]--spec-pathSPEC_PATH[--bundled-spec-pathBUNDLED_SPEC_PATH][--verbose]optionalarguments:-h,--helpshowthishelpmessageandexit--spec-pathSPEC_PATHsetpathtoopenapispecfile--bundled-spec-pathBUNDLED_SPEC_PATHsetpathtobundledspecfile--verbosesetverbosemodeHow to useCurrently, bundling only support components object.Thetests/fixtures/simple/openapi.yamlis openapi specification file and a part of schemas is defined intests/fixtures/simple/schemas.yaml....content:application/json:schema:$ref:'schemas.yaml#/components/schemas/User'...For example,Userschema is defined like this.components:schemas:User:type:objectproperties:id:type:integerformat:int64username:type:stringfirstName:type:stringlastName:type:stringbirthday:type:stringformat:dateemail:type:stringpassword:type:stringphone:type:stringuserStatus:type:integerdescription:User Statusformat:int32Runopenapi-spec-clito bundle yaml files and create singleopenapi.yaml.$openapi-spec-cli--spec-pathtests/fixtures/simple/openapi.yaml2019-05-1111:56:12,337openapi.spec.extINFOwrotebundledspecfileto"bundled_openapi.yaml"2019-05-1111:56:12,402openapi.spec.extINFOvalidatingbundledspec:OKYou can confirmbundled_openapi.yamlin current directory. Then, all schemas inschemas.yamlare moved tobundled_openapi.yamland a$reffield also reffers as Local Reference....content:application/json:schema:$ref:'#/components/schemas/User'...
Package: openapi-fastapi-client
Openapi yaml file to FastApi ClientA commandline tool to generate Apifunctionsand their requiredpydantic ModelSchema from anopenapi.yamlof version 3Installationpipinstallopenapi-fastapi-clientUsageopenapi-fastapi-client./openapi.yaml./my-clientopenapi-fastapi-client./openapi.yaml./my-client--asyncthis will generate under the foldermy-clientfollowing files__init__.pyif not existsapi.pyhere are all function calls to the external apischema.pyhere are all pydantic ModelsArgumentsOPENAPI_FILE  [required]OUTPUT_PATH   [required]Options--syncAll requests to the client are synchronous.default--asyncAll requests to the client are asynchronous withaiohttp.Helpopenapi-fastapi-client--help
Package: open-api-framework
1Welcome to open_api_framework’s documentation!Version:0.1.0Source:https://github.com/maykinmedia/open_api_frameworkKeywords:<keywords>PythonVersion:3.11<One liner describing the project>Contents1Welcome to open_api_framework’s documentation!2Features3Installation3.1Requirements3.2Install4Usage5Local development2Features……3Installation3.1RequirementsPython 3.9/3.11 or aboveDjango 3.2/4.2 or newer3.2Installpipinstallopen_api_framework4Usage<document or refer to docs>5Local developmentTo install and develop the library locally, use:.. code-block:: bashpip install -e .[tests,coverage,docs,release]When running management commands viadjango-admin, make sure to add the root
directory to the python path (or usepython-mdjango <command>):exportPYTHONPATH=.DJANGO_SETTINGS_MODULE=testapp.settingsdjango-admincheck# or other commands like:
# django-admin makemessages -l nl