Documentation ¶
Overview ¶
Package rules contains API rules that are enforced in OpenAPI spec generation as part of the machinery. Files under this package implement APIRule interface which evaluates Go type and produces list of API rule violations.
Implementations of APIRule should be added to API linter under openAPIGen code- generator to get integrated in the generation process.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NamesMatch ¶
type NamesMatch struct{}
NamesMatch implements APIRule interface. Go field names must be CamelCase. JSON field names must be camelCase. Other than capitalization of the initial letter, the two should almost always match. No underscores nor dashes in either. This rule verifies the convention "Other than capitalization of the initial letter, the two should almost always match." Examples (also in unit test):
Go name | JSON name | match podSpec false PodSpec podSpec true PodSpec PodSpec false podSpec podSpec false PodSpec spec false Spec podSpec false JSONSpec jsonSpec true JSONSpec jsonspec false HTTPJSONSpec httpJSONSpec true
NOTE: this validator cannot tell two sequential all-capital words from one word, therefore the case below is also considered matched.
HTTPJSONSpec httpjsonSpec true
NOTE: JSON names in jsonNameBlacklist should skip evaluation
true podSpec true podSpec - true podSpec metadata true