/** * Apimatic APILib * * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). */ import { ApiResponse, FileWrapper, RequestOptions } from '../core.js'; import { ContentType, contentTypeSchema } from '../models/contentType.js'; import { ValidateApiResult, validateApiResultSchema, } from '../models/validateApiResult.js'; import { string } from '../schema.js'; import { BaseController } from './baseController.js'; import { InternalServerErrorResponseError } from '../errors/internalServerErrorResponseError.js'; import { ProblemDetailsError } from '../errors/problemDetailsError.js'; import { UnauthorizedResponseError } from '../errors/unauthorizedResponseError.js'; export class ApiValidationV2ExternalApisController extends BaseController { /** * Validate an API by uploading the API specification file. * * You can also specify [API Metadata](https://docs.apimatic.io/manage-apis/apimatic-metadata) while * validating the API using this endpoint. When specifying Metadata, the uploaded file will be a zip * file containing the API specification file and the `APIMATIC-META` json file. * * @param contentType * @param file The API specification file.
The type of the specification file should be * any of the [supported formats](https://docs.apimatic.io/api- * transformer/overview-transformer#supported-input-formats). * @return Response from the API call */ async validateApiViaFileV2( contentType: ContentType, file: FileWrapper, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('POST', '/validation/v2/validate-via-file'); req.baseUrl('default'); const mapped = req.prepareArgs({ contentType: [contentType, contentTypeSchema], }); req.header('Content-Type', mapped.contentType); req.formData({ file: file }); req.throwOn(400, ProblemDetailsError, 'Bad Request'); req.throwOn(401, UnauthorizedResponseError, 'Unauthorized'); req.throwOn(403, ProblemDetailsError, 'Subscription Issue'); req.throwOn(500, InternalServerErrorResponseError, 'Internal Server Error'); req.authenticate([{ authorization: true }]); return req.callAsJson(validateApiResultSchema, requestOptions); } /** * Validate an API by providing the URL of the API specification file. * * You can also specify [API Metadata](https://docs.apimatic.io/manage-apis/apimatic-metadata) while * validating the API using this endpoint. When specifying Metadata, the URL provided will be that of a * zip file containing the API specification file and the `APIMATIC-META` json file. * * @param url The URL for the API specification file.

**Note:** This URL should be publicly * accessible. * @return Response from the API call */ async validateApiViaUrlV2( url: string, requestOptions?: RequestOptions ): Promise> { const req = this.createRequest('GET', '/validation/v2/validate-via-url'); req.baseUrl('default'); const mapped = req.prepareArgs({ url: [url, string()] }); req.query('url', mapped.url); req.throwOn(400, ProblemDetailsError, 'Bad Request'); req.throwOn(401, UnauthorizedResponseError, 'Unauthorized'); req.throwOn(403, ProblemDetailsError, 'Subscription Issue'); req.throwOn(500, InternalServerErrorResponseError, 'Internal Server Error'); req.authenticate([{ authorization: true }]); return req.callAsJson(validateApiResultSchema, requestOptions); } }