mirror of
https://github.com/mjl-/mox.git
synced 2024-12-28 01:13:47 +03:00
a2c9cfc55b
several fields in dmarc and tls reports have known string values. we have a Go string type for them. sherpats (through sherpadoc) turns those strings into typescript enums, and sherpats generates runtime-typechecking code (to enforce correct types for incoming json, to prevent failing deeper in the code when we get invalid data (much harder to debug)). the Go not-really-enum types allow other values, and real-world reports have unknown/unspecified/invalid values. this uses the sherpadoc -rename flag to turn those enums into regular untyped strings, so sherpats doesn't generate enum-enforcing runtime type checking code. this required an update to sherpadoc, to properly handling renaming a type to a basic type instead of another named type. for issue #161 by RobSlgm, thanks for reporting! |
||
---|---|---|
.. | ||
cmd/sherpadoc | ||
check.go | ||
LICENSE | ||
README.txt | ||
sherpadoc.go |
sherpadoc - documentation for sherpa API's Go package containing type defintions for sherpa documentation for encoding to and decoding from json. Also contains the sherpadoc command reads Go code and writes sherpadoc JSON. Use together with the sherpa library, github.com/mjl-/sherpa. Read more about sherpa at https://www.ueber.net/who/mjl/sherpa/ # About Written by Mechiel Lukkien, mechiel@ueber.net. Bug fixes, patches, comments are welcome. MIT-licensed, see LICENSE. # todo - major cleanup required. too much parsing is done that can probably be handled by the go/* packages. - check that all cases of embedding work (seems like we will include duplicates: when a struct has fields that override an embedded struct, we generate duplicate fields). - check that all cross-package referencing (ast.SelectorExpr) works - better cli syntax for replacements and renames, and always replace based on fully qualified names. currently you need to specify both the fully qualified and unqualified type paths. - see if order of items in output depends on a map somewhere, i've seen diffs for generated jsons where a type was only moved, not modified. perhaps the type was discovered earlier/later because of other type changes. we may want to sort sections,methods,types in the output. - better error messages and error handling, stricter parsing - support type aliases - support plain iota enums? currently only simple literals are supported for enums. - support complete expressions for enum consts? - find out which go constructs people want to use that aren't yet implemented by sherpadoc - when to make a field nullable. when omitempty is set? (currently yes), when field is a pointer type (currently yes). should we have a way to prevent nullable without omitempty set, or make field a pointer without it being nullable? - write tests