nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: twpayne/chezmoi
Pull request #182 (2019-01-29 05:40:25)

Consider files only containing whitespace as empty


Patch:
diff --git a/lib/chezmoi/chezmoi.go b/lib/chezmoi/chezmoi.go
index 3541bdf3a..22b34599c 100644
--- a/lib/chezmoi/chezmoi.go
+++ b/lib/chezmoi/chezmoi.go
@@ -2,6 +2,7 @@ package chezmoi
 
 import (
 	"archive/tar"
+	"bytes"
 	"os"
 	"path/filepath"
 	"sort"
@@ -57,6 +58,11 @@ func dirNames(dirAttributes []DirAttributes) []string {
 	return dns
 }
 
+// isEmpty returns true if b should be considered empty.
+func isEmpty(b []byte) bool {
+	return len(bytes.TrimSpace(b)) == 0
+}
+
 // parseDirNameComponents parses multiple directory name components.
 func parseDirNameComponents(components []string) []DirAttributes {
 	das := []DirAttributes{}
diff --git a/lib/chezmoi/file.go b/lib/chezmoi/file.go
index 27c911da5..386bbf217 100644
--- a/lib/chezmoi/file.go
+++ b/lib/chezmoi/file.go
@@ -127,7 +127,7 @@ func (f *File) Apply(fs vfs.FS, destDir string, ignore func(string) bool, umask
 	var currData []byte
 	switch {
 	case err == nil && info.Mode().IsRegular():
-		if len(contents) == 0 && !f.Empty {
+		if isEmpty(contents) && !f.Empty {
 			return mutator.RemoveAll(targetPath)
 		}
 		currData, err = fs.ReadFile(targetPath)
@@ -151,7 +151,7 @@ func (f *File) Apply(fs vfs.FS, destDir string, ignore func(string) bool, umask
 	default:
 		return err
 	}
-	if len(contents) == 0 && !f.Empty {
+	if isEmpty(contents) && !f.Empty {
 		return nil
 	}
 	return mutator.WriteFile(targetPath, contents, f.Perm&^umask, currData)


Test patch:
diff --git a/lib/chezmoi/target_state_test.go b/lib/chezmoi/target_state_test.go
index 51b98bd02..d8f61b8fa 100644
--- a/lib/chezmoi/target_state_test.go
+++ b/lib/chezmoi/target_state_test.go
@@ -42,6 +42,7 @@ func TestEndToEnd(t *testing.T) {
 					"empty_foo":                "",
 					"exact_dir/foo":            "foo",
 					"exact_dir/.chezmoiignore": "qux\n",
+					"whitespace":               " ",
 					"symlink_bar":              "empty",
 					"symlink_replace_symlink":  "bar",
 				},
@@ -71,6 +72,8 @@ func TestEndToEnd(t *testing.T) {
 					vfst.TestModeType(os.ModeSymlink),
 					vfst.TestSymlinkTarget("empty"),
 				),
+				vfst.TestPath("/home/user/whitespace",
+					vfst.TestDoesNotExist),
 				vfst.TestPath("/home/user/replace_symlink",
 					vfst.TestModeType(os.ModeSymlink),
 					vfst.TestSymlinkTarget("bar"),
Repository: 11ty/eleventy
Pull request #82 (2018-03-16 09:00:49)

Make EleventyConfig.addPassthroughCopy chainable
_(Implements #81)_

In this pull request:

- `EleventyConfig.addPassthroughCopy` returns a reference to `this` (the `EleventyConfig` object in this context)
- Tests for `EleventyConfig.addPassthroughCopy` are added

Should this be mentioned in [Pass-through File Copy: Manual Passthrough Copy (Faster)](https://github.com/11ty/eleventy/blob/master/docs/copy.md#manual-passthrough-copy-faster)? I could add a little example in the code snippet.

Also, you might not like the method documentation I added. However, I think it’s very helpful as some editors actually display this in a useful manner on hovering over function calls (e.g. VS Code).


Patch:
diff --git a/src/EleventyConfig.js b/src/EleventyConfig.js
index dcea19ee..99f7948c 100644
--- a/src/EleventyConfig.js
+++ b/src/EleventyConfig.js
@@ -154,8 +154,19 @@ class EleventyConfig {
     pluginCallback(this);
   }
 
+  /**
+   * Adds a path to a file or directory to the list of pass-through copies
+   * which are copied as-is to the output.
+   *
+   * @param {String} fileOrDir The path to the file or directory that should
+   * be copied.
+   * @returns {any} a reference to the `EleventyConfig` object.
+   * @memberof EleventyConfig
+   */
   addPassthroughCopy(fileOrDir) {
     this.passthroughCopies[fileOrDir] = true;
+
+    return this;
   }
 
   setTemplateFormats(templateFormats) {


Test patch:
diff --git a/test/EleventyConfigTest.js b/test/EleventyConfigTest.js
index 6fb7bb80..c0238715 100644
--- a/test/EleventyConfigTest.js
+++ b/test/EleventyConfigTest.js
@@ -29,6 +29,19 @@ test("Add Collections throws error on key collision", t => {
   });
 });
 
+test("Set manual Pass-through File Copy (single call)", t => {
+  eleventyConfig.addPassthroughCopy("img");
+
+  t.is(eleventyConfig.passthroughCopies["img"], true);
+});
+
+test("Set manual Pass-through File Copy (chained calls)", t => {
+  eleventyConfig.addPassthroughCopy("css").addPassthroughCopy("js");
+
+  t.is(eleventyConfig.passthroughCopies["css"], true);
+  t.is(eleventyConfig.passthroughCopies["js"], true);
+});
+
 test("Set Template Formats (string)", t => {
   eleventyConfig.setTemplateFormats("ejs, njk, liquid");
   t.deepEqual(eleventyConfig.templateFormats, ["ejs", "njk", "liquid"]);
Repository: 11ty/eleventy
Pull request #276 (2018-10-15 10:02:12)

Check whether file exists before isDirectory check
This adds a file exists check before statting the file.
This avoids an exception being thrown, but more importantly, allows glob
arguments to be passed as `--input`, fixing #173 in the process.

An example of a glob pattern that didn't work before, but will after this change, is:

```
$ eleventy --input=pages/!(contact.md)
```

It will process all file in the `pages` directory, except `contact.md`.

I've added a unit test for the glob argument, let me know if you'd like to see more checks!


Patch:
diff --git a/src/TemplatePath.js b/src/TemplatePath.js
index 999351bf..40d3fc50 100644
--- a/src/TemplatePath.js
+++ b/src/TemplatePath.js
@@ -133,7 +133,7 @@ TemplatePath.stripPathFromDir = function(targetDir, prunedPath) {
 };
 
 TemplatePath.isDirectorySync = function(path) {
-  return fs.statSync(path).isDirectory();
+  return fs.existsSync(path) && fs.statSync(path).isDirectory();
 };
 
 TemplatePath.convertToGlob = function(path) {


Test patch:
diff --git a/test/EleventyFilesTest.js b/test/EleventyFilesTest.js
index 84599031..98e54c77 100644
--- a/test/EleventyFilesTest.js
+++ b/test/EleventyFilesTest.js
@@ -48,6 +48,16 @@ test("Single File Input (shallow path)", async t => {
   t.is(files[0], "./README.md");
 });
 
+test("Glob Input", async t => {
+  let evf = new EleventyFiles("./test/stubs/glob-pages/!(contact.md)", "./test/stubs/_site", ["md"]);
+
+  let globs = evf.getFileGlobs();
+  let files = await fastglob.async(globs);
+  t.is(files.length, 2);
+  t.is(files[0], "./test/stubs/glob-pages/about.md");
+  t.is(files[1], "./test/stubs/glob-pages/home.md");
+});
+
 test(".eleventyignore parsing", t => {
   let ignores = EleventyFiles.getFileIgnores("./test/stubs/.eleventyignore");
   t.is(ignores.length, 2);
diff --git a/test/stubs/glob-pages/about.md b/test/stubs/glob-pages/about.md
new file mode 100644
index 00000000..027ba4ba
--- /dev/null
+++ b/test/stubs/glob-pages/about.md
@@ -0,0 +1,5 @@
+---
+title: "About"
+---
+
+About 
diff --git a/test/stubs/glob-pages/contact.md b/test/stubs/glob-pages/contact.md
new file mode 100644
index 00000000..c774af7f
--- /dev/null
+++ b/test/stubs/glob-pages/contact.md
@@ -0,0 +1,6 @@
+---
+title: "Contact"
+---
+
+Contact
+
diff --git a/test/stubs/glob-pages/home.md b/test/stubs/glob-pages/home.md
new file mode 100644
index 00000000..277823f4
--- /dev/null
+++ b/test/stubs/glob-pages/home.md
@@ -0,0 +1,5 @@
+---
+title: "Home"
+---
+
+Home
Repository: 11ty/eleventy
Pull request #747 (2019-10-29 17:04:29)

Improve Sortable test coverage; call out a bug; fix others
I decided to improve test coverage a bit in `Util/Sortable`, and found a couple issues.  Some of them were easy to fix, but others are above my pay-grade.

Pay special attention to the comments under `Alphabetic Ascending (shortcut)`


Patch:
diff --git a/src/Util/Sortable.js b/src/Util/Sortable.js
index 176f9018..6d280557 100644
--- a/src/Util/Sortable.js
+++ b/src/Util/Sortable.js
@@ -37,11 +37,11 @@ class Sortable {
   }
 
   sortAscending() {
-    return this.sort(this.getSortFunctionAscending);
+    return this.sort(this.getSortFunctionAscending());
   }
 
   sortDescending() {
-    return this.sort(this.getSortFunctionDescending);
+    return this.sort(this.getSortFunctionDescending());
   }
 
   isSortAscending() {


Test patch:
diff --git a/test/SortableTest.js b/test/SortableTest.js
index d4357008..82a51af1 100644
--- a/test/SortableTest.js
+++ b/test/SortableTest.js
@@ -9,24 +9,54 @@ test("get Sort Function", t => {
 
 test("Alphabetic Ascending", t => {
   let s = new Sortable();
+  t.false(s.isSortNumeric());
+  t.true(s.isSortAscending());
+
   s.add("a");
   s.add("z");
   s.add("m");
   t.deepEqual(s.sort(), ["a", "m", "z"]);
 });
 
+test.skip("Alphabetic Ascending (shortcut)", t => {
+  /* FIXME THIS WILL NOT WORK because s.sortAscending() has been replaced by the boolean sortAscending.
+   *
+   * If backwards compatibility were not an issue, I'd recommend renaming the boolean properties
+   * to isSort(Ascending|Numeric) and renaming the getters & Setters to (get|set)IsSort(Ascending|Numeric)
+   */
+  let s = new Sortable();
+  s.add("a");
+  s.add("z");
+  s.add("m");
+  t.deepEqual(s.sortAscending(), ["a", "m", "z"]);
+});
+
 test("Alphabetic Descending", t => {
   let s = new Sortable();
   s.setSortDescending();
+  t.false(s.isSortNumeric());
+  t.false(s.isSortAscending());
+
   s.add("a");
   s.add("z");
   s.add("m");
   t.deepEqual(s.sort(), ["z", "m", "a"]);
 });
 
+test("Alphabetic Descending (shortcut)", t => {
+  let s = new Sortable();
+  s.add("a");
+  s.add("z");
+  s.add("m");
+  t.deepEqual(s.sortDescending(), ["z", "m", "a"]);
+});
+
 test("Numeric Ascending", t => {
   let s = new Sortable();
   s.setSortNumeric(true);
+  t.true(s.isSortNumeric());
+  t.true(s.isSortAscending());
+
   s.add(1);
   s.add(4);
   s.add(2);
@@ -37,6 +67,9 @@ test("Numeric Descending", t => {
   let s = new Sortable();
   s.setSortNumeric(true);
   s.setSortDescending();
+  t.true(s.isSortNumeric());
+  t.false(s.isSortAscending());
+
   s.add(1);
   s.add(4);
   s.add(2);
@@ -149,3 +182,19 @@ test("Alphabetic Descending (str sort arg)", t => {
   s.add("m");
   t.deepEqual(s.sort("descending"), ["z", "m", "a"]);
 });
+
+test("Alphabetic Ascending (short str sort arg)", t => {
+  let s = new Sortable();
+  s.add("a");
+  s.add("z");
+  s.add("m");
+  t.deepEqual(s.sort("A-Z"), ["a", "m", "z"]);
+});
+
+test("Alphabetic Descending (short str sort arg)", t => {
+  let s = new Sortable();
+  s.add("a");
+  s.add("z");
+  s.add("m");
+  t.deepEqual(s.sort("Z-A"), ["z", "m", "a"]);
+});
Repository: 11ty/eleventy
Pull request #1014 (2020-03-10 13:39:39)

Use getter for pagedItems in Pagination class ("TODO" fix)
Simply to have one less "TODO" in the code that could be fixed by a quick PR :).

The TODO said above the `getPagedItems` function:

> // TODO switch to a getter


Patch:
diff --git a/src/Plugins/Pagination.js b/src/Plugins/Pagination.js
index d94d4e61..cee6d4c7 100644
--- a/src/Plugins/Pagination.js
+++ b/src/Plugins/Pagination.js
@@ -63,7 +63,7 @@ class Pagination {
     this.alias = data.pagination.alias;
 
     this.target = this._resolveItems();
-    this.items = this.getPagedItems();
+    this.items = this.pagedItems;
   }
 
   setTemplate(tmpl) {
@@ -134,8 +134,7 @@ class Pagination {
     return result;
   }
 
-  getPagedItems() {
-    // TODO switch to a getter
+  get pagedItems() {
     if (!this.data) {
       throw new Error("Missing `setData` call for Pagination object.");
     }


Test patch:
diff --git a/test/PaginationTest.js b/test/PaginationTest.js
index f0e807cb..2bb6dccb 100644
--- a/test/PaginationTest.js
+++ b/test/PaginationTest.js
@@ -13,7 +13,7 @@ test("No data passed to pagination", async t => {
   let paging = new Pagination();
   paging.setTemplate(tmpl);
 
-  t.is(paging.getPagedItems().length, 0);
+  t.is(paging.pagedItems.length, 0);
   t.is((await paging.getPageTemplates()).length, 0);
 });
 
@@ -30,7 +30,7 @@ test("No pagination", async t => {
 
   t.falsy(data.pagination);
   t.is(paging.getPageCount(), 0);
-  t.is(paging.getPagedItems().length, 0);
+  t.is(paging.pagedItems.length, 0);
   t.is((await paging.getPageTemplates()).length, 0);
 });
 
@@ -66,7 +66,7 @@ test("Resolve paged data in frontmatter", async t => {
   paging.setTemplate(tmpl);
   t.is(paging._resolveItems().length, 8);
   t.is(paging.getPageCount(), 2);
-  t.is(paging.getPagedItems().length, 2);
+  t.is(paging.pagedItems.length, 2);
 });
 
 test("Paginate data in frontmatter", async t => {
Repository: 11ty/eleventy
Pull request #3181 (2024-02-01 15:06:27)

HtmlBasePlugin: Keep the URL hash
* src/Plugins/HtmlBasePlugin.js: Keep the hash if specified.
* test/HtmlBasePluginTest.js: Add tests.


Patch:
diff --git a/src/Plugins/HtmlBasePlugin.js b/src/Plugins/HtmlBasePlugin.js
index a9b7fd4c..849bf473 100644
--- a/src/Plugins/HtmlBasePlugin.js
+++ b/src/Plugins/HtmlBasePlugin.js
@@ -41,7 +41,8 @@ function transformUrl(url, base, opts = {}) {
 	if (isValidUrl(base)) {
 		// convert relative paths to absolute path first using pageUrl
 		if (pageUrl && !url.startsWith("/")) {
-			url = new URL(url, `http://example.com${pageUrl}`).pathname;
+			let urlObj = new URL(url, `http://example.com${pageUrl}`);
+			url = urlObj.pathname + (urlObj.hash || "");
 		}
 
 		return addPathPrefixToUrl(url, pathPrefix, base);


Test patch:
diff --git a/test/HtmlBasePluginTest.js b/test/HtmlBasePluginTest.js
index a18838fc..aaa6fc93 100644
--- a/test/HtmlBasePluginTest.js
+++ b/test/HtmlBasePluginTest.js
@@ -36,6 +36,9 @@ test("Using the filter directly", async (t) => {
   t.is(applyBaseToUrl("subdir/", "/pathprefix/"), "subdir/");
   t.is(applyBaseToUrl("../subdir/", "/pathprefix/"), "../subdir/");
   t.is(applyBaseToUrl("./subdir/", "/pathprefix/"), "subdir/");
+  t.is(applyBaseToUrl("#anchor", "/pathprefix/"), "#anchor");
+  t.is(applyBaseToUrl("/test/#anchor", "/pathprefix/"), "/pathprefix/test/#anchor");
+  t.is(applyBaseToUrl("/test/?param=value", "/pathprefix/"), "/pathprefix/test/?param=value");
   t.is(applyBaseToUrl("http://url.com/", "/pathprefix/"), "http://url.com/");
   t.is(applyBaseToUrl("http://url.com/test/", "/pathprefix/"), "http://url.com/test/");
 
@@ -47,6 +50,9 @@ test("Using the filter directly", async (t) => {
   t.is(applyBaseToUrl("./subdir/", "http://example.com/"), "http://example.com/subdir/");
   t.is(applyBaseToUrl("http://url.com/", "http://example.com/"), "http://url.com/");
   t.is(applyBaseToUrl("http://url.com/test/", "http://example.com/"), "http://url.com/test/");
+  t.is(applyBaseToUrl("#anchor", "http://example.com/"), "http://example.com/#anchor");
+	t.is(applyBaseToUrl("/test/#anchor", "http://example.com/"), "http://example.com/test/#anchor");
+	t.is(applyBaseToUrl("/test/?param=value#anchor", "http://example.com/"), "http://example.com/test/?param=value#anchor");
 
   // with a URL base with extra subdirectory
   t.is(applyBaseToUrl("/", "http://example.com/ignored/"), "http://example.com/");
Repository: 11ty/eleventy
Pull request #3346 (2024-07-04 12:55:08)

fix: encodeURI for passthrough aliases
This fixes files with non-ASCII names not working (404) when server passthrough copy behavior is set to `"passthrough"` and the requested file is not already copied to the dist folder.


Patch:
diff --git a/src/TemplatePassthroughManager.js b/src/TemplatePassthroughManager.js
index a66d0ac2..06b0746a 100644
--- a/src/TemplatePassthroughManager.js
+++ b/src/TemplatePassthroughManager.js
@@ -273,7 +273,7 @@ class TemplatePassthroughManager {
 		for (let entry of result) {
 			for (let src in entry.map) {
 				let dest = TemplatePath.stripLeadingSubPath(entry.map[src], this.outputDir);
-				entries["/" + dest] = src;
+				entries["/" + encodeURI(dest)] = src;
 			}
 		}
 		return entries;


Test patch:
diff --git a/test/TemplatePassthroughManagerTest.js b/test/TemplatePassthroughManagerTest.js
index 48edb0b5..18a5d94c 100644
--- a/test/TemplatePassthroughManagerTest.js
+++ b/test/TemplatePassthroughManagerTest.js
@@ -8,7 +8,7 @@ import FileSystemSearch from "../src/FileSystemSearch.js";
 import EleventyFiles from "../src/EleventyFiles.js";
 import EleventyExtensionMap from "../src/EleventyExtensionMap.js";
 
-import { getTemplateConfigInstanceCustomCallback } from "./_testHelpers.js";
+import { getTemplateConfigInstance, getTemplateConfigInstanceCustomCallback } from "./_testHelpers.js";
 
 test("Get paths from Config", async (t) => {
   let eleventyConfig = new TemplateConfig();
@@ -188,6 +188,24 @@ test("getAllNormalizedPaths with globs", async (t) => {
   ]);
 });
 
+test("getAliasesFromPassthroughResults with Unicode filenames", async (t) => {
+  let eleventyConfig = await getTemplateConfigInstance();
+
+  let mgr = new TemplatePassthroughManager(eleventyConfig);
+  let results = [
+    { map: { "./path/file": "_site/path/file" } },
+    { map: { "./测试.用例/⌘": "_site/测试.用例/⌘" } },
+    { map: { "./path/测试.用例": "_site/path/测试.用例" } },
+    { map: { "./测试.用例/file": "_site/测试.用例/file" } },
+  ]
+  t.deepEqual(mgr.getAliasesFromPassthroughResults(results), {
+    "/path/file": "./path/file",
+    "/%E6%B5%8B%E8%AF%95.%E7%94%A8%E4%BE%8B/%E2%8C%98": "./测试.用例/⌘",
+    "/path/%E6%B5%8B%E8%AF%95.%E7%94%A8%E4%BE%8B": "./path/测试.用例",
+    "/%E6%B5%8B%E8%AF%95.%E7%94%A8%E4%BE%8B/file": "./测试.用例/file",
+  });
+});
+
 test("Look for uniqueness on template passthrough paths #1677", async (t) => {
   let formats = [];
Repository: json-schema-faker/json-schema-faker
Pull request #746 (2023-03-02 13:01:05)

Allow empty arrays without defined items
Schema:

```json
{
  "foo": {
    "type": "array",
    "minItems": 0,
    "maxItems": 0,
    "uniqueItems": true
  }
}
```

I would expect this schema to always generate empty arrays. Instead, I get the error below:

```
Error while resolving schema (missing items for {
  "type": "array",
  "minItems": 0,
  "maxItems": 0,
  "uniqueItems": true
} in /foo)
```

I understand why `items` is required in general, but if `minItems` and `maxItems` are both zero, no array item will ever be generated, so it should be fine for `items` to be empty. I'm using a tool that sometimes generates schemas like this, so it would be helpful if this case were handled.


Patch:
diff --git a/src/lib/types/array.mjs b/src/lib/types/array.mjs
index 21490ba..c783c50 100644
--- a/src/lib/types/array.mjs
+++ b/src/lib/types/array.mjs
@@ -45,7 +45,9 @@ function arrayType(value, path, resolve, traverseCallback) {
 
   if (!(value.items || value.additionalItems)) {
     if (utils.hasProperties(value, 'minItems', 'maxItems', 'uniqueItems')) {
-      throw new ParseError(`missing items for ${utils.short(value)}`, path);
+      if (value.minItems !== 0 || value.maxItems !== 0) {
+        throw new ParseError(`missing items for ${utils.short(value)}`, path);
+      }
     }
     return items;
   }


Test patch:
diff --git a/tests/schema/core/types/array.json b/tests/schema/core/types/array.json
index 1bcc170..166da7a 100644
--- a/tests/schema/core/types/array.json
+++ b/tests/schema/core/types/array.json
@@ -135,6 +135,17 @@
         },
         "throws": "missing items for [\\s\\S]+ in \\/"
       },
+      {
+        "description": "should validate items using all options",
+        "schema": {
+          "type": "array",
+          "minItems": 0,
+          "maxItems": 0,
+          "uniqueItems": true,
+          "additionalItems": false
+        },
+        "valid": true
+      },
       {
         "description": "should handle inferred type (when possible)",
         "schema": {
Repository: json-schema-faker/json-schema-faker
Pull request #757 (2023-04-14 14:19:16)

fix: alwaysFakeOptionals causes additionalProperties to generate the …
fix: generate type err bug #749 


Patch:
diff --git a/src/lib/types/object.mjs b/src/lib/types/object.mjs
index 274d0ed..0f388cb 100644
--- a/src/lib/types/object.mjs
+++ b/src/lib/types/object.mjs
@@ -196,7 +196,7 @@ function objectType(value, path, resolve, traverseCallback) {
     const limit = random.number(0, max);
 
     for (let i = 0; i < limit; i += 1) {
-      props[words(1) + hash(limit[i])] = anyType;
+      props[words(1) + hash(limit[i])] = additionalProperties || anyType;
     }
   }
 


Test patch:
diff --git a/tests/schema/core/issues/issue-749.json b/tests/schema/core/issues/issue-749.json
new file mode 100644
index 0000000..f8fb80d
--- /dev/null
+++ b/tests/schema/core/issues/issue-749.json
@@ -0,0 +1,25 @@
+[
+  {
+    "description": "generate the current type when use alwaysFakeOptionals true and additionalProperties option",
+    "tests": [
+      {
+        "description": "should generate current type",
+        "schema": {
+          "properties": {
+            "fields": {
+              "type": "object",
+              "additionalProperties": {
+                "type": "string"
+              }
+            }
+          }
+        },
+        "valid": true,
+        "random": "some seed",
+        "set": {
+          "alwaysFakeOptionals": true
+        }
+      }
+    ]
+  }
+]
Repository: json-schema-faker/json-schema-faker
Pull request #762 (2023-04-21 01:47:01)

fix: use alwaysFakeOptionals, not required object type should be corr…
fix: #761 
when use alwaysFakeOptionals true, not required object type should be correct generate!


Patch:
diff --git a/src/lib/core/utils.mjs b/src/lib/core/utils.mjs
index 7cdf246..1135a65 100644
--- a/src/lib/core/utils.mjs
+++ b/src/lib/core/utils.mjs
@@ -474,7 +474,9 @@ function isEmpty(value) {
 function shouldClean(key, schema) {
   schema = schema.items || schema;
 
-  const isRequired = Array.isArray(schema.required) && schema.required.includes(key);
+  // fix: when alwaysFakeOptionals is true, need set isRequired to true, see bug:https://github.com/json-schema-faker/json-schema-faker/issues/761
+  const alwaysFakeOptionals = optionAPI('alwaysFakeOptionals');
+  const isRequired = (Array.isArray(schema.required) && schema.required.includes(key)) || alwaysFakeOptionals;
   const wasCleaned = typeof schema.thunk === 'function' || (schema.additionalProperties && typeof schema.additionalProperties.thunk === 'function');
 
   return !isRequired && !wasCleaned;


Test patch:
diff --git a/tests/schema/core/types/object.json b/tests/schema/core/types/object.json
index b9bfbb3..9418e98 100644
--- a/tests/schema/core/types/object.json
+++ b/tests/schema/core/types/object.json
@@ -374,6 +374,19 @@
                   ]
                 }
               }
+            },
+            "data3": {
+              "type": "object",
+              "properties": {
+                "data1": {
+                  "type": "object",
+                  "properties": {
+                    "obj": {
+                      "type": "object"
+                    }
+                  }
+                }
+              }
             }
           },
           "required": [
@@ -392,6 +405,11 @@
               "obj": {}
             }
           },
+          "data3": {
+            "data1": {
+              "obj": {}
+            }
+          },
           "obj": {}
         },
         "set": {