![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
A tool to test Swagger-powered APIs automatically through monkey testing.
Also allows for custom tests written directly in Swagger files
or in separate test suites.
Includes command-line and programmatic interfaces.
Install via npm install got-swag -g
.
got-swag <url> ... [-m] [-t <ms>] [-T] [-v] [-w]
Test a Swagger URL or file (YAML). Additional files are merged.
Options:
-m, --monkey Run monkey tests on GET endpoints
-l, --monkey-limit Maximum number of parameter combinations for each
monkey GET, default is 50
-t, --timeout <ms> Set a timeout (in milliseconds) for test step execution,
default is 2000 ms
-T, --trace Trace: Log requests and responses
-V, --version Show version
-w, --watch Watch the Swagger files and rerun tests on changes
Most Mocha options are valid. See https://mochajs.org/#usage for details.
The most basic usage of got-swag
is monkey testing:
Each GET endpoint of a service is validated using minimal variable
input, if any, and the definitions from the services' Swagger file.
The endpoints are requested with random authentication/variable combinations
until one combination leads to a response status code less than 400.
Just invoke got-swag on a URL with the -m
switch:
got-swag http://petstore.swagger.io/v2/swagger.json -m
See monkeystore.yaml for an example of input variables.
Additionally, got-swag
allows to embed custom tests in Swagger files
or separate test suites.
The test steps are written in JS using a small domain-specific language.
Every step is evaluated, even if a previous step failed.
For example, see petstore.yaml (embedded) and yoda.yaml (separate).
ok( actual )
equal( actual, expected )
notEqual( actual, expected )
deepEqual( actual, expected )
notDeepEqual( actual, expected )
strictEqual( actual, expected )
notStrictEqual( actual, expected )
deepStrictEqual( actual, expected )
notDeepStrictEqual( actual, expected )
match( actualString, expectedPattern )
validate( data, schema )
data
or schema
are omitted (strictly equal to undefined
),
the last response is validated against the current operation's response schemarequest( options )
options
is optional, see httpoptions.data
sets the request bodyget( url, headers )
post( url, data, headers )
put( url, data, headers )
delete( url, headers )
options( url, headers )
head( url, headers )
null
for url
to request the current endpointheaders
are optionalauth( securityDefinitionId, credentials, scopes )
scopes
are optional and inferred from the API if possibleencodeURIComponent( s )
encodes a string for URI transmissionlog( value )
logs a valuestringify( value )
alias of JSON.stringifyparse( string )
alias of JSON.parsebyteLength( string )
alias of Buffer.byteLength for computing 'Content-Length' header manuallymonkeyAuth()
tries to authenticate using known method/credentialsmonkeyGet()
tries to GET using known parametersvars
: Variables reusable for all tests
vars
in test steps, see examplereq
: Last request datares
: Last response data
res.statusCode
: Integer response status coderes.headers
: Response headersres.body
: String response bodyres.json
: Parsed JSON response, if anyapi
: Complete Swagger APIYou can define extension Swagger files on top of existing Swagger files
using the '#/path': value
syntax.
For reference, see extended-petstore.yaml.
var gotSwag = require( 'got-swag' );
// test api and report as JSON
gotSwag.test( 'swag.yaml', 'vars.yaml' ).then( function ( report ) {
console.log( report );
} );
// describe mocha tests in current suite
describe( 'My test suite', function () {
gotSwag.describe( 'swag.yaml', 'vars.yaml', { parent: this } );
} );
got-swag
only supports JSON.../node_modules/got-swag/lib/validate.js:24 throw new Error( result.errors );
in your console, it's a Node.js BugFAQs
Got Swag? A tool to test Swagger-powered APIs automatically
We found that got-swag demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.