summaryrefslogtreecommitdiff
path: root/src/json_html_serializer.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-04Remove implicit conversionsEd Tanous1-1/+6
Since 2020, nlohmann has recognized that implicit conversions to and from json are an issue. Many bugs have been caused at both development time and runtime due to unexpected implicit conversions from json to std::string/int/bool. This commit disables implicit conversions using JSON_USE_IMPLICIT_CONVERSIONS [1]. This option will become the default in the future. That comment was written 3 years ago at this point, so we should prepare. Tested: Redfish service validator passes. [1] https://json.nlohmann.me/api/macros/json_use_implicit_conversions/ Change-Id: Id6cc47b9bbf8889e4777fd6d77ec992f3139962c Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-01-20Use SPDX identifiersEd Tanous1-0/+2
SPDX identifiers are simpler, and reduce the amount of cruft we have in code files. They are recommended by linux foundation, and therefore we should do as they allow. This patchset does not intend to modify any intent on any existing copyrights or licenses, only to standardize their inclusion. [1] https://www.linuxfoundation.org/blog/blog/copyright-notices-in-open-source-software-projects Change-Id: I935c7c0156caa78fc368c929cebd0f068031e830 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-08-17clang-format: re-format for clang-18Patrick Williams1-4/+4
clang-format-18 isn't compatible with the clang-format-17 output, so we need to reformat the code with the latest version. The way clang-18 handles lambda formatting also changed, so we have made changes to the organization default style format to better handle lambda formatting. See I5e08687e696dd240402a2780158664b7113def0e for updated style. See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement. Change-Id: Iceec1dc95b6c908ec6c21fb40093de9dd18bf11a Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2024-07-12Make schemas selectableEd Tanous1-2/+2
Which schemas are installed should be selectable in both a meson config, and trivially by forks. This commit gets us closer to that idea. It does it in several ways, first, the code for generating JsonSchemaFile resources has been changed to be generated at runtime, based on files on disk. This is slightly slower, but allows installing schemas from anywhere, and matches the CSDL handling. Next, the schema folders are separated into two sets csdl -> This includes the complete schema pack from dmtf installed -> this includes only the schemas the bmc includes Similar folders exist for json-schema and json-schema-installed. This allows any additional schemas to be a single symlink addition. Note, this also checks in all of the dmtf json schemas, not just the versions we use. This allows us to update the schema pack without needing to break our versions we ship. Because the static files are now selectable, all files need to be in a folder. This forces the css and image for the redfish built-in gui to be moved. Tested: /redfish/v1/JsonSchemas returns the correct result /redfish/v1/JsonSchemas/UpdateService returns a JsonSchemaFile instance /redfish/v1/JsonSchemas/UpdateService/UpdateService<version>json returns the JsonSchemaFile contents. Redfish service validator passes. Change-Id: Ie96b2e4b623788dc2ec94eb40fcfd80325f0d826 Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-11Add nullptr checkEd Tanous1-0/+4
Change-Id: If511f1210cca7bd1da3a8c5152688487d3036e2f Signed-off-by: Ed Tanous <ed@tanous.net>
2024-04-01Use no-switch-default on clangEd Tanous1-1/+1
clang-18 improves this check so that we can actually use it. Enable it and fix all violations. Change-Id: Ibe4ce19c423d447a4cbe593d1abba948362426af Signed-off-by: Ed Tanous <ed@tanous.net>
2024-03-28Add misc-include-cleanerEd Tanous1-2/+9
And fix the includes that are wrong. Note, there is a very large ignore list included in the .clang-tidy configcfile. These are things that clang-tidy doesn't yet handle well, like knowing about a details include. Change-Id: Ie3744f2c8cba68a8700b406449d6c2018a736952 Signed-off-by: Ed Tanous <ed@tanous.net>
2023-10-31Move to file_body in boostEd Tanous1-1/+3
As is, it reads the whole file into memory before sending it. While fairly fast for the user, this wastes ram, and makes bmcweb less useful on less capable systems. This patch enables using the boost::beast::http::file_body type, which has more efficient serialization semantics than using a std::string. To do this, it adds a openFile() handler to http::Response, which can be used to properly open a file. Once the file is opened, the existing string body is ignored, and the file payload is sent instead. openFile() also returns success or failure, to allow users to properly handle 404s and other errors. To prove that it works, I moved over every instance of direct use of the body() method over to using this, including the webasset handler. The webasset handler specifically should help with system load when doing an initial page load of the webui. Tested: Redfish service validator passes. Change-Id: Ic7ea9ffefdbc81eb985de7edc0fac114822994ad Signed-off-by: Ed Tanous <ed@tanous.net>
2023-06-05Break out serializer into its own cpp fileEd Tanous1-0/+571
This commit is entirely just moving code, such that not all compile units need to pull in the full html serializer. Tested: Unit tests pass. Pretty good coverage. Redfish service validator passes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ifaebe9534c0693dc678fd994517563b89aca0cc5