![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.
@flowko/cypress-swagger-validation
Advanced tools
Validate your Swagger file and request responses against Swagger Endpoints
Validate your request responses against Swagger JSON Endpoints. AKA Contract Testing.
Do you use Cypress to perform API endpoint testing? Do you have Swagger/Openapi v3 schema? This is the plugin for you.
See the example swagger files to see how the usage below works with it.
Your swagger doc will need endpoints with content schema defined.
yarn add @flowko/cypress-swagger-validation
Then in your cypress Plugins file:
const {SwaggerValidation} = require('@flowko/cypress-swagger-validation');
module.exports = (on, config) => {
// ...
on('task', SwaggerValidation(config));
// ...
return config;
};
describe('Basic API checks', () => {
it('Should be a valid swagger schema', function () {
cy.task('validateSwaggerFile', {
file: './testing/swagger.json', // optional path or full URL, see below
}).should('equal', null);
});
it('Should return a valid health payload', function () {
cy.request('/healthz').then($response => {
// Check the swagger schema:
cy.task('validateSwaggerSchema', {
file: './testing/swagger.json', // optional path or full URL, see below
endpoint: '/healthz',
method: 'get',
statusCode: 200,
responseSchema: $response.body,
verbose: true, // optional, default: false
}).should('equal', null);
});
});
});
This can either be a file on disk or a URL.
When using a file on disk and due to the fact that this plugin runs on the Cypress Backend, the location of the file must be defined as either the full path on disk or relative path to the running of the cypress command.
You can define the swagger file location either with an environment variable which can apply to all tests:
config.env.swaggerFile
or within each individial test using the options below.
Option | Description | Optional | Default |
---|---|---|---|
file | The location of the swagger file to use for contract testing | true | config.env.swaggerFile |
Option | Description | Optional | Default |
---|---|---|---|
file | The location of the swagger file to use for contract testing | true | config.env.swaggerFile |
endpoint | The name of the swagger endpoint to check | ||
method | The request method of the endpoint | ||
statuscode | The http status code beneath the method | ||
responseSchema | The payload of the API response to validate | ||
verbose | Console.log more info when validation fails | true | false |
yarn install
yarn build
yarn test
FAQs
Validate your Swagger file and request responses against Swagger Endpoints
The npm package @flowko/cypress-swagger-validation receives a total of 0 weekly downloads. As such, @flowko/cypress-swagger-validation popularity was classified as not popular.
We found that @flowko/cypress-swagger-validation 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.
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.