Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions module/openapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,12 @@ func TestValidateScalarValue(t *testing.T) {
{"string too long", "toolongstring", &openAPISchema{Type: "string", MaxLength: &maxLen}, true},
{"enum match", "cat", &openAPISchema{Type: "string", Enum: []any{"cat", "dog"}}, false},
{"enum mismatch", "fish", &openAPISchema{Type: "string", Enum: []any{"cat", "dog"}}, true},
// Query/path parameters are always strings; integer enum values from YAML
// (e.g. enum: [1, 2, 3]) are compared as their string representation.
// This is intentional: the parameter "1" should match the YAML integer 1.
{"enum integer yaml matches string param", "1", &openAPISchema{Type: "integer", Enum: []any{1, 2, 3}}, false},
{"enum integer yaml no match", "4", &openAPISchema{Type: "integer", Enum: []any{1, 2, 3}}, true},
{"enum nil values skipped", "a", &openAPISchema{Enum: []any{nil, "a", nil}}, false},
}

for _, tt := range tests {
Expand Down
5 changes: 5 additions & 0 deletions plugins/openapi/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func (p *Plugin) ModuleFactories() map[string]plugin.ModuleFactory {
"openapi": func(name string, cfg map[string]any) modular.Module {
oacfg := module.OpenAPIConfig{}

// NOTE: spec_file existence is not validated here at configuration time.
// Path resolution is performed by ResolvePathInConfig (relative to the
// config file directory via the _config_dir key), but file existence and
// readability are checked lazily during Init(). Errors will surface at
// engine startup, after all modules have been constructed.
if v, ok := cfg["spec_file"].(string); ok {
oacfg.SpecFile = config.ResolvePathInConfig(cfg, v)
}
Expand Down