Kaynağa Gözat

add support for swagger/openapi

tags/v1.4.37
Jonathan Cobb 3 yıl önce
ebeveyn
işleme
b1dd67a233
10 değiştirilmiş dosya ile 34 ekleme ve 17 silme
  1. +0
    -13
      bubble-server/pom.xml
  2. +2
    -0
      bubble-server/src/main/java/bubble/ApiConstants.java
  3. +2
    -1
      bubble-server/src/main/java/bubble/auth/BubbleAuthFilter.java
  4. +1
    -1
      bubble-server/src/main/java/bubble/server/BubbleConfiguration.java
  5. +17
    -0
      bubble-server/src/main/java/bubble/service/cloud/AnsiblePrepService.java
  6. +1
    -0
      bubble-server/src/main/resources/ansible/roles/bubble/files/bubble_role.json
  7. +1
    -0
      bubble-server/src/main/resources/ansible/roles/bubble/templates/bubble.env.j2
  8. +8
    -0
      bubble-server/src/main/resources/bubble-config.yml
  9. +1
    -1
      utils/cobbzilla-utils
  10. +1
    -1
      utils/cobbzilla-wizard

+ 0
- 13
bubble-server/pom.xml Dosyayı Görüntüle

@@ -301,19 +301,6 @@
<version>1.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<version>1.5.24</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>

<build>


+ 2
- 0
bubble-server/src/main/java/bubble/ApiConstants.java Dosyayı Görüntüle

@@ -266,6 +266,8 @@ public class ApiConstants {
public static final String DEBUG_ENDPOINT = "/debug";
public static final String BUBBLE_MAGIC_ENDPOINT = "/.bubble";

public static final String OPENAPI_JSON_ENDPOINT = "/openapi.json";

public static final String FILTER_HTTP_ENDPOINT = "/filter";
public static final String EP_CHECK = "/check";
public static final String EP_APPLY = "/apply";


+ 2
- 1
bubble-server/src/main/java/bubble/auth/BubbleAuthFilter.java Dosyayı Görüntüle

@@ -32,7 +32,8 @@ public class BubbleAuthFilter extends AuthFilter<Account> {
PLANS_ENDPOINT, PAYMENT_METHODS_ENDPOINT,
BUBBLE_MAGIC_ENDPOINT,
MESSAGES_ENDPOINT, TIMEZONES_ENDPOINT,
NOTIFY_ENDPOINT, FILTER_HTTP_ENDPOINT, DETECT_ENDPOINT
NOTIFY_ENDPOINT, FILTER_HTTP_ENDPOINT, DETECT_ENDPOINT,
OPENAPI_JSON_ENDPOINT
));
public static final Set<String> SKIP_AUTH_PATHS = new SingletonSet<>(AUTH_ENDPOINT);
public static final Set<String> SKIP_ALL_AUTH = new SingletonSet<>("/");


+ 1
- 1
bubble-server/src/main/java/bubble/server/BubbleConfiguration.java Dosyayı Görüntüle

@@ -259,7 +259,7 @@ public class BubbleConfiguration extends PgRestServerConfiguration
try {
properties.load(loadResourceAsStream("META-INF/bubble/bubble.properties"));
} catch (Exception e) {
return die("getVersion: "+e, e);
return die("jarVersion: "+e, e);
}
return properties.getProperty(META_PROP_BUBBLE_VERSION);
}


+ 17
- 0
bubble-server/src/main/java/bubble/service/cloud/AnsiblePrepService.java Dosyayı Görüntüle

@@ -45,10 +45,13 @@ import static org.cobbzilla.util.io.FileUtil.abs;
import static org.cobbzilla.util.io.FileUtil.mkdirOrDie;
import static org.cobbzilla.util.io.StreamUtil.copyClasspathDirectory;
import static org.cobbzilla.util.json.JsonUtil.json;
import static org.cobbzilla.wizard.server.config.OpenApiConfiguration.OPENAPI_DISABLED;

@Service @Slf4j
public class AnsiblePrepService {

private static final int MIN_OPEN_API_MEMORY = 4096;

@Autowired private DatabaseFilterService dbFilter;
@Autowired private BubbleConfiguration configuration;
@Autowired private AccountPlanDAO accountPlanDAO;
@@ -92,6 +95,12 @@ public class AnsiblePrepService {
ctx.put("support", configuration.getSupport());
ctx.put("appLinks", configuration.getAppLinks());

if (shouldEnableOpenApi(installType, nodeSize)) {
ctx.put("openapi_contact_email", configuration.getOpenApi().getContactEmail());
} else {
ctx.put("openapi_contact_email", OPENAPI_DISABLED);
}

if (network.sendErrors() && configuration.hasErrorApi()) {
final ErrorApiConfiguration errorApi = configuration.getErrorApi();
ctx.put("error_url", errorApi.getUrl());
@@ -168,4 +177,12 @@ public class AnsiblePrepService {
return (int) (((double) memoryMB) * 0.19d);
}

private boolean shouldEnableOpenApi(AnsibleInstallType installType, ComputeNodeSize nodeSize) {
// to enable OpenAPI on a deployed node:
// - it must already be enabled on the current bubble
// - the bubble being launched must be a sage or have 4GB+ memory
return configuration.hasOpenApi() &&
(installType == AnsibleInstallType.sage || nodeSize.getMemoryMB() >= MIN_OPEN_API_MEMORY);
}

}

+ 1
- 0
bubble-server/src/main/resources/ansible/roles/bubble/files/bubble_role.json Dosyayı Görüntüle

@@ -20,6 +20,7 @@
{"name": "db_name", "value": "bubble"},
{"name": "db_key", "value": "[[dbEncryptionKey]]"},
{"name": "letsencrypt_email", "value": "[[configuration.letsencryptEmail]]"},
{"name": "openapi_contact_email", "value": "openapi_contact_email"},
{"name": "is_fork", "value": "[[fork]]"},
{"name": "restore_key", "value": "[[restoreKey]]"},
{"name": "restore_timeout", "value": "[[restoreTimeoutSeconds]]"},


+ 1
- 0
bubble-server/src/main/resources/ansible/roles/bubble/templates/bubble.env.j2 Dosyayı Görüntüle

@@ -22,3 +22,4 @@ export APP_LINK_MACOSX={{ app_link_macosx }}
export APP_LINK_LINUX={{ app_link_linux }}

export CERT_VALIDATION_HOST={{ cert_validation_host }}
export OPENAPI_CONTACT_EMAIL={{ openapi_contact_email }}

+ 8
- 0
bubble-server/src/main/resources/bubble-config.yml Dosyayı Görüntüle

@@ -8,6 +8,14 @@ serverName: bubble-api

publicUriBase: {{PUBLIC_BASE_URI}}

openApi:
title: Bubble API Reference, <<configuration.version>>
description: This is the Bubble API. It is used by the web UI, native apps, and CLI tools.
contactEmail: {{OPENAPI_CONTACT_EMAIL}}
terms: https://getbubblenow.com/terms/
licenseName: Bubble License
licenseUrl: https://getbubblenow.com/bubble-license/

defaultLocale: {{#exists BUBBLE_DEFAULT_LOCALE}}{{BUBBLE_DEFAULT_LOCALE}}{{else}}en_US{{/exists}}
testMode: {{#exists BUBBLE_TEST_MODE}}{{BUBBLE_TEST_MODE}}{{else}}false{{/exists}}



+ 1
- 1
utils/cobbzilla-utils

@@ -1 +1 @@
Subproject commit 72419b875024efae04931a9ce06b8cda8173cb9e
Subproject commit d915a7aff9e07888d389fc021693994fa538923c

+ 1
- 1
utils/cobbzilla-wizard

@@ -1 +1 @@
Subproject commit e79af2c70ce31672995e708b2adbfa6f5e733f97
Subproject commit 8da076b3a54a1af1d9d4efceace3b9c832b8d5dc

Yükleniyor…
İptal
Kaydet