2023-04-22 23:42:08 +03:30

174 lines
6.0 KiB
JavaScript

/*
* APIs
* An example application with OpenAPI, Swashbuckle, and API versioning.
*
* OpenAPI spec version: 1.0
* Contact:
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://github.com/OpenAPITools/openapi-generator
*
* OpenAPI generator version: 6.6.0-SNAPSHOT
*/
import http from "k6/http";
import { group, check, sleep } from "k6";
const BASE_URL = "/";
// Sleep duration between successive requests.
// You might want to edit the value of this variable or remove calls to the sleep function on the script.
const SLEEP_DURATION = 0.1;
// Global variables should be initialized.
export default function() {
group("/api/v1/flight/seat", () => {
// Request No. 1: CreateSeat
{
let url = BASE_URL + `/api/v1/flight/seat`;
// TODO: edit the parameters of the request body.
let body = {"seatNumber": "string", "type": "seattype", "class": "seatclass", "flightId": "uuid"};
let params = {headers: {"Content-Type": "application/json", "Accept": "application/json"}};
let request = http.post(url, JSON.stringify(body), params);
check(request, {
"Success": (r) => r.status === 200
});
}
});
group("/api/v1/flight/get-available-flights", () => {
// Request No. 1: GetAvailableFlights
{
let url = BASE_URL + `/api/v1/flight/get-available-flights`;
let request = http.get(url);
check(request, {
"Success": (r) => r.status === 200
});
}
});
group("/api/v1/flight/airport", () => {
// Request No. 1: CreateAirport
{
let url = BASE_URL + `/api/v1/flight/airport`;
// TODO: edit the parameters of the request body.
let body = {"name": "string", "address": "string", "code": "string"};
let params = {headers: {"Content-Type": "application/json", "Accept": "application/json"}};
let request = http.post(url, JSON.stringify(body), params);
check(request, {
"Success": (r) => r.status === 200
});
}
});
group("/api/v1/flight/get-available-seats/{id}", () => {
let id = 'TODO_EDIT_THE_ID'; // specify value as there is no example value for this parameter in OpenAPI spec
// Request No. 1: GetAvailableSeats
{
let url = BASE_URL + `/api/v1/flight/get-available-seats/${id}`;
let request = http.get(url);
check(request, {
"Success": (r) => r.status === 200
});
}
});
group("/api/v1/flight", () => {
// Request No. 1: UpdateFlight
{
let url = BASE_URL + `/api/v1/flight`;
// TODO: edit the parameters of the request body.
let body = {"id": "uuid", "flightNumber": "string", "aircraftId": "uuid", "departureAirportId": "uuid", "departureDate": "date", "arriveDate": "date", "arriveAirportId": "uuid", "durationMinutes": "double", "flightDate": "date", "status": "flightstatus", "price": "double", "isDeleted": "boolean"};
let params = {headers: {"Content-Type": "application/json", "Accept": "application/problem+json"}};
let request = http.put(url, JSON.stringify(body), params);
check(request, {
"Success": (r) => r.status === 204
});
sleep(SLEEP_DURATION);
}
// Request No. 2: CreateFlight
{
let url = BASE_URL + `/api/v1/flight`;
// TODO: edit the parameters of the request body.
let body = {"flightNumber": "string", "aircraftId": "uuid", "departureAirportId": "uuid", "departureDate": "date", "arriveDate": "date", "arriveAirportId": "uuid", "durationMinutes": "double", "flightDate": "date", "status": "flightstatus", "price": "double"};
let params = {headers: {"Content-Type": "application/json", "Accept": "application/json"}};
let request = http.post(url, JSON.stringify(body), params);
check(request, {
"Success": (r) => r.status === 201
});
}
});
group("/api/v1/flight/{id}", () => {
let id = 'TODO_EDIT_THE_ID'; // specify value as there is no example value for this parameter in OpenAPI spec
// Request No. 1: GetFlightById
{
let url = BASE_URL + `/api/v1/flight/${id}`;
let request = http.get(url);
check(request, {
"Success": (r) => r.status === 200
});
sleep(SLEEP_DURATION);
}
// Request No. 2: DeleteFlight
{
let url = BASE_URL + `/api/v1/flight/${id}`;
let request = http.del(url);
check(request, {
"Success": (r) => r.status === 204
});
}
});
group("/api/v1/flight/reserve-seat", () => {
// Request No. 1: ReserveSeat
{
let url = BASE_URL + `/api/v1/flight/reserve-seat`;
// TODO: edit the parameters of the request body.
let body = {"flightId": "uuid", "seatNumber": "string"};
let params = {headers: {"Content-Type": "application/json", "Accept": "application/json"}};
let request = http.post(url, JSON.stringify(body), params);
check(request, {
"Success": (r) => r.status === 200
});
}
});
group("/api/v1/flight/aircraft", () => {
// Request No. 1: CreateAircraft
{
let url = BASE_URL + `/api/v1/flight/aircraft`;
// TODO: edit the parameters of the request body.
let body = {"name": "string", "model": "string", "manufacturingYear": "integer"};
let params = {headers: {"Content-Type": "application/json", "Accept": "application/json"}};
let request = http.post(url, JSON.stringify(body), params);
check(request, {
"Success": (r) => r.status === 200
});
}
});
}