`null` not supported in `enum`?
- Dominant language
- JavaScript
- Stars
- 137
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
It appears that including `null` inside an `enum` is causing wetzel to fail with an error. In our use case, we have a property which may either be a pre-defined string or else may be null. I've replicated the general idea in the sample json below.
I have worked around this for our needs, but I am submitting this in case it's helpful.
Example json:
```json
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "example.enum.null",
"title": "Null enum demo",
"type": "object",
"properties": {
"example": {
"enum": [null, "a", "b"]
}
}
}
```
Command:
```
node bin/wetzel.js example.json
```
Output:
```
/Users/ehall/Code/wetzel/lib/replaceRef.js:30
const ref = schema.$ref;
^
TypeError: Cannot read properties of null (reading '$ref')
at replaceRef (/Users/ehall/Code/wetzel/lib/replaceRef.js:30:24)
at replaceRef (/Users/ehall/Code/wetzel/lib/replaceRef.js:100:32)
at replaceRef (/Users/ehall/Code/wetzel/lib/replaceRef.js:100:32)
at replaceRef (/Users/ehall/Code/wetzel/lib/replaceRef.js:100:32)
at replaceRef (/Users/ehall/Code/wetzel/lib/replaceRef.js:100:32)
at Object.resolve (/Users/ehall/Code/wetzel/lib/schema4Resolver.js:35:19)
at generateMarkdown (/Users/ehall/Code/wetzel/lib/generateMarkdown.js:45:32)
at Object. (/Users/ehall/Code/wetzel/bin/wetzel.js:94:22)
at Module._compile (node:internal/modules/cjs/loader:1356:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with lib/replaceRef.js, where the stack trace shows null is treated as a schema object, and follow its recursive calls from lib/schema4Resolver.js. Reproduce the failure with node bin/wetzel.js example.json, then verify that the same example completes successfully and handles the null enum value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100