Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c843469
add refactoring CLI (WIP)
marle3003 Oct 14, 2025
ea4e559
Merge remote-tracking branch 'origin/develop' into develop
marle3003 Oct 14, 2025
f5078d9
fix build error
marle3003 Oct 14, 2025
22ecdab
fix build error
marle3003 Oct 15, 2025
9d0b259
fix avro schema convert
marle3003 Oct 15, 2025
5ddf4c9
fix test
marle3003 Oct 15, 2025
a16cbdd
fix config url
marle3003 Oct 15, 2025
96391be
fix faker module extending data generator
marle3003 Oct 15, 2025
4344167
fix test
marle3003 Oct 15, 2025
fdb28e2
fix null reference in OpenAPI when no responses defined for operation
marle3003 Oct 15, 2025
5f83763
Merge branch 'main' into develop
marle3003 Oct 15, 2025
a7529f4
fix null reference error
marle3003 Oct 16, 2025
607fa59
Bump github.com/evanw/esbuild from 0.25.10 to 0.25.11
dependabot[bot] Oct 17, 2025
e8876a1
Bump eslint-plugin-vue from 10.5.0 to 10.5.1 in /webui
dependabot[bot] Oct 17, 2025
fff489f
Merge pull request #711 from marle3003/dependabot/npm_and_yarn/webui/…
github-actions[bot] Oct 17, 2025
37f503b
Bump vue-router from 4.5.1 to 4.6.3 in /webui
dependabot[bot] Oct 17, 2025
6c59fa1
Merge pull request #713 from marle3003/dependabot/npm_and_yarn/webui/…
github-actions[bot] Oct 17, 2025
51c4e80
Bump @types/node from 24.7.1 to 24.8.1 in /webui
dependabot[bot] Oct 17, 2025
b437d37
Merge pull request #710 from marle3003/dependabot/npm_and_yarn/webui/…
github-actions[bot] Oct 17, 2025
42be98e
Bump @playwright/test from 1.56.0 to 1.56.1 in /webui
dependabot[bot] Oct 17, 2025
3b95cd3
Merge pull request #712 from marle3003/dependabot/npm_and_yarn/webui/…
github-actions[bot] Oct 17, 2025
c699908
Bump vite from 7.1.9 to 7.1.10 in /webui
dependabot[bot] Oct 17, 2025
2a2c874
Merge pull request #714 from marle3003/dependabot/npm_and_yarn/webui/…
github-actions[bot] Oct 17, 2025
3cb2b46
fix OpenAPI parameter in webui
marle3003 Oct 19, 2025
d002cb6
Merge remote-tracking branch 'origin/develop' into develop
marle3003 Oct 19, 2025
0f6f61d
fix test
marle3003 Oct 19, 2025
0f43cd8
fix test
marle3003 Oct 19, 2025
a3ed85e
fix test
marle3003 Oct 19, 2025
85bf65a
Merge branch 'develop' into dependabot/go_modules/develop/github.com/…
marle3003 Oct 19, 2025
2723d55
Merge pull request #709 from marle3003/dependabot/go_modules/develop/…
github-actions[bot] Oct 19, 2025
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
5 changes: 0 additions & 5 deletions acceptance/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"mokapi/server/cert"
"mokapi/version"

"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)

Expand All @@ -34,10 +33,6 @@ type Cmd struct {
func Start(cfg *static.Config) (*Cmd, error) {
log.SetLevel(log.DebugLevel)

if len(cfg.Services) > 0 {
return nil, errors.New("static configuration Services are no longer supported. Use patching instead.")
}

feature.Enable(cfg.Features)

registerDynamicTypes()
Expand Down
64 changes: 33 additions & 31 deletions api/handler_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,44 +211,46 @@ func (h *handler) getHttpService(w http.ResponseWriter, r *http.Request, m *moni
op.Parameters = getParameters(p.Value.Parameters)
op.Parameters = append(op.Parameters, getParameters(o.Parameters)...)

for it := o.Responses.Iter(); it.Next(); {
statusCode := it.Key()
r := it.Value()
if r.Value == nil {
continue
}
res := response{
StatusCode: statusCode,
Description: r.Value.Description,
}
if len(r.Description) > 0 {
res.Description = r.Description
}

for ct, r := range r.Value.Content {
res.Contents = append(res.Contents, mediaType{
Type: ct,
Schema: r.Schema,
})
}
for name, h := range r.Value.Headers {
if h.Value == nil {
if o.Responses != nil {
for it := o.Responses.Iter(); it.Next(); {
statusCode := it.Key()
r := it.Value()
if r.Value == nil {
continue
}
res := response{
StatusCode: statusCode,
Description: r.Value.Description,
}
if len(r.Description) > 0 {
res.Description = r.Description
}

hi := header{
Name: name,
Description: h.Value.Description,
Schema: h.Value.Schema,
for ct, r := range r.Value.Content {
res.Contents = append(res.Contents, mediaType{
Type: ct,
Schema: r.Schema,
})
}
if len(h.Description) > 0 {
hi.Description = h.Description
for name, h := range r.Value.Headers {
if h.Value == nil {
continue
}

hi := header{
Name: name,
Description: h.Value.Description,
Schema: h.Value.Schema,
}
if len(h.Description) > 0 {
hi.Description = h.Description
}

res.Headers = append(res.Headers, hi)
}

res.Headers = append(res.Headers, hi)
op.Responses = append(op.Responses, res)
}

op.Responses = append(op.Responses, res)
}

requirements := append(o.Security, s.Security...)
Expand Down
4 changes: 2 additions & 2 deletions api/handler_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (h *handler) getExampleData(w http.ResponseWriter, r *http.Request) {
case *openApiSchema.Schema:
s = openApiSchema.ConvertToJsonSchema(t)
case *avro.Schema:
s = t.Convert()
s = avro.ConvertToJsonSchema(t)
default:
var ok bool
s, ok = t.(*jsonSchema.Schema)
Expand Down Expand Up @@ -151,7 +151,7 @@ func encodeExample(v interface{}, schema interface{}, schemaFormat string, conte
case *avro.Schema:
switch {
case ct.Subtype == "json":
data, err = encoding.NewEncoder(t.Convert()).Write(v, ct)
data, err = encoding.NewEncoder(avro.ConvertToJsonSchema(t)).Write(v, ct)
case ct.Key() == "avro/binary" || ct.Key() == "application/avro" || ct.Key() == "application/octet-stream":
data, err = t.Marshal(v)
default:
Expand Down
4 changes: 2 additions & 2 deletions api/handler_schema_asyncapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func getAsyncApiExample(w http.ResponseWriter, r *http.Request, cfg *asyncapi3.C
case *openApiSchema.Schema:
s = openApiSchema.ConvertToJsonSchema(t)
case *avro.Schema:
s = t.Convert()
s = avro.ConvertToJsonSchema(t)
default:
var ok bool
s, ok = t.(*jsonSchema.Schema)
Expand All @@ -85,7 +85,7 @@ func getAsyncApiExample(w http.ResponseWriter, r *http.Request, cfg *asyncapi3.C
case *avro.Schema:
switch {
case ct.Subtype == "json":
data, err = encoding.NewEncoder(t.Convert()).Write(rnd, ct)
data, err = encoding.NewEncoder(avro.ConvertToJsonSchema(t)).Write(rnd, ct)
case ct.Key() == "avro/binary" || ct.Key() == "application/avro" || ct.Key() == "application/octet-stream":
data, err = t.Marshal(rnd)
default:
Expand Down
27 changes: 10 additions & 17 deletions cmd/mokapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ func main() {

fmt.Printf(logo, version.BuildVersion, strings.Repeat(" ", 17-len(versionString)))

if len(cfg.Services) > 0 {
fmt.Println("static configuration Services are no longer supported. Use patching instead.")
return
}

configureLogging(cfg)
registerDynamicTypes()

Expand Down Expand Up @@ -139,19 +134,17 @@ func createServer(cfg *static.Config) (*server.Server, error) {
func configureLogging(cfg *static.Config) {
stdlog.SetFlags(stdlog.Lshortfile | stdlog.LstdFlags)

if cfg.Log != nil {
level, err := log.ParseLevel(cfg.Log.Level)
if err != nil {
log.WithField("logLevel", cfg.Log.Level).Errorf("error parsing log level: %v", err.Error())
}
log.SetLevel(level)
level, err := log.ParseLevel(cfg.Log.Level)
if err != nil {
log.WithField("logLevel", cfg.Log.Level).Errorf("error parsing log level: %v", err.Error())
}
log.SetLevel(level)

if strings.ToLower(cfg.Log.Format) == "json" {
log.SetFormatter(&log.JSONFormatter{})
} else {
formatter := &log.TextFormatter{DisableColors: false, FullTimestamp: true, DisableSorting: true}
log.SetFormatter(formatter)
}
if strings.ToLower(cfg.Log.Format) == "json" {
log.SetFormatter(&log.JSONFormatter{})
} else {
formatter := &log.TextFormatter{DisableColors: false, FullTimestamp: true, DisableSorting: true}
log.SetFormatter(formatter)
}
}

Expand Down
7 changes: 2 additions & 5 deletions cmd/mokapi/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ providers:
file:
filenames: []
directories: []
skipprefix:
skipPrefix:
- _
include: []
git:
Expand All @@ -59,11 +59,8 @@ api:
dashboard: true
search:
enabled: false
types: []
rootCaCert: ""
rootCaKey: ""
js:
globalfolders: []
configs: []
event:
store:
Expand All @@ -83,7 +80,7 @@ data-gen:
require.Equal(t, `file:
filenames: []
directories: []
skipprefix:
skipPrefix:
- _
include: []
git:
Expand Down
1 change: 1 addition & 0 deletions config/dynamic/provider/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (p *Provider) Read(u *url.URL) (*dynamic.Config, error) {
if err != nil {
return nil, err
}
config.Info.Url = u
config.SourceType = dynamic.SourceReference

p.watchPath(file)
Expand Down
66 changes: 14 additions & 52 deletions config/static/static_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import (
)

type Config struct {
Log *MokApiLog `json:"log" yaml:"log"`
ConfigFile string `json:"-" yaml:"-"`
Log MokApiLog `json:"log" yaml:"log"`
ConfigFile string `json:"-" yaml:"-" flag:"-"`
Providers Providers `json:"providers" yaml:"providers"`
Api Api `json:"api" yaml:"api"`
RootCaCert tls.FileOrContent `json:"rootCaCert" yaml:"rootCaCert"`
RootCaKey tls.FileOrContent `json:"rootCaKey" yaml:"rootCaKey"`
Services Services `json:"-" yaml:"-"`
Js JsConfig `json:"js" yaml:"js"`
RootCaCert tls.FileOrContent `json:"rootCaCert" yaml:"rootCaCert" name:"root-ca-cert"`
RootCaKey tls.FileOrContent `json:"rootCaKey" yaml:"rootCaKey" name:"root-ca-cert"`
Configs Configs `json:"configs" yaml:"configs" explode:"config"`
Help bool `json:"-" yaml:"-" aliases:"h"`
GenerateSkeleton interface{} `json:"-" yaml:"-" flag:"generate-cli-skeleton"`
Expand All @@ -33,7 +31,7 @@ type Config struct {

func NewConfig() *Config {
cfg := &Config{}
cfg.Log = &MokApiLog{Level: "info", Format: "text"}
cfg.Log = MokApiLog{Level: "info", Format: "text"}

cfg.Api.Port = "8080"
cfg.Api.Dashboard = true
Expand Down Expand Up @@ -67,37 +65,31 @@ type Api struct {

type Search struct {
Enabled bool
Types []string
}

type NgramAnalyzer struct {
Min int
Max int
}

type FileProvider struct {
Filenames []string `explode:"filename"`
Directories []string `explode:"directory"`
SkipPrefix []string `flag:"skip-prefix"`
SkipPrefix []string `yaml:"skipPrefix" json:"skipPrefix" flag:"skip-prefix"`
Include []string
}

type GitProvider struct {
Urls []string `explode:"url"`
PullInterval string `yaml:"pullInterval" name:"pull-interval"`
TempDir string `yaml:"tempDir" name:"temp-dir"`
PullInterval string `yaml:"pullInterval" json:"pullInterval" name:"pull-interval"`
TempDir string `yaml:"tempDir" json:"tempDir" name:"temp-dir"`

Repositories []GitRepo `explode:"repository"`
}

type GitRepo struct {
Url string
// Specifies an allow list of files to include in mokapi
Files []string
Files []string `explode:"file"`
// Specifies an array of filenames pr pattern to include in mokapi
Include []string
Auth *GitAuth
PullInterval string `yaml:"pullInterval"`
PullInterval string `yaml:"pullInterval" name:"pull-interval"`
}

type GitAuth struct {
Expand All @@ -112,15 +104,15 @@ type GitHubAuth struct {

type HttpProvider struct {
Urls []string `explode:"url"`
PollInterval string `yaml:"pollInterval" flag:"poll-interval"`
PollTimeout string `yaml:"pollTimeout" flag:"poll-timeout"`
PollInterval string `yaml:"pollInterval" name:"poll-interval"`
PollTimeout string `yaml:"pollTimeout" name:"poll-timeout"`
Proxy string
TlsSkipVerify bool `yaml:"tlsSkipVerify" flag:"tls-skip-verify"`
Ca tls.FileOrContent `yaml:"ca"`
}

type NpmProvider struct {
GlobalFolders []string `yaml:"globalFolders" flag:"global-folders"`
GlobalFolders []string `yaml:"globalFolders" name:"global-folders" explode:"global-folders"`
Packages []NpmPackage `explode:"package"`
}

Expand All @@ -132,36 +124,6 @@ type NpmPackage struct {
Include []string
}

type Services map[string]*Service

func (s Services) GetByName(name string) *Service {
key := strings.ReplaceAll(name, " ", "-")
key = strings.ToLower(key)
return s[key]
}

type Service struct {
Config ServiceConfig
Http *HttpService
}

type ServiceConfig struct {
File string
Url string
}

type HttpService struct {
Servers []HttpServer
}

type HttpServer struct {
Url string
}

type JsConfig struct {
GlobalFolders []string
}

type Event struct {
Store map[string]Store
}
Expand All @@ -182,7 +144,7 @@ type Certificate struct {
}

type DataGen struct {
OptionalProperties string `yaml:"optionalProperties" json:"optionalProperties"`
OptionalProperties string `yaml:"optionalProperties" json:"optionalProperties" name:"optional-properties"`
}

func (c *Configs) UnmarshalJSON(b []byte) error {
Expand Down
4 changes: 2 additions & 2 deletions engine/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func createValue(r *asyncapi3.SchemaRef) (value interface{}, err error) {
case *openapi.Schema:
value, err = openapi.CreateValue(v)
case *avro.Schema:
jsSchema := v.Convert()
jsSchema := avro.ConvertToJsonSchema(v)
value, err = generator.New(&generator.Request{Schema: jsSchema})
default:
err = fmt.Errorf("schema format not supported: %v", r.Value.Format)
Expand Down Expand Up @@ -289,7 +289,7 @@ func valueMatchMessagePayload(value any, msg *asyncapi3.Message) bool {
_, err := v.Marshal(value, media.ParseContentType("application/json"))
return err == nil
case *avro.Schema:
jsSchema := v.Convert()
jsSchema := avro.ConvertToJsonSchema(v)
_, err := encoding.NewEncoder(jsSchema).Write(value, media.ParseContentType("application/json"))
return err == nil
default:
Expand Down
2 changes: 1 addition & 1 deletion engine/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (l *DefaultScriptLoader) Load(file *dynamic.Config, host common.Host) (comm
filename := file.Info.Path()
switch filepath.Ext(filename) {
case ".js", ".cjs", ".mjs", ".ts":
return js.New(file, host, l.config.Js)
return js.New(file, host)
case ".lua":
return lua.New(getScriptPath(file.Info.Url), s, host)
default:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/bradleyfalzon/ghinstallation/v2 v2.17.0
github.com/brianvoe/gofakeit/v6 v6.28.0
github.com/dop251/goja v0.0.0-20250309171923-bcd7cc6bf64c
github.com/evanw/esbuild v0.25.10
github.com/evanw/esbuild v0.25.11
github.com/fsnotify/fsnotify v1.9.0
github.com/go-co-op/gocron v1.37.0
github.com/go-git/go-git/v5 v5.16.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o
github.com/elazarl/goproxy v1.7.2/go.mod h1:82vkLNir0ALaW14Rc399OTTjyNREgmdL2cVoIbS6XaE=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/evanw/esbuild v0.25.10 h1:8cl6FntLWO4AbqXWqMWgYrvdm8lLSFm5HjU/HY2N27E=
github.com/evanw/esbuild v0.25.10/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48=
github.com/evanw/esbuild v0.25.11 h1:NGtezc+xk+Mti4fgWaoD3dncZNCzcTA+r0BxMV3Koyw=
github.com/evanw/esbuild v0.25.11/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c=
Expand Down
Loading