From 85468835d0e3a45457798f63351c71a11c7b07b6 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Wed, 1 Mar 2017 12:50:36 +0100 Subject: [PATCH 1/8] properly abort in ABORT macro --- lib/Basics/Common.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Basics/Common.h b/lib/Basics/Common.h index c8decbd4bc..0270a9fdad 100644 --- a/lib/Basics/Common.h +++ b/lib/Basics/Common.h @@ -237,7 +237,6 @@ typedef long suseconds_t; TRI_LogBacktrace(); \ arangodb::Logger::flush(); \ arangodb::Logger::shutdown(); \ - TRI_EXIT_FUNCTION(EXIT_FAILURE, nullptr); \ std::abort(); \ } while (0) From 6495e12aa160653058f505c52ded26b37fd52692 Mon Sep 17 00:00:00 2001 From: Alan Plum Date: Wed, 1 Mar 2017 12:51:56 +0100 Subject: [PATCH 2/8] Document endpoint.tag Fixes #2338. --- CHANGELOG | 2 ++ .../Books/Manual/Foxx/Router/Endpoints.mdpp | 27 +++++++++++++++++++ .../Manual/ReleaseNotes/NewFeatures32.mdpp | 4 ++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 97bd3d4260..ae07be1eeb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -71,6 +71,8 @@ v3.2.alpha1 (2017-02-05) * more detailed stacktraces in Foxx apps +* add support for Swagger tags in Foxx + v3.1.12 (XXXX-XX-XX) -------------------- diff --git a/Documentation/Books/Manual/Foxx/Router/Endpoints.mdpp b/Documentation/Books/Manual/Foxx/Router/Endpoints.mdpp index 940660382c..bfe60cce0e 100644 --- a/Documentation/Books/Manual/Foxx/Router/Endpoints.mdpp +++ b/Documentation/Books/Manual/Foxx/Router/Endpoints.mdpp @@ -372,3 +372,30 @@ Returns the endpoint. router.get(/* ... */) .deprecated(); ``` + + +tag +--- + +`endpoint.tag(...tags): this` + +Marks the endpoint with the given tags that will be used to group related routes in the generated API documentation. + +If the endpoint is a child router, all routes of that router will also be marked with the tags. If the endpoint is a middleware, this method has no effect. + +This method only affects the generated API documentation and has not other effect within the service itself. + +**Arguments** + +* **tags**: `string` + + One or more strings that will be used to group the endpoint's routes. + +Returns the endpoint. + +**Examples** + +```js +router.get(/* ... */) +.tag('auth', 'restricted'); +``` diff --git a/Documentation/Books/Manual/ReleaseNotes/NewFeatures32.mdpp b/Documentation/Books/Manual/ReleaseNotes/NewFeatures32.mdpp index 65c8df5425..083bbf9170 100644 --- a/Documentation/Books/Manual/ReleaseNotes/NewFeatures32.mdpp +++ b/Documentation/Books/Manual/ReleaseNotes/NewFeatures32.mdpp @@ -59,4 +59,6 @@ Foxx The [cookie session transport](../Foxx/Sessions/Transports/Cookie.md) now supports all options supported by the [cookie method of the response object](../Foxx/Router/Response.md#cookie). -It's now possible to provide your own version of the `graphql-sync` module when using the [GraphQL extensions for Foxx](../Foxx/GraphQL.md) by passing a copy of the module using the new _graphql_ option. \ No newline at end of file +It's now possible to provide your own version of the `graphql-sync` module when using the [GraphQL extensions for Foxx](../Foxx/GraphQL.md) by passing a copy of the module using the new _graphql_ option. + +Endpoints can now be tagged using the [tag method](../Foxx/Router/Endpoints.md#tag) to generate a cleaner Swagger documentation. From 0ac29eb1772f0c532f55a532ad82efc288f16633 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Wed, 1 Mar 2017 12:52:51 +0100 Subject: [PATCH 3/8] don't fail when using optional features as dependencies --- arangod/RestServer/arangod.cpp | 2 +- arangosh/Benchmark/arangobench.cpp | 2 -- arangosh/Dump/arangodump.cpp | 2 -- arangosh/Export/arangoexport.cpp | 2 -- arangosh/Import/arangoimp.cpp | 2 -- arangosh/Restore/arangorestore.cpp | 2 -- arangosh/Shell/arangosh.cpp | 2 -- arangosh/VPack/arangovpack.cpp | 2 -- .../ApplicationFeature.cpp | 25 +++++++++++-------- lib/ApplicationFeatures/ApplicationServer.h | 5 ++-- lib/ApplicationFeatures/GreetingsFeature.cpp | 12 +++------ lib/ApplicationFeatures/GreetingsFeature.h | 5 +--- 12 files changed, 23 insertions(+), 40 deletions(-) diff --git a/arangod/RestServer/arangod.cpp b/arangod/RestServer/arangod.cpp index 60502e8e7c..fec2466865 100644 --- a/arangod/RestServer/arangod.cpp +++ b/arangod/RestServer/arangod.cpp @@ -146,7 +146,7 @@ static int runServer(int argc, char** argv) { server.addFeature(new FoxxQueuesFeature(&server)); server.addFeature(new FrontendFeature(&server)); server.addFeature(new GeneralServerFeature(&server)); - server.addFeature(new GreetingsFeature(&server, "arangod")); + server.addFeature(new GreetingsFeature(&server)); server.addFeature(new InitDatabaseFeature(&server, nonServerFeatures)); server.addFeature(new LanguageFeature(&server)); server.addFeature(new LockfileFeature(&server)); diff --git a/arangosh/Benchmark/arangobench.cpp b/arangosh/Benchmark/arangobench.cpp index 3f3bc47010..7758b69d55 100644 --- a/arangosh/Benchmark/arangobench.cpp +++ b/arangosh/Benchmark/arangobench.cpp @@ -25,7 +25,6 @@ #include "Basics/directories.h" #include "ApplicationFeatures/ConfigFeature.h" -#include "ApplicationFeatures/GreetingsFeature.h" #include "ApplicationFeatures/ShutdownFeature.h" #include "ApplicationFeatures/TempFeature.h" #include "ApplicationFeatures/VersionFeature.h" @@ -57,7 +56,6 @@ int main(int argc, char* argv[]) { server.addFeature(new BenchFeature(&server, &ret)); server.addFeature(new ClientFeature(&server)); server.addFeature(new ConfigFeature(&server, "arangobench")); - server.addFeature(new GreetingsFeature(&server, "arangobench")); server.addFeature(new LoggerFeature(&server, false)); server.addFeature(new RandomFeature(&server)); server.addFeature(new ShutdownFeature(&server, {"Bench"})); diff --git a/arangosh/Dump/arangodump.cpp b/arangosh/Dump/arangodump.cpp index acbe198ef9..fd1acf5a67 100644 --- a/arangosh/Dump/arangodump.cpp +++ b/arangosh/Dump/arangodump.cpp @@ -25,7 +25,6 @@ #include "Basics/directories.h" #include "ApplicationFeatures/ConfigFeature.h" -#include "ApplicationFeatures/GreetingsFeature.h" #include "ApplicationFeatures/ShutdownFeature.h" #include "ApplicationFeatures/VersionFeature.h" #include "Basics/ArangoGlobalContext.h" @@ -54,7 +53,6 @@ int main(int argc, char* argv[]) { server.addFeature(new ClientFeature(&server)); server.addFeature(new ConfigFeature(&server, "arangodump")); server.addFeature(new DumpFeature(&server, &ret)); - server.addFeature(new GreetingsFeature(&server, "arangodump")); server.addFeature(new LoggerFeature(&server, false)); server.addFeature(new RandomFeature(&server)); server.addFeature(new ShutdownFeature(&server, {"Dump"})); diff --git a/arangosh/Export/arangoexport.cpp b/arangosh/Export/arangoexport.cpp index 20d0f491dd..859fc9a168 100644 --- a/arangosh/Export/arangoexport.cpp +++ b/arangosh/Export/arangoexport.cpp @@ -25,7 +25,6 @@ #include "Basics/directories.h" #include "ApplicationFeatures/ConfigFeature.h" -#include "ApplicationFeatures/GreetingsFeature.h" #include "ApplicationFeatures/ShutdownFeature.h" #include "ApplicationFeatures/TempFeature.h" #include "ApplicationFeatures/VersionFeature.h" @@ -54,7 +53,6 @@ int main(int argc, char* argv[]) { server.addFeature(new ClientFeature(&server)); server.addFeature(new ConfigFeature(&server, "arangoexport")); - server.addFeature(new GreetingsFeature(&server, "arangoexport")); server.addFeature(new ExportFeature(&server, &ret)); server.addFeature(new LoggerFeature(&server, false)); server.addFeature(new RandomFeature(&server)); diff --git a/arangosh/Import/arangoimp.cpp b/arangosh/Import/arangoimp.cpp index 6168a10f0a..0fd47885a8 100644 --- a/arangosh/Import/arangoimp.cpp +++ b/arangosh/Import/arangoimp.cpp @@ -25,7 +25,6 @@ #include "Basics/directories.h" #include "ApplicationFeatures/ConfigFeature.h" -#include "ApplicationFeatures/GreetingsFeature.h" #include "ApplicationFeatures/ShutdownFeature.h" #include "ApplicationFeatures/TempFeature.h" #include "ApplicationFeatures/VersionFeature.h" @@ -54,7 +53,6 @@ int main(int argc, char* argv[]) { server.addFeature(new ClientFeature(&server)); server.addFeature(new ConfigFeature(&server, "arangoimp")); - server.addFeature(new GreetingsFeature(&server, "arangoimp")); server.addFeature(new ImportFeature(&server, &ret)); server.addFeature(new LoggerFeature(&server, false)); server.addFeature(new RandomFeature(&server)); diff --git a/arangosh/Restore/arangorestore.cpp b/arangosh/Restore/arangorestore.cpp index 6f676c1e1d..c7611dc10e 100644 --- a/arangosh/Restore/arangorestore.cpp +++ b/arangosh/Restore/arangorestore.cpp @@ -25,7 +25,6 @@ #include "Basics/directories.h" #include "ApplicationFeatures/ConfigFeature.h" -#include "ApplicationFeatures/GreetingsFeature.h" #include "ApplicationFeatures/ShutdownFeature.h" #include "ApplicationFeatures/TempFeature.h" #include "ApplicationFeatures/VersionFeature.h" @@ -53,7 +52,6 @@ int main(int argc, char* argv[]) { server.addFeature(new ClientFeature(&server)); server.addFeature(new ConfigFeature(&server, "arangorestore")); - server.addFeature(new GreetingsFeature(&server, "arangorestore")); server.addFeature(new LoggerFeature(&server, false)); server.addFeature(new RandomFeature(&server)); server.addFeature(new RestoreFeature(&server, &ret)); diff --git a/arangosh/Shell/arangosh.cpp b/arangosh/Shell/arangosh.cpp index bb4ddc2972..e65753e937 100644 --- a/arangosh/Shell/arangosh.cpp +++ b/arangosh/Shell/arangosh.cpp @@ -25,7 +25,6 @@ #include "Basics/directories.h" #include "ApplicationFeatures/ConfigFeature.h" -#include "ApplicationFeatures/GreetingsFeature.h" #include "ApplicationFeatures/LanguageFeature.h" #include "ApplicationFeatures/ShutdownFeature.h" #include "ApplicationFeatures/TempFeature.h" @@ -63,7 +62,6 @@ int main(int argc, char* argv[]) { server.addFeature(new ClientFeature(&server)); server.addFeature(new ConfigFeature(&server, name)); server.addFeature(new ConsoleFeature(&server)); - server.addFeature(new GreetingsFeature(&server, "arangosh")); server.addFeature(new LanguageFeature(&server)); server.addFeature(new LoggerFeature(&server, false)); server.addFeature(new RandomFeature(&server)); diff --git a/arangosh/VPack/arangovpack.cpp b/arangosh/VPack/arangovpack.cpp index 7fabe9917c..02231114a1 100644 --- a/arangosh/VPack/arangovpack.cpp +++ b/arangosh/VPack/arangovpack.cpp @@ -25,7 +25,6 @@ #include "Basics/directories.h" #include "ApplicationFeatures/ConfigFeature.h" -#include "ApplicationFeatures/GreetingsFeature.h" #include "ApplicationFeatures/ShutdownFeature.h" #include "ApplicationFeatures/VersionFeature.h" #include "Basics/ArangoGlobalContext.h" @@ -49,7 +48,6 @@ int main(int argc, char* argv[]) { int ret; server.addFeature(new ConfigFeature(&server, "arangovpack")); - server.addFeature(new GreetingsFeature(&server, "arangovpack")); server.addFeature(new LoggerFeature(&server, false)); server.addFeature(new RandomFeature(&server)); server.addFeature(new ShutdownFeature(&server, {"VPack"})); diff --git a/lib/ApplicationFeatures/ApplicationFeature.cpp b/lib/ApplicationFeatures/ApplicationFeature.cpp index 6b17ca0652..b96e111b29 100644 --- a/lib/ApplicationFeatures/ApplicationFeature.cpp +++ b/lib/ApplicationFeatures/ApplicationFeature.cpp @@ -112,21 +112,24 @@ void ApplicationFeature::determineAncestors() { std::vector path; std::function build = [this, &build, &path](std::string const& name) { - path.emplace_back(name); + // lookup the feature first. it may not exist + ApplicationFeature* other = this->server()->lookupFeature(name); - for (auto& ancestor : this->server()->feature(name)->startsAfter()) { - if (_ancestors.emplace(ancestor).second) { - if (ancestor == _name) { - path.emplace_back(ancestor); - THROW_ARANGO_EXCEPTION_MESSAGE( - TRI_ERROR_INTERNAL, - "dependencies for feature '" + _name + "' are cyclic: " + arangodb::basics::StringUtils::join(path, " <= ")); + if (other != nullptr) { + path.emplace_back(name); + for (auto& ancestor : other->startsAfter()) { + if (_ancestors.emplace(ancestor).second) { + if (ancestor == _name) { + path.emplace_back(ancestor); + THROW_ARANGO_EXCEPTION_MESSAGE( + TRI_ERROR_INTERNAL, + "dependencies for feature '" + _name + "' are cyclic: " + arangodb::basics::StringUtils::join(path, " <= ")); + } + build(ancestor); } - build(ancestor); } + path.pop_back(); } - - path.pop_back(); }; build(_name); diff --git a/lib/ApplicationFeatures/ApplicationServer.h b/lib/ApplicationFeatures/ApplicationServer.h index de8005cde5..0ce43654ae 100644 --- a/lib/ApplicationFeatures/ApplicationServer.h +++ b/lib/ApplicationFeatures/ApplicationServer.h @@ -216,11 +216,12 @@ class ApplicationServer { _progressReports.emplace_back(reporter); } - char const* getBinaryPath() { return _binaryPath;} - private: // look up a feature and return a pointer to it. may be nullptr static ApplicationFeature* lookupFeature(std::string const&); + + char const* getBinaryPath() { return _binaryPath;} + private: // throws an exception that a requested feature was not found static void throwFeatureNotFoundException(std::string const& name); diff --git a/lib/ApplicationFeatures/GreetingsFeature.cpp b/lib/ApplicationFeatures/GreetingsFeature.cpp index f646216f31..706f0bf8c2 100644 --- a/lib/ApplicationFeatures/GreetingsFeature.cpp +++ b/lib/ApplicationFeatures/GreetingsFeature.cpp @@ -27,21 +27,17 @@ using namespace arangodb; GreetingsFeature::GreetingsFeature( - application_features::ApplicationServer* server, char const* progname) - : ApplicationFeature(server, "Greetings"), _progname(progname) { + application_features::ApplicationServer* server) + : ApplicationFeature(server, "Greetings") { setOptional(false); requiresElevatedPrivileges(false); startsAfter("Logger"); } void GreetingsFeature::prepare() { - if (strcmp(_progname, "arangod") == 0) { - LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "" << rest::Version::getVerboseVersionString(); - } + LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "" << rest::Version::getVerboseVersionString(); } void GreetingsFeature::unprepare() { - if (strcmp(_progname, "arangod") == 0) { - LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "ArangoDB has been shut down"; - } + LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "ArangoDB has been shut down"; } diff --git a/lib/ApplicationFeatures/GreetingsFeature.h b/lib/ApplicationFeatures/GreetingsFeature.h index 0a6a178da3..2b4137b696 100644 --- a/lib/ApplicationFeatures/GreetingsFeature.h +++ b/lib/ApplicationFeatures/GreetingsFeature.h @@ -28,14 +28,11 @@ namespace arangodb { class GreetingsFeature final : public application_features::ApplicationFeature { public: - GreetingsFeature(application_features::ApplicationServer* server, char const* progname); + explicit GreetingsFeature(application_features::ApplicationServer* server); public: void prepare() override final; void unprepare() override final; - - private: - char const* _progname; }; } From 18f4ce56e57fab2be0d3a9324e7a9e58ef4cf2e5 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Wed, 1 Mar 2017 13:49:04 +0100 Subject: [PATCH 4/8] add option to add the cookbook to the tarball and handle #2287 --- Documentation/Books/Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Documentation/Books/Makefile b/Documentation/Books/Makefile index afd995231b..1cdf180f67 100644 --- a/Documentation/Books/Makefile +++ b/Documentation/Books/Makefile @@ -427,8 +427,15 @@ build-dist-books: DISPL="$${DISPLAY}"; \ fi; \ make build-books DISPLAY="$${DISP}"; \ - mkdir -p ${OUTPUT_DIR}; \ - ( cd books; tar -czf ${OUTPUT_DIR}/ArangoDB-${newVersionNumber}.tar.gz ${ALLBOOKS} index.html; ); \ + mkdir -p ${OUTPUT_DIR} ; \ + ( \ + mv books ArangoDB-${newVersionNumber} ; \ + if test -n "${COOKBOOK_DIR}" ; then \ + cp -a ${COOKBOOK_DIR} ArangoDB-${newVersionNumber}/cookbook ; \ + fi ; \ + tar -czf ${OUTPUT_DIR}/ArangoDB-${newVersionNumber}.tar.gz ArangoDB-${newVersionNumber} ; \ + mv ArangoDB-${newVersionNumber} books ; \ + ) ; \ for book in $(ALLBOOKS); do \ make build-book-dist NAME=$${book} DISPLAY="$${DISP}" ; \ done; \ From d137dfcd7ec6b0c10855e9112020de1d067a5b22 Mon Sep 17 00:00:00 2001 From: Alan Plum Date: Wed, 1 Mar 2017 13:52:26 +0100 Subject: [PATCH 5/8] Fix swagger tag entry in CHANGELOG --- CHANGELOG | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ae07be1eeb..27fc938f27 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -71,8 +71,6 @@ v3.2.alpha1 (2017-02-05) * more detailed stacktraces in Foxx apps -* add support for Swagger tags in Foxx - v3.1.12 (XXXX-XX-XX) -------------------- @@ -233,6 +231,8 @@ shards. * process.stdout.isTTY now returns `true` in arangosh and when running arangod with the `--console` flag +* add support for Swagger tags in Foxx + v3.1.9 (XXXX-XX-XX) ------------------- From 31eac710f7612df54dce24958a6862614f553b70 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Wed, 1 Mar 2017 13:56:42 +0100 Subject: [PATCH 6/8] updated CHANGELOG --- CHANGELOG | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 27fc938f27..00cbb52c22 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,13 @@ devel ----- +* always validate incoming JSON HTTP requests for duplicate attribute names + + Incoming JSON data with duplicate attribute names will now be rejected as + invalid. Previous versions of ArangoDB only validated the uniqueness of + attribute names inside incoming JSON for some API endpoints, but not + consistently for all APIs. + * don't let read-only transactions block the WAL collector * allow passing own `graphql-sync` module instance to Foxx GraphQL router From ce2af3bf8daa8feccfd35c7ff6a40e8da2530f05 Mon Sep 17 00:00:00 2001 From: Alan Plum Date: Wed, 1 Mar 2017 13:59:34 +0100 Subject: [PATCH 7/8] Mention swagger tags change in 3.2 --- CHANGELOG | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 00cbb52c22..ed6a070e66 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,8 +10,6 @@ devel * don't let read-only transactions block the WAL collector -* allow passing own `graphql-sync` module instance to Foxx GraphQL router - v3.2.alpha2 (2017-02-20) ------------------------ @@ -78,6 +76,8 @@ v3.2.alpha1 (2017-02-05) * more detailed stacktraces in Foxx apps +* generated Foxx services now use swagger tags + v3.1.12 (XXXX-XX-XX) -------------------- From 8cb7cb14802b7e3d6b4f8e9c9e88668577bd820b Mon Sep 17 00:00:00 2001 From: Alan Plum Date: Wed, 1 Mar 2017 14:04:23 +0100 Subject: [PATCH 8/8] Oops, devel is next alpha --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index ed6a070e66..f37cfdc47d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,8 @@ devel * don't let read-only transactions block the WAL collector +* allow passing own `graphql-sync` module instance to Foxx GraphQL router + v3.2.alpha2 (2017-02-20) ------------------------