From 0253168285275abdd89c4b6b60c45953a6249b2e Mon Sep 17 00:00:00 2001 From: Edwin Greene Date: Tue, 19 Nov 2024 12:56:34 -0500 Subject: [PATCH] Add OpenApiValidator feature flag (#9784) * Add OpenApiValidator feature flag --------- Signed-off-by: Edwin Greene --- docs/configuration.md | 5 +++-- hedera-mirror-rest/config/application.yml | 2 ++ hedera-mirror-rest/server.js | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 10cab924e13..0bec9c0e8d9 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -431,7 +431,7 @@ monitor. | `hedera.mirror.monitor.nodes[].host` | "" | The main node's hostname | | `hedera.mirror.monitor.nodes[].port` | 50211 | The main node's port | | `hedera.mirror.monitor.nodeValidation.enabled` | true | Whether to validate and remove invalid or down nodes permanently before publishing | -| `hedera.mirror.monitor.nodeValidation.frequency` | 1d | The amount of time between validations of the network. If not specified, millisecond is implied as the unit. | +| `hedera.mirror.monitor.nodeValidation.frequency` | 1d | The amount of time between validations of the network. If not specified, millisecond is implied as the unit. | | `hedera.mirror.monitor.nodeValidation.maxAttempts` | 8 | The number of times the monitor should attempt to receive a healthy response from a node before marking it as unhealthy. | | `hedera.mirror.monitor.nodeValidation.maxBackoff` | 2s | The maximum amount of time to wait in between attempts when trying to validate a node | | `hedera.mirror.monitor.nodeValidation.maxThreads` | 25 | The maximum number of threads to use for node validation | @@ -503,7 +503,7 @@ The following table lists the available properties along with their default valu value, it is recommended to only populate overridden properties in the custom `application.yml`. | Name | Default | Description | -|--------------------------------------------------------------------| ----------------------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| ------------------------------------------------------------------ | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `hedera.mirror.rest.cache.entityId.maxAge` | 1800 | The number of seconds until the entityId cache entry expires | | `hedera.mirror.rest.cache.entityId.maxSize` | 100000 | The maximum number of entries in the entityId cache | | `hedera.mirror.rest.cache.token.maxSize` | 100000 | The maximum number of entries in the token cache | @@ -533,6 +533,7 @@ value, it is recommended to only populate overridden properties in the custom `a | `hedera.mirror.rest.network.unreleasedSupplyAccounts` | [0.0.2, 0.0.42, ...] | An array of account IDs whose aggregated balance subtracted from the total supply is the released supply | | `hedera.mirror.rest.openapi.specFileName` | 'openapi' | The file name of the OpenAPI spec file | | `hedera.mirror.rest.openapi.swaggerUIPath` | '/docs' | Swagger UI path for your REST API | +| `hedera.mirror.rest.openapi.validation.enabled` | false | Whether or not the OpenAPI request validation is enabled. | | `hedera.mirror.rest.port` | 5551 | The REST API port | | `hedera.mirror.rest.query.bindTimestampRange` | false | Whether to bind the timestamp range to maxTimestampRange | | `hedera.mirror.rest.query.maxRecordFileCloseInterval` | 10s | The maximum close interval of record files to limit the time partitions to scan. Note the default value is larger than the actual network close interval | diff --git a/hedera-mirror-rest/config/application.yml b/hedera-mirror-rest/config/application.yml index 241a7ddcfa0..089651a0961 100644 --- a/hedera-mirror-rest/config/application.yml +++ b/hedera-mirror-rest/config/application.yml @@ -62,6 +62,8 @@ hedera: openapi: specFileName: "openapi" swaggerUIPath: "docs" + validation: + enabled: false port: 5551 query: bindTimestampRange: false diff --git a/hedera-mirror-rest/server.js b/hedera-mirror-rest/server.js index fabc2317d88..f43e940216b 100644 --- a/hedera-mirror-rest/server.js +++ b/hedera-mirror-rest/server.js @@ -93,6 +93,7 @@ global.pool = pool; const app = addAsync(express()); const {apiPrefix} = constants; const applicationCacheEnabled = config.cache.response.enabled && config.redis.enabled; +const openApiValidatorEnabled = config.openapi.validation.enabled; app.disable('x-powered-by'); app.set('trust proxy', true); @@ -100,7 +101,9 @@ app.set('port', port); app.set('query parser', requestQueryParser); serveSwaggerDocs(app); -openApiValidator(app); +if (openApiValidatorEnabled || isTestEnv()) { + openApiValidator(app); +} // middleware functions, Prior to v0.5 define after sets app.use(