Repository: NREL/OpenStudio (language: python)

Issue:
Add `json_schemer` gem
Enhancement Request
--------------
OpenStudio includes the `json-schema` gem, but it is barely maintained and [many users recommend switching to `json_schemer` gem](https://github.com/voxpupuli/json-schema/issues/423#issuecomment-634811990). Not only is the `json_schemer` gem well maintained, but it supports newer drafts of the JSON schema that are heavily utilized these days. The `json-schema` gem has no current progress towards supporting newer drafts of the schema.

For DOE's Home Energy Score project, we are unable to use the current `json-schema` gem because it doesn't support JSON Schema draft-07. This means that we can't validate JSON files submitted and has occasionally led to issues.

(Perhaps OpenStudio should consider replacing the `json-schema` gem, but that would be a breaking change.)
Add `json_schemer` gem
Enhancement Request
--------------
OpenStudio includes the `json-schema` gem, but it is barely maintained and [many users recommend switching to `json_schemer` gem](https://github.com/voxpupuli/json-schema/issues/423#issuecomment-634811990). Not only is the `json_schemer` gem well maintained, but it supports newer drafts of the JSON schema that are heavily utilized these days. The `json-schema` gem has no current progress towards supporting newer drafts of the schema.

For DOE's Home Energy Score project, we are unable to use the current `json-schema` gem because it doesn't support JSON Schema draft-07. This means that we can't validate JSON files submitted and has occasionally led to issues.

(Perhaps OpenStudio should consider replacing the `json-schema` gem, but that would be a breaking change.)


Discussion / hints:
No problem. This is a pure ruby gem, no native ext, so we shouldn't need any patching because MSVC doesn't support C99 etc.

@wenyikuang Do you want to take this one?
Added the PR at https://github.com/NREL/openstudio-gems/pull/64.

Assuming it works, packages should be uploaded to S3 and OpenStudio's CMakeLists.txt should be updated to match.

(I'll have to build the mac M1 one myself and have @wenyikuang upload it to s3 as well, unless the arm64 mac CI machines are ready. **Edit: built and hosted on google drive, link on slack**)
> No problem. This is a pure ruby gem, no native ext, so we shouldn't need any patching because MSVC doesn't support C99 etc.
> 
> @wenyikuang Do you want to take this one?

Sure, let me take a look.
No problem. This is a pure ruby gem, no native ext, so we shouldn't need any patching because MSVC doesn't support C99 etc.

@wenyikuang Do you want to take this one?
Added the PR at https://github.com/NREL/openstudio-gems/pull/64.

Assuming it works, packages should be uploaded to S3 and OpenStudio's CMakeLists.txt should be updated to match.

(I'll have to build the mac M1 one myself and have @wenyikuang upload it to s3 as well, unless the arm64 mac CI machines are ready. **Edit: built and hosted on google drive, link on slack**)
> No problem. This is a pure ruby gem, no native ext, so we shouldn't need any patching because MSVC doesn't support C99 etc.
> 
> @wenyikuang Do you want to take this one?

Sure, let me take a look.

Fix patch:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ba93257831a..836e429b0e7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -833,19 +833,19 @@ if(BUILD_CLI)
   if(UNIX)
      if(APPLE)
        if (ARCH MATCHES arm64)
-         set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230427-darwin_arm64.tar.gz")
-         set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "27ca992c6e5fe5347a7e342eb5b91511")
+         set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230918-darwin_arm64.tar.gz")
+         set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "404783d585a63a07f2f9d5b4ba445d99")
        else()
-         set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230427-darwin.tar.gz")
-         set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "b6bf19e6958bd41be9788a7f16fd7f27")
+         set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230918-darwin.tar.gz")
+         set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "71282202360c68cf9dd0f0d585d560f2")
        endif()
      else()
        if (ARCH MATCHES "arm64")
-         set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230427-linux_arm64.tar.gz")
-         set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "979a8839facf2fa1c4096dcbae39ddc2")
+         set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230918-linux_arm64.tar.gz")
+         set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "c28e1b84051fbae2ae0a9f7a27416951")
        else()
-         set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230427-linux.tar.gz")
-         set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "957681cb4f3b5cf8ad95103a5fae9a72")
+         set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230918-linux.tar.gz")
+         set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "f7279e86e0a9f41cfd0ce89060c4d836")
        endif()
        if (USE_OPENSTUDIO_GEMS_PR)
          set(OPENSTUDIO_GEMS_BASEURL "${OPENSTUDIO_GEMS_BASEURL}/openstudio-gems-linux/${OPENSTUDIO_GEMS_PR_NUMBER}")
@@ -853,8 +853,8 @@ if(BUILD_CLI)
      endif()
   elseif(WIN32)
     # OpenStudio gems are only supported on 64 bit windows
-    set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230427-windows.tar.gz")
-    set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "e82889c296b7b76eb1f7b3fc7e22d2aa")
+    set(OPENSTUDIO_GEMS_ZIP_FILENAME "openstudio3-gems-20230918-windows.tar.gz")
+    set(OPENSTUDIO_GEMS_ZIP_EXPECTED_MD5 "1606f5db801064864c1dc22e8e23459e")
     if (USE_OPENSTUDIO_GEMS_PR)
       set(OPENSTUDIO_GEMS_BASEURL "${OPENSTUDIO_GEMS_BASEURL}/openstudio-gems-windows/${OPENSTUDIO_GEMS_PR_NUMBER}")
     endif()


Test patch:
diff --git a/src/cli/test/test_embedded_ruby.rb b/src/cli/test/test_embedded_ruby.rb
index ccb0c4bcd7b..8a8c4fd5e81 100644
--- a/src/cli/test/test_embedded_ruby.rb
+++ b/src/cli/test/test_embedded_ruby.rb
@@ -233,4 +233,21 @@ def test_msgpack
     assert(data == data2)
   end
 
+  def test_json_schemer
+    require 'json_schemer'
+
+    schema = {
+      'type' => 'object',
+      'properties' => {
+        'abc' => {
+          'type' => 'integer',
+          'minimum' => 11
+        }
+      }
+    }
+    schemer = JSONSchemer.schema(schema)
+    assert(schemer.valid?({ 'abc' => 11 }))
+    assert(!schemer.valid?({ 'abc' => 10 }))
+  end
+
 end