From af0b0865f4c2f22975a836b72ff0b902ddac1ce9 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 29 Jan 2024 11:31:15 +0100 Subject: [PATCH] feat: Remove Swagger and OpenAPI Support and features are lacking --- build.gradle.kts | 3 - docs/.swagger-codegen-ignore | 23 - docs/.swagger-codegen/VERSION | 1 - docs/index.html | 2752 ----------------- gradle/libs.versions.toml | 2 - .../kotlin/app/revanced/api/plugins/HTTP.kt | 17 +- src/main/resources/openapi/documentation.yaml | 23 - 7 files changed, 3 insertions(+), 2818 deletions(-) delete mode 100644 docs/.swagger-codegen-ignore delete mode 100644 docs/.swagger-codegen/VERSION delete mode 100644 docs/index.html delete mode 100644 src/main/resources/openapi/documentation.yaml diff --git a/build.gradle.kts b/build.gradle.kts index bfc4d3f..50cccda 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,8 +34,6 @@ dependencies { implementation(libs.ktor.server.content.negotiation) implementation(libs.ktor.server.auth) implementation(libs.ktor.server.auth.jwt) - implementation(libs.ktor.server.swagger) - implementation(libs.ktor.server.openapi) implementation(libs.ktor.server.cors) implementation(libs.ktor.server.caching.headers) implementation(libs.ktor.server.host.common) @@ -54,5 +52,4 @@ dependencies { testImplementation(libs.ktor.server.tests) testImplementation(libs.kotlin.test.junit) - } diff --git a/docs/.swagger-codegen-ignore b/docs/.swagger-codegen-ignore deleted file mode 100644 index c5fa491..0000000 --- a/docs/.swagger-codegen-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# Swagger Codegen Ignore -# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/docs/.swagger-codegen/VERSION b/docs/.swagger-codegen/VERSION deleted file mode 100644 index a254f0a..0000000 --- a/docs/.swagger-codegen/VERSION +++ /dev/null @@ -1 +0,0 @@ -3.0.41 \ No newline at end of file diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index af14f14..0000000 --- a/docs/index.html +++ /dev/null @@ -1,2752 +0,0 @@ - - - - - Application API - - - - - - - - - - - - - -
-
-
- -
-
-
-
-

Application API

-
-
-
- -
-
-

Default

-
-
-
-

rootGet

-

-
-
-
-

-

Hello World!

-

-
-
/
-

-

Usage and SDK Samples

-

- - -
-
-
curl -X GET\
--H "Accept: text/plain"\
-"http://0.0.0.0:8080/"
-
-
-
import io.swagger.client.*;
-import io.swagger.client.auth.*;
-import io.swagger.client.model.*;
-import io.swagger.client.api.DefaultApi;
-
-import java.io.File;
-import java.util.*;
-
-public class DefaultApiExample {
-
-    public static void main(String[] args) {
-        
-        DefaultApi apiInstance = new DefaultApi();
-        try {
-            'String' result = apiInstance.rootGet();
-            System.out.println(result);
-        } catch (ApiException e) {
-            System.err.println("Exception when calling DefaultApi#rootGet");
-            e.printStackTrace();
-        }
-    }
-}
-
- -
-
import io.swagger.client.api.DefaultApi;
-
-public class DefaultApiExample {
-
-    public static void main(String[] args) {
-        DefaultApi apiInstance = new DefaultApi();
-        try {
-            'String' result = apiInstance.rootGet();
-            System.out.println(result);
-        } catch (ApiException e) {
-            System.err.println("Exception when calling DefaultApi#rootGet");
-            e.printStackTrace();
-        }
-    }
-}
-
- -
-

-DefaultApi *apiInstance = [[DefaultApi alloc] init];
-
-[apiInstance rootGetWithCompletionHandler: 
-              ^('String' output, NSError* error) {
-                            if (output) {
-                                NSLog(@"%@", output);
-                            }
-                            if (error) {
-                                NSLog(@"Error: %@", error);
-                            }
-                        }];
-
-
- -
-
var ApplicationApi = require('application_api');
-
-var api = new ApplicationApi.DefaultApi()
-var callback = function(error, data, response) {
-  if (error) {
-    console.error(error);
-  } else {
-    console.log('API called successfully. Returned data: ' + data);
-  }
-};
-api.rootGet(callback);
-
-
- - -
-
using System;
-using System.Diagnostics;
-using IO.Swagger.Api;
-using IO.Swagger.Client;
-using IO.Swagger.Model;
-
-namespace Example
-{
-    public class rootGetExample
-    {
-        public void main()
-        {
-
-            var apiInstance = new DefaultApi();
-
-            try
-            {
-                'String' result = apiInstance.rootGet();
-                Debug.WriteLine(result);
-            }
-            catch (Exception e)
-            {
-                Debug.Print("Exception when calling DefaultApi.rootGet: " + e.Message );
-            }
-        }
-    }
-}
-
-
- -
-
<?php
-require_once(__DIR__ . '/vendor/autoload.php');
-
-$api_instance = new Swagger\Client\ApiDefaultApi();
-
-try {
-    $result = $api_instance->rootGet();
-    print_r($result);
-} catch (Exception $e) {
-    echo 'Exception when calling DefaultApi->rootGet: ', $e->getMessage(), PHP_EOL;
-}
-?>
-
- -
-
use Data::Dumper;
-use WWW::SwaggerClient::Configuration;
-use WWW::SwaggerClient::DefaultApi;
-
-my $api_instance = WWW::SwaggerClient::DefaultApi->new();
-
-eval { 
-    my $result = $api_instance->rootGet();
-    print Dumper($result);
-};
-if ($@) {
-    warn "Exception when calling DefaultApi->rootGet: $@\n";
-}
-
- -
-
from __future__ import print_statement
-import time
-import swagger_client
-from swagger_client.rest import ApiException
-from pprint import pprint
-
-# create an instance of the API class
-api_instance = swagger_client.DefaultApi()
-
-try: 
-    api_response = api_instance.root_get()
-    pprint(api_response)
-except ApiException as e:
-    print("Exception when calling DefaultApi->rootGet: %s\n" % e)
-
-
- -

Parameters

- - - - - - -

Responses

-

Status: 200 - OK

- - - -
-
-
- -
- -
-
- -
-
-
-
-
- -
-
-
- - - - - - - - - diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 413b850..016787b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,8 +21,6 @@ ktor-server-core = { module = "io.ktor:ktor-server-core" } ktor-server-content-negotiation = { module = "io.ktor:ktor-server-content-negotiation" } ktor-server-auth = { module = "io.ktor:ktor-server-auth" } ktor-server-auth-jwt = { module = "io.ktor:ktor-server-auth-jwt" } -ktor-server-swagger = { module = "io.ktor:ktor-server-swagger" } -ktor-server-openapi = { module = "io.ktor:ktor-server-openapi" } ktor-server-cors = { module = "io.ktor:ktor-server-cors" } ktor-server-caching-headers = { module = "io.ktor:ktor-server-caching-headers" } ktor-server-host-common = { module = "io.ktor:ktor-server-host-common" } diff --git a/src/main/kotlin/app/revanced/api/plugins/HTTP.kt b/src/main/kotlin/app/revanced/api/plugins/HTTP.kt index 8ea4b73..b46f168 100644 --- a/src/main/kotlin/app/revanced/api/plugins/HTTP.kt +++ b/src/main/kotlin/app/revanced/api/plugins/HTTP.kt @@ -6,18 +6,10 @@ import io.ktor.server.application.* import io.ktor.server.plugins.cachingheaders.* import io.ktor.server.plugins.conditionalheaders.* import io.ktor.server.plugins.cors.routing.* -import io.ktor.server.plugins.openapi.* -import io.ktor.server.plugins.swagger.* -import io.ktor.server.routing.* +import kotlin.time.Duration.Companion.minutes fun Application.configureHTTP() { install(ConditionalHeaders) - routing { - swaggerUI(path = "openapi") - } - routing { - openAPI(path = "openapi") - } install(CORS) { allowMethod(HttpMethod.Options) allowMethod(HttpMethod.Put) @@ -27,11 +19,8 @@ fun Application.configureHTTP() { anyHost() // @TODO: Don't do this in production if possible. Try to limit it. } install(CachingHeaders) { - options { _, outgoingContent -> - when (outgoingContent.contentType?.withoutParameters()) { - ContentType.Text.CSS -> CachingOptions(CacheControl.MaxAge(maxAgeSeconds = 24 * 60 * 60)) - else -> null - } + options { _, _ -> + CachingOptions(CacheControl.MaxAge(maxAgeSeconds = 5.minutes.inWholeSeconds.toInt())) } } } diff --git a/src/main/resources/openapi/documentation.yaml b/src/main/resources/openapi/documentation.yaml deleted file mode 100644 index 2e6c6d7..0000000 --- a/src/main/resources/openapi/documentation.yaml +++ /dev/null @@ -1,23 +0,0 @@ -openapi: "3.0.3" -info: - title: "Application API" - description: "Application API" - version: "1.0.0" -servers: - - url: "http://0.0.0.0:8080" -paths: - /: - get: - description: "Hello World!" - responses: - "200": - description: "OK" - content: - text/plain: - schema: - type: "string" - examples: - Example#1: - value: "Hello World!" -components: - schemas: