diff --git a/Makefile b/Makefile index 0807147..ae7411b 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ PKG := ./... COVERAGE_DIR := coverage COVERAGE_FILE := coverage.out -ADAPTERS := chiopenapi echoopenapi fiberopenapi ginopenapi httpopenapi muxopenapi httprouteropenapi +ADAPTERS := chiopenapi echoopenapi fiberopenapi/v2 fiberopenapi/v3 ginopenapi httpopenapi muxopenapi httprouteropenapi # Platform detection for sed compatibility # Using an immediately expanded variable for this is good practice. diff --git a/RELEASE.md b/RELEASE.md index bafde89..f807d69 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -10,7 +10,8 @@ The project consists of: - **Adapter modules**: Framework-specific integrations - `github.com/oaswrap/spec/adapter/chiopenapi` - Chi framework adapter - `github.com/oaswrap/spec/adapter/echoopenapi` - Echo framework adapter - - `github.com/oaswrap/spec/adapter/fiberopenapi` - Fiber framework adapter + - `github.com/oaswrap/spec/adapter/fiberopenapi/v2` - Fiber v2 framework adapter + - `github.com/oaswrap/spec/adapter/fiberopenapi/v3` - Fiber v3 framework adapter - `github.com/oaswrap/spec/adapter/ginopenapi` - Gin framework adapter - `github.com/oaswrap/spec/adapter/httpopenapi` - net/http adapter - `github.com/oaswrap/spec/adapter/httprouteropenapi` - HttpRouter adapter diff --git a/adapter/chiopenapi/examples/basic/go.sum b/adapter/chiopenapi/examples/basic/go.sum index 43e9266..07577f4 100644 --- a/adapter/chiopenapi/examples/basic/go.sum +++ b/adapter/chiopenapi/examples/basic/go.sum @@ -11,8 +11,11 @@ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/oaswrap/spec v0.3.6 h1:igKJvrrEYP/pK5I4TzEzYVcdbbr8eJ1gfALUXgZ/Oc8= +github.com/oaswrap/spec v0.3.6/go.mod h1:e6cGQJcVCkQozwsw8T0ydSWEgQPA/dHFmQME4KawOYU= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= github.com/oaswrap/spec-ui v0.1.4/go.mod h1:D8EnD6zbYJ3q65wdltw6QHXfw+nut5XwSSA1xtlSEQQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -20,11 +23,13 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= github.com/swaggest/jsonschema-go v0.3.78 h1:5+YFQrLxOR8z6CHvgtZc42WRy/Q9zRQQ4HoAxlinlHw= github.com/swaggest/jsonschema-go v0.3.78/go.mod h1:4nniXBuE+FIGkOGuidjOINMH7OEqZK3HCSbfDuLRI0g= github.com/swaggest/openapi-go v0.2.60 h1:kglHH/WIfqAglfuWL4tu0LPakqNYySzklUWx06SjSKo= +github.com/swaggest/openapi-go v0.2.60/go.mod h1:jmFOuYdsWGtHU0BOuILlHZQJxLqHiAE6en+baE+QQUk= github.com/swaggest/refl v1.4.0 h1:CftOSdTqRqs100xpFOT/Rifss5xBV/CT0S/FN60Xe9k= github.com/swaggest/refl v1.4.0/go.mod h1:4uUVFVfPJ0NSX9FPwMPspeHos9wPFlCMGoPRllUbpvA= github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= @@ -33,6 +38,7 @@ github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3Ifn github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/adapter/chiopenapi/go.mod b/adapter/chiopenapi/go.mod index bf1c19a..cc0a806 100644 --- a/adapter/chiopenapi/go.mod +++ b/adapter/chiopenapi/go.mod @@ -12,7 +12,7 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/kr/text v0.1.0 // indirect + github.com/kr/text v0.2.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/swaggest/jsonschema-go v0.3.78 // indirect github.com/swaggest/openapi-go v0.2.60 // indirect diff --git a/adapter/chiopenapi/go.sum b/adapter/chiopenapi/go.sum index cc173f7..be33792 100644 --- a/adapter/chiopenapi/go.sum +++ b/adapter/chiopenapi/go.sum @@ -2,6 +2,7 @@ github.com/bool64/dev v0.2.39 h1:kP8DnMGlWXhGYJEZE/J0l/gVBdbuhoPGL+MJG4QbofE= github.com/bool64/dev v0.2.39/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-chi/chi/v5 v5.2.2 h1:CMwsvRVTbXVytCk1Wd72Zy1LAsAh9GxMmSNWLHCG618= @@ -12,9 +13,8 @@ github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJ github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/oaswrap/spec v0.3.6 h1:igKJvrrEYP/pK5I4TzEzYVcdbbr8eJ1gfALUXgZ/Oc8= github.com/oaswrap/spec v0.3.6/go.mod h1:e6cGQJcVCkQozwsw8T0ydSWEgQPA/dHFmQME4KawOYU= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= diff --git a/adapter/echoopenapi/examples/basic/go.mod b/adapter/echoopenapi/examples/basic/go.mod index 449bfd3..e750586 100644 --- a/adapter/echoopenapi/examples/basic/go.mod +++ b/adapter/echoopenapi/examples/basic/go.mod @@ -1,6 +1,6 @@ module github.com/oaswrap/spec/adapter/echoopenapi/examples/basic -go 1.23.0 +go 1.24.0 require ( github.com/labstack/echo/v4 v4.13.4 @@ -18,10 +18,10 @@ require ( github.com/swaggest/refl v1.4.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect - golang.org/x/crypto v0.38.0 // indirect - golang.org/x/net v0.40.0 // indirect - golang.org/x/sys v0.33.0 // indirect - golang.org/x/text v0.25.0 // indirect + golang.org/x/crypto v0.44.0 // indirect + golang.org/x/net v0.47.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/text v0.31.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/adapter/echoopenapi/examples/basic/go.sum b/adapter/echoopenapi/examples/basic/go.sum index 4b55d3a..e783a18 100644 --- a/adapter/echoopenapi/examples/basic/go.sum +++ b/adapter/echoopenapi/examples/basic/go.sum @@ -9,7 +9,9 @@ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/labstack/echo/v4 v4.13.4 h1:oTZZW+T3s9gAu5L8vmzihV7/lkXGZuITzTQkTEhcXEA= github.com/labstack/echo/v4 v4.13.4/go.mod h1:g63b33BZ5vZzcIUF8AtRH40DrTlXnx4UMC8rBdndmjQ= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= @@ -19,6 +21,7 @@ github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stg github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/oaswrap/spec v0.3.6 h1:igKJvrrEYP/pK5I4TzEzYVcdbbr8eJ1gfALUXgZ/Oc8= +github.com/oaswrap/spec v0.3.6/go.mod h1:e6cGQJcVCkQozwsw8T0ydSWEgQPA/dHFmQME4KawOYU= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= github.com/oaswrap/spec-ui v0.1.4/go.mod h1:D8EnD6zbYJ3q65wdltw6QHXfw+nut5XwSSA1xtlSEQQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -26,11 +29,13 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= github.com/swaggest/jsonschema-go v0.3.78 h1:5+YFQrLxOR8z6CHvgtZc42WRy/Q9zRQQ4HoAxlinlHw= github.com/swaggest/jsonschema-go v0.3.78/go.mod h1:4nniXBuE+FIGkOGuidjOINMH7OEqZK3HCSbfDuLRI0g= github.com/swaggest/openapi-go v0.2.60 h1:kglHH/WIfqAglfuWL4tu0LPakqNYySzklUWx06SjSKo= +github.com/swaggest/openapi-go v0.2.60/go.mod h1:jmFOuYdsWGtHU0BOuILlHZQJxLqHiAE6en+baE+QQUk= github.com/swaggest/refl v1.4.0 h1:CftOSdTqRqs100xpFOT/Rifss5xBV/CT0S/FN60Xe9k= github.com/swaggest/refl v1.4.0/go.mod h1:4uUVFVfPJ0NSX9FPwMPspeHos9wPFlCMGoPRllUbpvA= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= @@ -41,17 +46,18 @@ github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCO github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= -golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= -golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= -golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU= +golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= -golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/adapter/echoopenapi/go.mod b/adapter/echoopenapi/go.mod index e34adf8..f1aeda8 100644 --- a/adapter/echoopenapi/go.mod +++ b/adapter/echoopenapi/go.mod @@ -1,6 +1,6 @@ module github.com/oaswrap/spec/adapter/echoopenapi -go 1.23.0 +go 1.24.0 require ( github.com/labstack/echo/v4 v4.13.4 @@ -12,7 +12,7 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/kr/text v0.1.0 // indirect + github.com/kr/text v0.2.0 // indirect github.com/labstack/gommon v0.4.2 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect @@ -22,10 +22,10 @@ require ( github.com/swaggest/refl v1.4.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect - golang.org/x/crypto v0.38.0 // indirect - golang.org/x/net v0.40.0 // indirect - golang.org/x/sys v0.33.0 // indirect - golang.org/x/text v0.25.0 // indirect + golang.org/x/crypto v0.44.0 // indirect + golang.org/x/net v0.47.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/text v0.31.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/adapter/echoopenapi/go.sum b/adapter/echoopenapi/go.sum index 6a080c1..2348638 100644 --- a/adapter/echoopenapi/go.sum +++ b/adapter/echoopenapi/go.sum @@ -2,6 +2,7 @@ github.com/bool64/dev v0.2.39 h1:kP8DnMGlWXhGYJEZE/J0l/gVBdbuhoPGL+MJG4QbofE= github.com/bool64/dev v0.2.39/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -10,9 +11,8 @@ github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJ github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/labstack/echo/v4 v4.13.4 h1:oTZZW+T3s9gAu5L8vmzihV7/lkXGZuITzTQkTEhcXEA= github.com/labstack/echo/v4 v4.13.4/go.mod h1:g63b33BZ5vZzcIUF8AtRH40DrTlXnx4UMC8rBdndmjQ= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= @@ -47,15 +47,15 @@ github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCO github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= -golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= -golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= -golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU= +golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= -golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/adapter/fiberopenapi/README.md b/adapter/fiberopenapi/v2/README.md similarity index 85% rename from adapter/fiberopenapi/README.md rename to adapter/fiberopenapi/v2/README.md index 32f2b9e..b2a3286 100644 --- a/adapter/fiberopenapi/README.md +++ b/adapter/fiberopenapi/v2/README.md @@ -1,9 +1,11 @@ -# fiberopenapi +# fiberopenapi/v2 -[![Go Reference](https://pkg.go.dev/badge/github.com/oaswrap/spec/adapter/fiberopenapi.svg)](https://pkg.go.dev/github.com/oaswrap/spec/adapter/fiberopenapi) -[![Go Report Card](https://goreportcard.com/badge/github.com/oaswrap/spec/adapter/fiberopenapi)](https://goreportcard.com/report/github.com/oaswrap/spec/adapter/fiberopenapi) +[![Go Reference](https://pkg.go.dev/badge/github.com/oaswrap/spec/adapter/fiberopenapi/v2.svg)](https://pkg.go.dev/github.com/oaswrap/spec/adapter/fiberopenapi/v2) +[![Go Report Card](https://goreportcard.com/badge/github.com/oaswrap/spec/adapter/fiberopenapi/v2)](https://goreportcard.com/report/github.com/oaswrap/spec/adapter/fiberopenapi/v2) -A lightweight adapter for the [Fiber](https://github.com/gofiber/fiber) web framework that automatically generates OpenAPI 3.x specifications from your routes using [`oaswrap/spec`](https://github.com/oaswrap/spec). +A lightweight adapter for the [Fiber v2](https://github.com/gofiber/fiber) web framework that automatically generates OpenAPI 3.x specifications from your routes using [`oaswrap/spec`](https://github.com/oaswrap/spec). + +> **Note**: This adapter is for Fiber v2. If you're using Fiber v3, use [`fiberopenapi/v3`](https://github.com/oaswrap/spec/tree/main/adapter/fiberopenapi/v3) instead. ## Features @@ -17,7 +19,7 @@ A lightweight adapter for the [Fiber](https://github.com/gofiber/fiber) web fram ## Installation ```bash -go get github.com/oaswrap/spec/adapter/fiberopenapi +go get github.com/oaswrap/spec/adapter/fiberopenapi/v2 ``` ## Quick Start @@ -29,7 +31,7 @@ import ( "log" "github.com/gofiber/fiber/v2" - "github.com/oaswrap/spec/adapter/fiberopenapi" + fiberopenapi "github.com/oaswrap/spec/adapter/fiberopenapi/v2" "github.com/oaswrap/spec/option" ) @@ -165,7 +167,7 @@ For more struct tag options, see the [swaggest/openapi-go](https://github.com/sw ## Examples Check out complete examples in the main repository: -- [Basic](https://github.com/oaswrap/spec/tree/main/examples/adapter/fiberopenapi/basic) +- [Basic](https://github.com/oaswrap/spec/tree/main/adapter/fiberopenapi/v2/examples/basic) ## Best Practices @@ -179,7 +181,7 @@ Check out complete examples in the main repository: ## API Reference - **Spec**: [pkg.go.dev/github.com/oaswrap/spec](https://pkg.go.dev/github.com/oaswrap/spec) -- **Fiber Adapter**: [pkg.go.dev/github.com/oaswrap/spec/adapter/fiberopenapi](https://pkg.go.dev/github.com/oaswrap/spec/adapter/fiberopenapi) +- **Fiber v2 Adapter**: [pkg.go.dev/github.com/oaswrap/spec/adapter/fiberopenapi/v2](https://pkg.go.dev/github.com/oaswrap/spec/adapter/fiberopenapi/v2) - **Options**: [pkg.go.dev/github.com/oaswrap/spec/option](https://pkg.go.dev/github.com/oaswrap/spec/option) - **Spec UI**: [pkg.go.dev/github.com/oaswrap/spec-ui](https://pkg.go.dev/github.com/oaswrap/spec-ui) @@ -189,4 +191,4 @@ We welcome contributions! Please open issues and PRs at the main [oaswrap/spec]( ## License -[MIT](../../LICENSE) \ No newline at end of file +[MIT](../../../LICENSE) \ No newline at end of file diff --git a/adapter/fiberopenapi/examples/basic/go.mod b/adapter/fiberopenapi/v2/examples/basic/go.mod similarity index 56% rename from adapter/fiberopenapi/examples/basic/go.mod rename to adapter/fiberopenapi/v2/examples/basic/go.mod index 027a929..564c0a3 100644 --- a/adapter/fiberopenapi/examples/basic/go.mod +++ b/adapter/fiberopenapi/v2/examples/basic/go.mod @@ -1,32 +1,30 @@ -module github.com/oaswrap/spec/adapter/fiberopenapi/examples/basic +module github.com/oaswrap/spec/adapter/fiberopenapi/v2/examples/basic -go 1.23.0 - -toolchain go1.23.12 +go 1.24.0 require ( github.com/gofiber/fiber/v2 v2.52.9 github.com/oaswrap/spec v0.3.6 - github.com/oaswrap/spec/adapter/fiberopenapi v0.0.0 + github.com/oaswrap/spec/adapter/fiberopenapi/v2 v2.0.0-00010101000000-000000000000 ) require ( - github.com/andybalholm/brotli v1.1.0 // indirect + github.com/andybalholm/brotli v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/klauspost/compress v1.17.9 // indirect + github.com/klauspost/compress v1.18.1 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/oaswrap/spec-ui v0.1.4 // indirect + github.com/oaswrap/spec/adapter/fiberopenapi v0.3.6 // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/swaggest/jsonschema-go v0.3.78 // indirect github.com/swaggest/openapi-go v0.2.60 // indirect github.com/swaggest/refl v1.4.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.51.0 // indirect - github.com/valyala/tcplisten v1.0.0 // indirect - golang.org/x/sys v0.33.0 // indirect + github.com/valyala/fasthttp v1.68.0 // indirect + golang.org/x/sys v0.38.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) -replace github.com/oaswrap/spec/adapter/fiberopenapi => ../.. +replace github.com/oaswrap/spec/adapter/fiberopenapi/v2 => ../.. diff --git a/adapter/fiberopenapi/go.sum b/adapter/fiberopenapi/v2/examples/basic/go.sum similarity index 79% rename from adapter/fiberopenapi/go.sum rename to adapter/fiberopenapi/v2/examples/basic/go.sum index 32b9594..aa728f2 100644 --- a/adapter/fiberopenapi/go.sum +++ b/adapter/fiberopenapi/v2/examples/basic/go.sum @@ -1,5 +1,5 @@ -github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= -github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= +github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ= +github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= github.com/bool64/dev v0.2.39 h1:kP8DnMGlWXhGYJEZE/J0l/gVBdbuhoPGL+MJG4QbofE= github.com/bool64/dev v0.2.39/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= @@ -14,13 +14,12 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= +github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -31,6 +30,8 @@ github.com/oaswrap/spec v0.3.6 h1:igKJvrrEYP/pK5I4TzEzYVcdbbr8eJ1gfALUXgZ/Oc8= github.com/oaswrap/spec v0.3.6/go.mod h1:e6cGQJcVCkQozwsw8T0ydSWEgQPA/dHFmQME4KawOYU= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= github.com/oaswrap/spec-ui v0.1.4/go.mod h1:D8EnD6zbYJ3q65wdltw6QHXfw+nut5XwSSA1xtlSEQQ= +github.com/oaswrap/spec/adapter/fiberopenapi v0.3.6 h1:1PTjSnWjOWqFAI9WYbQkEfo4TIm22vBXU/9m0krtIJs= +github.com/oaswrap/spec/adapter/fiberopenapi v0.3.6/go.mod h1:Uhy3kFLeT+HP8i7efdQOIh/pkkM1LboAPO7erpoPkX4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= @@ -49,17 +50,17 @@ github.com/swaggest/refl v1.4.0 h1:CftOSdTqRqs100xpFOT/Rifss5xBV/CT0S/FN60Xe9k= github.com/swaggest/refl v1.4.0/go.mod h1:4uUVFVfPJ0NSX9FPwMPspeHos9wPFlCMGoPRllUbpvA= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA= -github.com/valyala/fasthttp v1.51.0/go.mod h1:oI2XroL+lI7vdXyYoQk03bXBThfFl2cVdIA3Xl7cH8g= -github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= -github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= +github.com/valyala/fasthttp v1.68.0 h1:v12Nx16iepr8r9ySOwqI+5RBJ/DqTxhOy1HrHoDFnok= +github.com/valyala/fasthttp v1.68.0/go.mod h1:5EXiRfYQAoiO/khu4oU9VISC/eVY6JqmSpPJoHCKsz4= +github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= +github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/adapter/fiberopenapi/examples/basic/main.go b/adapter/fiberopenapi/v2/examples/basic/main.go similarity index 97% rename from adapter/fiberopenapi/examples/basic/main.go rename to adapter/fiberopenapi/v2/examples/basic/main.go index 0800439..1102e8d 100644 --- a/adapter/fiberopenapi/examples/basic/main.go +++ b/adapter/fiberopenapi/v2/examples/basic/main.go @@ -4,7 +4,7 @@ import ( "log" "github.com/gofiber/fiber/v2" - "github.com/oaswrap/spec/adapter/fiberopenapi" + fiberopenapi "github.com/oaswrap/spec/adapter/fiberopenapi/v2" "github.com/oaswrap/spec/option" ) diff --git a/adapter/fiberopenapi/go.mod b/adapter/fiberopenapi/v2/go.mod similarity index 69% rename from adapter/fiberopenapi/go.mod rename to adapter/fiberopenapi/v2/go.mod index d776ded..85afd5f 100644 --- a/adapter/fiberopenapi/go.mod +++ b/adapter/fiberopenapi/v2/go.mod @@ -1,23 +1,22 @@ -module github.com/oaswrap/spec/adapter/fiberopenapi +module github.com/oaswrap/spec/adapter/fiberopenapi/v2 -go 1.23.0 - -toolchain go1.23.12 +go 1.24.0 require ( github.com/gofiber/fiber/v2 v2.52.9 github.com/oaswrap/spec v0.3.6 github.com/oaswrap/spec-ui v0.1.4 + github.com/oaswrap/spec/adapter/fiberopenapi v0.3.6 github.com/stretchr/testify v1.11.1 ) require ( - github.com/andybalholm/brotli v1.1.0 // indirect + github.com/andybalholm/brotli v1.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.7.0 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/klauspost/compress v1.17.9 // indirect - github.com/kr/text v0.1.0 // indirect + github.com/klauspost/compress v1.18.1 // indirect + github.com/kr/text v0.2.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect @@ -27,9 +26,8 @@ require ( github.com/swaggest/openapi-go v0.2.60 // indirect github.com/swaggest/refl v1.4.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.51.0 // indirect - github.com/valyala/tcplisten v1.0.0 // indirect - golang.org/x/sys v0.33.0 // indirect + github.com/valyala/fasthttp v1.68.0 // indirect + golang.org/x/sys v0.38.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/adapter/fiberopenapi/examples/basic/go.sum b/adapter/fiberopenapi/v2/go.sum similarity index 69% rename from adapter/fiberopenapi/examples/basic/go.sum rename to adapter/fiberopenapi/v2/go.sum index bf16991..41b36c1 100644 --- a/adapter/fiberopenapi/examples/basic/go.sum +++ b/adapter/fiberopenapi/v2/go.sum @@ -1,9 +1,10 @@ -github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= -github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= +github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ= +github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= github.com/bool64/dev v0.2.39 h1:kP8DnMGlWXhGYJEZE/J0l/gVBdbuhoPGL+MJG4QbofE= github.com/bool64/dev v0.2.39/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/gofiber/fiber/v2 v2.52.9 h1:YjKl5DOiyP3j0mO61u3NTmK7or8GzzWzCFzkboyP5cw= @@ -14,18 +15,24 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= +github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/oaswrap/spec v0.3.6 h1:igKJvrrEYP/pK5I4TzEzYVcdbbr8eJ1gfALUXgZ/Oc8= +github.com/oaswrap/spec v0.3.6/go.mod h1:e6cGQJcVCkQozwsw8T0ydSWEgQPA/dHFmQME4KawOYU= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= github.com/oaswrap/spec-ui v0.1.4/go.mod h1:D8EnD6zbYJ3q65wdltw6QHXfw+nut5XwSSA1xtlSEQQ= +github.com/oaswrap/spec/adapter/fiberopenapi v0.3.6 h1:1PTjSnWjOWqFAI9WYbQkEfo4TIm22vBXU/9m0krtIJs= +github.com/oaswrap/spec/adapter/fiberopenapi v0.3.6/go.mod h1:Uhy3kFLeT+HP8i7efdQOIh/pkkM1LboAPO7erpoPkX4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= @@ -33,27 +40,31 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= github.com/swaggest/jsonschema-go v0.3.78 h1:5+YFQrLxOR8z6CHvgtZc42WRy/Q9zRQQ4HoAxlinlHw= github.com/swaggest/jsonschema-go v0.3.78/go.mod h1:4nniXBuE+FIGkOGuidjOINMH7OEqZK3HCSbfDuLRI0g= github.com/swaggest/openapi-go v0.2.60 h1:kglHH/WIfqAglfuWL4tu0LPakqNYySzklUWx06SjSKo= +github.com/swaggest/openapi-go v0.2.60/go.mod h1:jmFOuYdsWGtHU0BOuILlHZQJxLqHiAE6en+baE+QQUk= github.com/swaggest/refl v1.4.0 h1:CftOSdTqRqs100xpFOT/Rifss5xBV/CT0S/FN60Xe9k= github.com/swaggest/refl v1.4.0/go.mod h1:4uUVFVfPJ0NSX9FPwMPspeHos9wPFlCMGoPRllUbpvA= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA= -github.com/valyala/fasthttp v1.51.0/go.mod h1:oI2XroL+lI7vdXyYoQk03bXBThfFl2cVdIA3Xl7cH8g= -github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= -github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= +github.com/valyala/fasthttp v1.68.0 h1:v12Nx16iepr8r9ySOwqI+5RBJ/DqTxhOy1HrHoDFnok= +github.com/valyala/fasthttp v1.68.0/go.mod h1:5EXiRfYQAoiO/khu4oU9VISC/eVY6JqmSpPJoHCKsz4= +github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= +github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/adapter/fiberopenapi/internal/constant/constant.go b/adapter/fiberopenapi/v2/internal/constant/constant.go similarity index 100% rename from adapter/fiberopenapi/internal/constant/constant.go rename to adapter/fiberopenapi/v2/internal/constant/constant.go diff --git a/adapter/fiberopenapi/route.go b/adapter/fiberopenapi/v2/route.go similarity index 100% rename from adapter/fiberopenapi/route.go rename to adapter/fiberopenapi/v2/route.go diff --git a/adapter/fiberopenapi/router.go b/adapter/fiberopenapi/v2/router.go similarity index 100% rename from adapter/fiberopenapi/router.go rename to adapter/fiberopenapi/v2/router.go diff --git a/adapter/fiberopenapi/router_test.go b/adapter/fiberopenapi/v2/router_test.go similarity index 99% rename from adapter/fiberopenapi/router_test.go rename to adapter/fiberopenapi/v2/router_test.go index 1791218..01c6bd1 100644 --- a/adapter/fiberopenapi/router_test.go +++ b/adapter/fiberopenapi/v2/router_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/gofiber/fiber/v2" - "github.com/oaswrap/spec/adapter/fiberopenapi" + fiberopenapi "github.com/oaswrap/spec/adapter/fiberopenapi/v2" "github.com/oaswrap/spec/openapi" "github.com/oaswrap/spec/option" "github.com/oaswrap/spec/pkg/dto" diff --git a/adapter/fiberopenapi/testdata/petstore.yaml b/adapter/fiberopenapi/v2/testdata/petstore.yaml similarity index 100% rename from adapter/fiberopenapi/testdata/petstore.yaml rename to adapter/fiberopenapi/v2/testdata/petstore.yaml diff --git a/adapter/fiberopenapi/types.go b/adapter/fiberopenapi/v2/types.go similarity index 100% rename from adapter/fiberopenapi/types.go rename to adapter/fiberopenapi/v2/types.go diff --git a/adapter/fiberopenapi/v3/README.md b/adapter/fiberopenapi/v3/README.md new file mode 100644 index 0000000..23e9dab --- /dev/null +++ b/adapter/fiberopenapi/v3/README.md @@ -0,0 +1,220 @@ +# fiberopenapi/v3 + +[![Go Reference](https://pkg.go.dev/badge/github.com/oaswrap/spec/adapter/fiberopenapi/v3.svg)](https://pkg.go.dev/github.com/oaswrap/spec/adapter/fiberopenapi/v3) +[![Go Report Card](https://goreportcard.com/badge/github.com/oaswrap/spec/adapter/fiberopenapi/v3)](https://goreportcard.com/report/github.com/oaswrap/spec/adapter/fiberopenapi/v3) + +A lightweight adapter for the [Fiber v3](https://github.com/gofiber/fiber) web framework that automatically generates OpenAPI 3.x specifications from your routes using [`oaswrap/spec`](https://github.com/oaswrap/spec). + +> **Note**: This adapter is for Fiber v3. If you're using Fiber v2, use [`fiberopenapi`](https://github.com/oaswrap/spec/tree/main/adapter/fiberopenapi) instead. + +## Features + +- **⚡ Seamless Integration** — Works with your existing Fiber v3 routes and handlers +- **📝 Automatic Documentation** — Generate OpenAPI specs from route definitions and struct tags +- **🎯 Type Safety** — Full Go type safety for OpenAPI configuration +- **🔧 Multiple UI Options** — Swagger UI, Stoplight Elements, ReDoc, Scalar or RapiDoc served automatically at `/docs` +- **📄 YAML Export** — OpenAPI spec available at `/docs/openapi.yaml` +- **🚀 Zero Overhead** — Minimal performance impact on your API + +## Installation + +```bash +go get github.com/oaswrap/spec/adapter/fiberopenapi/v3 +``` + +## Quick Start + +```go +package main + +import ( + "log" + + "github.com/gofiber/fiber/v3" + fiberopenapi "github.com/oaswrap/spec/adapter/fiberopenapi/v3" + "github.com/oaswrap/spec/option" +) + +func main() { + app := fiber.New() + + // Create a new OpenAPI router + r := fiberopenapi.NewRouter(app, + option.WithTitle("My API"), + option.WithVersion("1.0.0"), + option.WithSecurity("bearerAuth", option.SecurityHTTPBearer("Bearer")), + ) + // Add routes + v1 := r.Group("/api/v1") + v1.Post("/login", LoginHandler).With( + option.Summary("User login"), + option.Request(new(LoginRequest)), + option.Response(200, new(LoginResponse)), + ) + auth := v1.Group("/", AuthMiddleware).With( + option.GroupSecurity("bearerAuth"), + ) + auth.Get("/users/:id", GetUserHandler).With( + option.Summary("Get user by ID"), + option.Request(new(GetUserRequest)), + option.Response(200, new(User)), + ) + + log.Printf("🚀 OpenAPI docs available at: %s", "http://localhost:3000/docs") + + if err := app.Listen(":3000"); err != nil { + log.Fatal(err) + } +} + +type LoginRequest struct { + Username string `json:"username" required:"true"` + Password string `json:"password" required:"true"` +} + +type LoginResponse struct { + Token string `json:"token"` +} + +type GetUserRequest struct { + ID string `params:"id" required:"true"` +} + +type User struct { + ID string `json:"id"` + Name string `json:"name"` +} + +func AuthMiddleware(c fiber.Ctx) error { + authHeader := c.Get("Authorization") + if authHeader != "" && authHeader == "Bearer example-token" { + return c.Next() + } + return c.Status(401).JSON(map[string]string{"error": "Unauthorized"}) +} + +func LoginHandler(c fiber.Ctx) error { + var req LoginRequest + if err := c.Bind().Body(&req); err != nil { + return c.Status(400).JSON(map[string]string{"error": "Invalid request"}) + } + // Simulate login logic + return c.Status(200).JSON(LoginResponse{Token: "example-token"}) +} + +func GetUserHandler(c fiber.Ctx) error { + var req GetUserRequest + if err := c.Bind().URI(&req); err != nil { + return c.Status(400).JSON(map[string]string{"error": "Invalid request"}) + } + // Simulate fetching user by ID + user := User{ID: req.ID, Name: "John Doe"} + return c.Status(200).JSON(user) +} +``` + +## Documentation Features + +### Built-in Endpoints +When you create a fiberopenapi router, the following endpoints are automatically available: + +- **`/docs`** — Interactive UI documentation +- **`/docs/openapi.yaml`** — Raw OpenAPI specification in YAML format + +If you want to disable the built-in UI, you can do so by passing `option.WithDisableDocs()` when creating the router: + +```go +r := fiberopenapi.NewRouter(app, + option.WithTitle("My API"), + option.WithVersion("1.0.0"), + option.WithDisableDocs(), +) +``` + +### Supported Documentation UIs +Choose from multiple UI options, powered by [`oaswrap/spec-ui`](https://github.com/oaswrap/spec-ui): + +- **Stoplight Elements** — Modern, clean design (default) +- **Swagger UI** — Classic interface with try-it functionality +- **ReDoc** — Three-panel responsive layout +- **Scalar** — Beautiful and fast interface +- **RapiDoc** — Highly customizable + +```go +r := fiberopenapi.NewRouter(app, + option.WithTitle("My API"), + option.WithVersion("1.0.0"), + option.WithScalar(), // Use Scalar as the documentation UI +) +``` + +### Rich Schema Documentation +Use struct tags to generate detailed OpenAPI schemas. **Note: These tags are used only for OpenAPI spec generation and documentation - they do not perform actual request validation.** + +```go +type CreateProductRequest struct { + Name string `json:"name" required:"true" minLength:"1" maxLength:"100"` + Description string `json:"description" maxLength:"500"` + Price float64 `json:"price" required:"true" minimum:"0" maximum:"999999.99"` + Category string `json:"category" required:"true" enum:"electronics,books,clothing"` + Tags []string `json:"tags" maxItems:"10"` + InStock bool `json:"in_stock" default:"true"` +} +``` + +For more struct tag options, see the [swaggest/openapi-go](https://github.com/swaggest/openapi-go?tab=readme-ov-file#features). + +## Fiber v3 Specifics + +This adapter is built for Fiber v3 and takes advantage of its new features: + +### Binding API +Fiber v3 introduces a new binding API. Use `c.Bind()` for request parsing: + +```go +func Handler(c fiber.Ctx) error { + var req Request + if err := c.Bind().Body(&req); err != nil { + return err + } + // ... +} +``` + +### Path Parameters +Path parameters use the `params` tag in Fiber v3: + +```go +type GetUserRequest struct { + ID string `params:"id" required:"true"` +} +``` + +## Examples + +Check out complete examples in the main repository: +- [Basic](https://github.com/oaswrap/spec/tree/main/adapter/fiberopenapi/v3/examples/basic) + +## Best Practices + +1. **Organize with Tags** — Group related operations using `option.Tags()` +2. **Document Everything** — Use `option.Summary()` and `option.Description()` for all routes +3. **Define Error Responses** — Include common error responses (400, 401, 404, 500) +4. **Use Validation Tags** — Leverage struct tags for request validation documentation +5. **Security First** — Define and apply appropriate security schemes +6. **Version Your API** — Use route groups for API versioning (`/api/v1`, `/api/v2`) + +## API Reference + +- **Spec**: [pkg.go.dev/github.com/oaswrap/spec](https://pkg.go.dev/github.com/oaswrap/spec) +- **Fiber v3 Adapter**: [pkg.go.dev/github.com/oaswrap/spec/adapter/fiberopenapi/v3](https://pkg.go.dev/github.com/oaswrap/spec/adapter/fiberopenapi/v3) +- **Options**: [pkg.go.dev/github.com/oaswrap/spec/option](https://pkg.go.dev/github.com/oaswrap/spec/option) +- **Spec UI**: [pkg.go.dev/github.com/oaswrap/spec-ui](https://pkg.go.dev/github.com/oaswrap/spec-ui) + +## Contributing + +We welcome contributions! Please open issues and PRs at the main [oaswrap/spec](https://github.com/oaswrap/spec) repository. + +## License + +[MIT](../../LICENSE) diff --git a/adapter/fiberopenapi/v3/examples/basic/go.mod b/adapter/fiberopenapi/v3/examples/basic/go.mod new file mode 100644 index 0000000..4e01556 --- /dev/null +++ b/adapter/fiberopenapi/v3/examples/basic/go.mod @@ -0,0 +1,34 @@ +module github.com/oaswrap/spec/adapter/fiberopenapi/v3/examples/basic + +go 1.25.0 + +replace github.com/oaswrap/spec/adapter/fiberopenapi/v3 => ../.. + +require ( + github.com/gofiber/fiber/v3 v3.0.0-rc.3 + github.com/oaswrap/spec v0.3.6 + github.com/oaswrap/spec/adapter/fiberopenapi/v3 v3.0.0-00010101000000-000000000000 +) + +require ( + github.com/andybalholm/brotli v1.2.0 // indirect + github.com/gofiber/schema v1.6.0 // indirect + github.com/gofiber/utils/v2 v2.0.0-rc.2 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/klauspost/compress v1.18.1 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/oaswrap/spec-ui v0.1.4 // indirect + github.com/philhofer/fwd v1.2.0 // indirect + github.com/swaggest/jsonschema-go v0.3.78 // indirect + github.com/swaggest/openapi-go v0.2.60 // indirect + github.com/swaggest/refl v1.4.0 // indirect + github.com/tinylib/msgp v1.5.0 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasthttp v1.68.0 // indirect + golang.org/x/crypto v0.44.0 // indirect + golang.org/x/net v0.47.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/text v0.31.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect +) diff --git a/adapter/fiberopenapi/v3/examples/basic/go.sum b/adapter/fiberopenapi/v3/examples/basic/go.sum new file mode 100644 index 0000000..2f5070a --- /dev/null +++ b/adapter/fiberopenapi/v3/examples/basic/go.sum @@ -0,0 +1,84 @@ +github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ= +github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= +github.com/bool64/dev v0.2.39 h1:kP8DnMGlWXhGYJEZE/J0l/gVBdbuhoPGL+MJG4QbofE= +github.com/bool64/dev v0.2.39/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= +github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= +github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM= +github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= +github.com/gofiber/fiber/v3 v3.0.0-rc.3 h1:h0KXuRHbivSslIpoHD1R/XjUsjcGwt+2vK0avFiYonA= +github.com/gofiber/fiber/v3 v3.0.0-rc.3/go.mod h1:LNBPuS/rGoUFlOyy03fXsWAeWfdGoT1QytwjRVNSVWo= +github.com/gofiber/schema v1.6.0 h1:rAgVDFwhndtC+hgV7Vu5ItQCn7eC2mBA4Eu1/ZTiEYY= +github.com/gofiber/schema v1.6.0/go.mod h1:WNZWpQx8LlPSK7ZaX0OqOh+nQo/eW2OevsXs1VZfs/s= +github.com/gofiber/utils/v2 v2.0.0-rc.2 h1:NvJTf7yMafTq16lUOJv70nr+HIOLNQcvGme/X+ftbW8= +github.com/gofiber/utils/v2 v2.0.0-rc.2/go.mod h1:gXins5o7up+BQFiubmO8aUJc/+Mhd7EKXIiAK5GBomI= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= +github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= +github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= +github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/oaswrap/spec v0.3.6 h1:igKJvrrEYP/pK5I4TzEzYVcdbbr8eJ1gfALUXgZ/Oc8= +github.com/oaswrap/spec v0.3.6/go.mod h1:e6cGQJcVCkQozwsw8T0ydSWEgQPA/dHFmQME4KawOYU= +github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= +github.com/oaswrap/spec-ui v0.1.4/go.mod h1:D8EnD6zbYJ3q65wdltw6QHXfw+nut5XwSSA1xtlSEQQ= +github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM= +github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/shamaton/msgpack/v2 v2.4.0 h1:O5Z08MRmbo0lA9o2xnQ4TXx6teJbPqEurqcCOQ8Oi/4= +github.com/shamaton/msgpack/v2 v2.4.0/go.mod h1:6khjYnkx73f7VQU7wjcFS9DFjs+59naVWJv1TB7qdOI= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= +github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= +github.com/swaggest/jsonschema-go v0.3.78 h1:5+YFQrLxOR8z6CHvgtZc42WRy/Q9zRQQ4HoAxlinlHw= +github.com/swaggest/jsonschema-go v0.3.78/go.mod h1:4nniXBuE+FIGkOGuidjOINMH7OEqZK3HCSbfDuLRI0g= +github.com/swaggest/openapi-go v0.2.60 h1:kglHH/WIfqAglfuWL4tu0LPakqNYySzklUWx06SjSKo= +github.com/swaggest/openapi-go v0.2.60/go.mod h1:jmFOuYdsWGtHU0BOuILlHZQJxLqHiAE6en+baE+QQUk= +github.com/swaggest/refl v1.4.0 h1:CftOSdTqRqs100xpFOT/Rifss5xBV/CT0S/FN60Xe9k= +github.com/swaggest/refl v1.4.0/go.mod h1:4uUVFVfPJ0NSX9FPwMPspeHos9wPFlCMGoPRllUbpvA= +github.com/tinylib/msgp v1.5.0 h1:GWnqAE54wmnlFazjq2+vgr736Akg58iiHImh+kPY2pc= +github.com/tinylib/msgp v1.5.0/go.mod h1:cvjFkb4RiC8qSBOPMGPSzSAx47nAsfhLVTCZZNuHv5o= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasthttp v1.68.0 h1:v12Nx16iepr8r9ySOwqI+5RBJ/DqTxhOy1HrHoDFnok= +github.com/valyala/fasthttp v1.68.0/go.mod h1:5EXiRfYQAoiO/khu4oU9VISC/eVY6JqmSpPJoHCKsz4= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= +github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= +github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= +github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= +golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU= +golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/adapter/fiberopenapi/v3/examples/basic/main.go b/adapter/fiberopenapi/v3/examples/basic/main.go new file mode 100644 index 0000000..1d43a30 --- /dev/null +++ b/adapter/fiberopenapi/v3/examples/basic/main.go @@ -0,0 +1,88 @@ +package main + +import ( + "log" + + "github.com/gofiber/fiber/v3" + "github.com/gofiber/fiber/v3/middleware/static" + fiberopenapi "github.com/oaswrap/spec/adapter/fiberopenapi/v3" + "github.com/oaswrap/spec/option" +) + +func main() { + app := fiber.New() + + // Create a new OpenAPI router + r := fiberopenapi.NewRouter(app, + option.WithTitle("My API"), + option.WithVersion("1.0.0"), + option.WithSecurity("bearerAuth", option.SecurityHTTPBearer("Bearer")), + ) + r.Get("/static/*", static.New("../../testdata")) + // Add routes + v1 := r.Group("/api/v1") + v1.Post("/login", LoginHandler).With( + option.Summary("User login"), + option.Request(new(LoginRequest)), + option.Response(fiber.StatusOK, new(LoginResponse)), + ) + auth := v1.Group("/", AuthMiddleware).With( + option.GroupSecurity("bearerAuth"), + ) + auth.Get("/users/:id", GetUserHandler).With( + option.Summary("Get user by ID"), + option.Request(new(GetUserRequest)), + option.Response(fiber.StatusOK, new(User)), + ) + + log.Printf("🚀 OpenAPI docs available at: %s", "http://localhost:3000/docs") + + if err := app.Listen(":3000"); err != nil { + log.Fatal(err) + } +} + +type LoginRequest struct { + Username string `json:"username" required:"true"` + Password string `json:"password" required:"true"` +} + +type LoginResponse struct { + Token string `json:"token"` +} + +type GetUserRequest struct { + ID string `uri:"id" required:"true"` +} + +type User struct { + ID string `json:"id"` + Name string `json:"name"` +} + +func AuthMiddleware(c fiber.Ctx) error { + authHeader := c.Get("Authorization") + if authHeader != "" && authHeader == "Bearer example-token" { + return c.Next() + } + return c.Status(fiber.StatusUnauthorized).JSON(map[string]string{"error": "Unauthorized"}) +} + +func LoginHandler(c fiber.Ctx) error { + var req LoginRequest + if err := c.Bind().JSON(&req); err != nil { + return c.Status(fiber.StatusBadRequest).JSON(map[string]string{"error": "Invalid request"}) + } + // Simulate login logic + return c.Status(fiber.StatusOK).JSON(LoginResponse{Token: "example-token"}) +} + +func GetUserHandler(c fiber.Ctx) error { + var req GetUserRequest + if err := c.Bind().URI(&req); err != nil { + return c.Status(fiber.StatusBadRequest).JSON(map[string]string{"error": "Invalid request"}) + } + // Simulate fetching user by ID + user := User{ID: req.ID, Name: "John Doe"} + return c.Status(fiber.StatusOK).JSON(user) +} diff --git a/adapter/fiberopenapi/v3/go.mod b/adapter/fiberopenapi/v3/go.mod new file mode 100644 index 0000000..511c67c --- /dev/null +++ b/adapter/fiberopenapi/v3/go.mod @@ -0,0 +1,37 @@ +module github.com/oaswrap/spec/adapter/fiberopenapi/v3 + +go 1.25.0 + +require ( + github.com/gofiber/fiber/v3 v3.0.0-rc.3 + github.com/oaswrap/spec v0.3.6 + github.com/oaswrap/spec-ui v0.1.4 + github.com/stretchr/testify v1.11.1 +) + +require ( + github.com/andybalholm/brotli v1.2.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/gofiber/schema v1.6.0 // indirect + github.com/gofiber/utils/v2 v2.0.0-rc.2 // indirect + github.com/google/go-cmp v0.7.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/klauspost/compress v1.18.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/philhofer/fwd v1.2.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/swaggest/jsonschema-go v0.3.78 // indirect + github.com/swaggest/openapi-go v0.2.60 // indirect + github.com/swaggest/refl v1.4.0 // indirect + github.com/tinylib/msgp v1.5.0 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasthttp v1.68.0 // indirect + golang.org/x/crypto v0.44.0 // indirect + golang.org/x/net v0.47.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/text v0.31.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/adapter/fiberopenapi/v3/go.sum b/adapter/fiberopenapi/v3/go.sum new file mode 100644 index 0000000..59893a2 --- /dev/null +++ b/adapter/fiberopenapi/v3/go.sum @@ -0,0 +1,85 @@ +github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ= +github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= +github.com/bool64/dev v0.2.39 h1:kP8DnMGlWXhGYJEZE/J0l/gVBdbuhoPGL+MJG4QbofE= +github.com/bool64/dev v0.2.39/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= +github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= +github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM= +github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= +github.com/gofiber/fiber/v3 v3.0.0-rc.3 h1:h0KXuRHbivSslIpoHD1R/XjUsjcGwt+2vK0avFiYonA= +github.com/gofiber/fiber/v3 v3.0.0-rc.3/go.mod h1:LNBPuS/rGoUFlOyy03fXsWAeWfdGoT1QytwjRVNSVWo= +github.com/gofiber/schema v1.6.0 h1:rAgVDFwhndtC+hgV7Vu5ItQCn7eC2mBA4Eu1/ZTiEYY= +github.com/gofiber/schema v1.6.0/go.mod h1:WNZWpQx8LlPSK7ZaX0OqOh+nQo/eW2OevsXs1VZfs/s= +github.com/gofiber/utils/v2 v2.0.0-rc.2 h1:NvJTf7yMafTq16lUOJv70nr+HIOLNQcvGme/X+ftbW8= +github.com/gofiber/utils/v2 v2.0.0-rc.2/go.mod h1:gXins5o7up+BQFiubmO8aUJc/+Mhd7EKXIiAK5GBomI= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= +github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= +github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= +github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/oaswrap/spec v0.3.6 h1:igKJvrrEYP/pK5I4TzEzYVcdbbr8eJ1gfALUXgZ/Oc8= +github.com/oaswrap/spec v0.3.6/go.mod h1:e6cGQJcVCkQozwsw8T0ydSWEgQPA/dHFmQME4KawOYU= +github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= +github.com/oaswrap/spec-ui v0.1.4/go.mod h1:D8EnD6zbYJ3q65wdltw6QHXfw+nut5XwSSA1xtlSEQQ= +github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM= +github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= +github.com/shamaton/msgpack/v2 v2.4.0 h1:O5Z08MRmbo0lA9o2xnQ4TXx6teJbPqEurqcCOQ8Oi/4= +github.com/shamaton/msgpack/v2 v2.4.0/go.mod h1:6khjYnkx73f7VQU7wjcFS9DFjs+59naVWJv1TB7qdOI= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= +github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= +github.com/swaggest/jsonschema-go v0.3.78 h1:5+YFQrLxOR8z6CHvgtZc42WRy/Q9zRQQ4HoAxlinlHw= +github.com/swaggest/jsonschema-go v0.3.78/go.mod h1:4nniXBuE+FIGkOGuidjOINMH7OEqZK3HCSbfDuLRI0g= +github.com/swaggest/openapi-go v0.2.60 h1:kglHH/WIfqAglfuWL4tu0LPakqNYySzklUWx06SjSKo= +github.com/swaggest/openapi-go v0.2.60/go.mod h1:jmFOuYdsWGtHU0BOuILlHZQJxLqHiAE6en+baE+QQUk= +github.com/swaggest/refl v1.4.0 h1:CftOSdTqRqs100xpFOT/Rifss5xBV/CT0S/FN60Xe9k= +github.com/swaggest/refl v1.4.0/go.mod h1:4uUVFVfPJ0NSX9FPwMPspeHos9wPFlCMGoPRllUbpvA= +github.com/tinylib/msgp v1.5.0 h1:GWnqAE54wmnlFazjq2+vgr736Akg58iiHImh+kPY2pc= +github.com/tinylib/msgp v1.5.0/go.mod h1:cvjFkb4RiC8qSBOPMGPSzSAx47nAsfhLVTCZZNuHv5o= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasthttp v1.68.0 h1:v12Nx16iepr8r9ySOwqI+5RBJ/DqTxhOy1HrHoDFnok= +github.com/valyala/fasthttp v1.68.0/go.mod h1:5EXiRfYQAoiO/khu4oU9VISC/eVY6JqmSpPJoHCKsz4= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= +github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= +github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= +github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= +golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU= +golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/adapter/fiberopenapi/v3/internal/constant/constant.go b/adapter/fiberopenapi/v3/internal/constant/constant.go new file mode 100644 index 0000000..859c24a --- /dev/null +++ b/adapter/fiberopenapi/v3/internal/constant/constant.go @@ -0,0 +1,7 @@ +package constant + +const ( + DefaultTitle = "Fiber v3 OpenAPI" + DefaultDescription = "OpenAPI documentation for Fiber v3 applications" + DefaultVersion = "1.0.0" +) diff --git a/adapter/fiberopenapi/v3/route.go b/adapter/fiberopenapi/v3/route.go new file mode 100644 index 0000000..842e982 --- /dev/null +++ b/adapter/fiberopenapi/v3/route.go @@ -0,0 +1,37 @@ +package fiberopenapi + +import ( + "github.com/gofiber/fiber/v3" + "github.com/oaswrap/spec" + "github.com/oaswrap/spec/option" +) + +// Route represents a single route in the OpenAPI specification. +type Route interface { + // Name sets the name for the route. + Name(name string) Route + // With applies the given options to the route. + With(opts ...option.OperationOption) Route +} + +type route struct { + fr fiber.Router + sr spec.Route +} + +// Name sets the name for the route. +func (r *route) Name(name string) Route { + r.fr.Name(name) + + return r +} + +// With applies the given options to the route. +func (r *route) With(opts ...option.OperationOption) Route { + if r.sr == nil { + return r + } + r.sr.With(opts...) + + return r +} diff --git a/adapter/fiberopenapi/v3/router.go b/adapter/fiberopenapi/v3/router.go new file mode 100644 index 0000000..c6aa27e --- /dev/null +++ b/adapter/fiberopenapi/v3/router.go @@ -0,0 +1,176 @@ +package fiberopenapi + +import ( + "github.com/gofiber/fiber/v3" + "github.com/gofiber/fiber/v3/middleware/adaptor" + "github.com/oaswrap/spec" + specui "github.com/oaswrap/spec-ui" + "github.com/oaswrap/spec/adapter/fiberopenapi/v3/internal/constant" + "github.com/oaswrap/spec/openapi" + "github.com/oaswrap/spec/option" + "github.com/oaswrap/spec/pkg/mapper" + "github.com/oaswrap/spec/pkg/parser" +) + +// NewGenerator creates a new OpenAPI generator with the specified Fiber router and options. +// +// It initializes the OpenAPI router and sets up the necessary routes for OpenAPI documentation. +func NewGenerator(r fiber.Router, opts ...option.OpenAPIOption) Generator { + return NewRouter(r, opts...) +} + +// NewRouter creates a new OpenAPI router with the specified Fiber router and options. +// +// It initializes the OpenAPI generator and sets up the necessary routes for OpenAPI documentation. +func NewRouter(r fiber.Router, opts ...option.OpenAPIOption) Generator { + defaultOpts := []option.OpenAPIOption{ + option.WithTitle(constant.DefaultTitle), + option.WithDescription(constant.DefaultDescription), + option.WithVersion(constant.DefaultVersion), + option.WithPathParser(parser.NewColonParamParser()), + option.WithStoplightElements(), + option.WithCacheAge(0), + option.WithReflectorConfig( + option.ParameterTagMapping(openapi.ParameterInPath, "params"), + ), + } + opts = append(defaultOpts, opts...) + gen := spec.NewGenerator(opts...) + cfg := gen.Config() + + rr := &router{ + fiberRouter: r, + specRouter: gen, + gen: gen, + } + + // If docs are disabled, return the router without adding docs routes. + if cfg.DisableDocs { + return rr + } + + handler := specui.NewHandler(mapper.SpecUIOpts(gen)...) + + r.Get(cfg.DocsPath, adaptor.HTTPHandler(handler.Docs())) + r.Get(cfg.SpecPath, adaptor.HTTPHandler(handler.Spec())) + + return rr +} + +type router struct { + fiberRouter fiber.Router + specRouter spec.Router + gen spec.Generator +} + +func (r *router) Use(args ...any) Router { + r.fiberRouter.Use(args...) + return r +} + +func (r *router) Get(path string, handler fiber.Handler, handlers ...any) Route { + return r.Add([]string{fiber.MethodGet}, path, handler, handlers...) +} + +func (r *router) Head(path string, handler fiber.Handler, handlers ...any) Route { + return r.Add([]string{fiber.MethodHead}, path, handler, handlers...) +} + +func (r *router) Post(path string, handler fiber.Handler, handlers ...any) Route { + return r.Add([]string{fiber.MethodPost}, path, handler, handlers...) +} + +func (r *router) Put(path string, handler fiber.Handler, handlers ...any) Route { + return r.Add([]string{fiber.MethodPut}, path, handler, handlers...) +} + +func (r *router) Patch(path string, handler fiber.Handler, handlers ...any) Route { + return r.Add([]string{fiber.MethodPatch}, path, handler, handlers...) +} + +func (r *router) Delete(path string, handler fiber.Handler, handlers ...any) Route { + return r.Add([]string{fiber.MethodDelete}, path, handler, handlers...) +} + +func (r *router) Connect(path string, handler fiber.Handler, handlers ...any) Route { + return r.Add([]string{fiber.MethodConnect}, path, handler, handlers...) +} + +func (r *router) Options(path string, handler fiber.Handler, handlers ...any) Route { + return r.Add([]string{fiber.MethodOptions}, path, handler, handlers...) +} + +func (r *router) Trace(path string, handler fiber.Handler, handlers ...any) Route { + return r.Add([]string{fiber.MethodTrace}, path, handler, handlers...) +} + +func (r *router) Add(methods []string, path string, handler fiber.Handler, handlers ...any) Route { + // If handler is nil, provide a default handler that returns 501 Not Implemented + if handler == nil { + handler = func(c fiber.Ctx) error { + return c.SendStatus(fiber.StatusNotImplemented) + } + } + + fr := r.fiberRouter.Add(methods, path, handler, handlers...) + route := &route{fr: fr} + + for _, m := range methods { + if m == fiber.MethodConnect { + // CONNECT method is not supported by OpenAPI, so we skip it + return route + } + route.sr = r.specRouter.Add(m, path) + } + + return route +} + +func (r *router) Group(prefix string, handlers ...any) Router { + rr := r.fiberRouter.Group(prefix, handlers...) + sr := r.specRouter.Group(prefix) + + return &router{ + fiberRouter: rr, + specRouter: sr, + } +} + +func (r *router) Route(prefix string, fn func(router Router), opts ...option.GroupOption) Router { + fr := r.fiberRouter.Group(prefix) + sr := r.specRouter.Group(prefix, opts...) + + subRouter := &router{ + fiberRouter: fr, + specRouter: sr, + } + + fn(subRouter) + + return subRouter +} + +func (r *router) With(opts ...option.GroupOption) Router { + r.specRouter.With(opts...) + return r +} + +func (r *router) Validate() error { + return r.gen.Validate() +} + +func (r *router) GenerateSchema(formats ...string) ([]byte, error) { + return r.gen.GenerateSchema(formats...) +} + +func (r *router) MarshalYAML() ([]byte, error) { + return r.gen.MarshalYAML() +} + +func (r *router) MarshalJSON() ([]byte, error) { + return r.gen.MarshalJSON() +} + +func (r *router) WriteSchemaTo(path string) error { + return r.gen.WriteSchemaTo(path) +} diff --git a/adapter/fiberopenapi/v3/router_test.go b/adapter/fiberopenapi/v3/router_test.go new file mode 100644 index 0000000..b071380 --- /dev/null +++ b/adapter/fiberopenapi/v3/router_test.go @@ -0,0 +1,580 @@ +package fiberopenapi_test + +import ( + "flag" + "io" + "net/http" + "os" + "path/filepath" + "testing" + + "github.com/gofiber/fiber/v3" + "github.com/gofiber/fiber/v3/middleware/static" + fiberopenapi "github.com/oaswrap/spec/adapter/fiberopenapi/v3" + "github.com/oaswrap/spec/openapi" + "github.com/oaswrap/spec/option" + "github.com/oaswrap/spec/pkg/dto" + "github.com/oaswrap/spec/pkg/testutil" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +//nolint:gochecknoglobals // test flag for golden file updates +var update = flag.Bool("update", false, "update golden files") + +func PingHandler(c fiber.Ctx) error { + return c.SendString("pong") +} + +func TestRouter_Spec(t *testing.T) { + tests := []struct { + name string + golden string + options []option.OpenAPIOption + setup func(r fiberopenapi.Router) + shouldErr bool + }{ + { + name: "Pet Store API", + golden: "petstore.yaml", + options: []option.OpenAPIOption{ + option.WithDescription("This is a sample Petstore server."), + option.WithVersion("1.0.0"), + option.WithTermsOfService("https://swagger.io/terms/"), + option.WithContact(openapi.Contact{ + Email: "apiteam@swagger.io", + }), + option.WithLicense(openapi.License{ + Name: "Apache 2.0", + URL: "https://www.apache.org/licenses/LICENSE-2.0.html", + }), + option.WithExternalDocs("https://swagger.io", "Find more info here about swagger"), + option.WithServer("https://petstore3.swagger.io/api/v3"), + option.WithTags( + openapi.Tag{ + Name: "pet", + Description: "Everything about your Pets", + ExternalDocs: &openapi.ExternalDocs{ + Description: "Find out more about our Pets", + URL: "https://swagger.io", + }, + }, + openapi.Tag{ + Name: "store", + Description: "Access to Petstore orders", + ExternalDocs: &openapi.ExternalDocs{ + Description: "Find out more about our Store", + URL: "https://swagger.io", + }, + }, + openapi.Tag{ + Name: "user", + Description: "Operations about user", + }, + ), + option.WithSecurity("petstore_auth", option.SecurityOAuth2( + openapi.OAuthFlows{ + Implicit: &openapi.OAuthFlowsImplicit{ + AuthorizationURL: "https://petstore3.swagger.io/oauth/authorize", + Scopes: map[string]string{ + "write:pets": "modify pets in your account", + "read:pets": "read your pets", + }, + }, + }), + ), + option.WithSecurity("apiKey", option.SecurityAPIKey("api_key", openapi.SecuritySchemeAPIKeyInHeader)), + }, + setup: func(r fiberopenapi.Router) { + pet := r.Group("/pet").With( + option.GroupTags("pet"), + option.GroupSecurity("petstore_auth", "write:pets", "read:pets"), + ) + pet.Put("/", nil).With( + option.OperationID("updatePet"), + option.Summary("Update an existing pet"), + option.Description("Update the details of an existing pet in the store."), + option.Request(new(dto.Pet)), + option.Response(200, new(dto.Pet)), + ) + pet.Post("/", nil).With( + option.OperationID("addPet"), + option.Summary("Add a new pet"), + option.Description("Add a new pet to the store."), + option.Request(new(dto.Pet)), + option.Response(201, new(dto.Pet)), + ) + pet.Get("/findByStatus", nil).With( + option.OperationID("findPetsByStatus"), + option.Summary("Find pets by status"), + option.Description("Finds Pets by status. Multiple status values can be provided with comma separated strings."), + option.Request(new(struct { + Status string `query:"status" enum:"available,pending,sold"` + })), + option.Response(200, new([]dto.Pet)), + ) + pet.Get("/findByTags", nil).With( + option.OperationID("findPetsByTags"), + option.Summary("Find pets by tags"), + option.Description("Finds Pets by tags. Multiple tags can be provided with comma separated strings."), + option.Request(new(struct { + Tags []string `query:"tags"` + })), + option.Response(200, new([]dto.Pet)), + ) + pet.Post("/:petId/uploadImage", nil).With( + option.OperationID("uploadFile"), + option.Summary("Upload an image for a pet"), + option.Description("Uploads an image for a pet."), + option.Request(new(dto.UploadImageRequest)), + option.Response(200, new(dto.APIResponse)), + ) + pet.Get("/:petId", nil).With( + option.OperationID("getPetById"), + option.Summary("Get pet by ID"), + option.Description("Retrieve a pet by its ID."), + option.Request(new(struct { + ID int `params:"petId" required:"true"` + })), + option.Response(200, new(dto.Pet)), + ) + pet.Post("/:petId", nil).With( + option.OperationID("updatePetWithForm"), + option.Summary("Update pet with form"), + option.Description("Updates a pet in the store with form data."), + option.Request(new(dto.UpdatePetWithFormRequest)), + option.Response(200, nil), + ) + pet.Delete("/{petId}", nil).With( + option.OperationID("deletePet"), + option.Summary("Delete a pet"), + option.Description("Delete a pet from the store by its ID."), + option.Request(new(dto.DeletePetRequest)), + option.Response(204, nil), + ) + store := r.Group("/store").With( + option.GroupTags("store"), + ) + store.Post("/order", nil).With( + option.OperationID("placeOrder"), + option.Summary("Place an order"), + option.Description("Place a new order for a pet."), + option.Request(new(dto.Order)), + option.Response(201, new(dto.Order)), + ) + store.Get("/order/:orderId", nil).With( + option.OperationID("getOrderById"), + option.Summary("Get order by ID"), + option.Description("Retrieve an order by its ID."), + option.Request(new(struct { + ID int `params:"orderId" required:"true"` + })), + option.Response(200, new(dto.Order)), + option.Response(404, nil), + ) + store.Delete("/order/:orderId", nil).With( + option.OperationID("deleteOrder"), + option.Summary("Delete an order"), + option.Description("Delete an order by its ID."), + option.Request(new(struct { + ID int `params:"orderId" required:"true"` + })), + option.Response(204, nil), + ) + + user := r.Group("/user").With( + option.GroupTags("user"), + ) + user.Post("/createWithList", nil).With( + option.OperationID("createUsersWithList"), + option.Summary("Create users with list"), + option.Description("Create multiple users in the store with a list."), + option.Request(new([]dto.PetUser)), + option.Response(201, nil), + ) + user.Post("/", nil).With( + option.OperationID("createUser"), + option.Summary("Create a new user"), + option.Description("Create a new user in the store."), + option.Request(new(dto.PetUser)), + option.Response(201, new(dto.PetUser)), + ) + user.Get("/:username", nil).With( + option.OperationID("getUserByName"), + option.Summary("Get user by username"), + option.Description("Retrieve a user by their username."), + option.Request(new(struct { + Username string `params:"username" required:"true"` + })), + option.Response(200, new(dto.PetUser)), + option.Response(404, nil), + ) + user.Put("/:username", nil).With( + option.OperationID("updateUser"), + option.Summary("Update an existing user"), + option.Description("Update the details of an existing user."), + option.Request(new(struct { + dto.PetUser + + Username string `params:"username" required:"true"` + })), + option.Response(200, new(dto.PetUser)), + option.Response(404, nil), + ) + user.Delete("/:username", nil).With( + option.OperationID("deleteUser"), + option.Summary("Delete a user"), + option.Description("Delete a user from the store by their username."), + option.Request(new(struct { + Username string `params:"username" required:"true"` + })), + option.Response(204, nil), + ) + }, + }, + { + name: "Invalid OpenAPI Version", + options: []option.OpenAPIOption{ + option.WithTitle("Invalid OpenAPI Version"), + option.WithOpenAPIVersion("2.0"), // Intentionally invalid for testing + option.WithDescription("This is a test API with an invalid OpenAPI version"), + }, + shouldErr: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + app := fiber.New() + opts := []option.OpenAPIOption{ + option.WithTitle("Test API " + tt.name), + option.WithVersion("1.0.0"), + option.WithDescription("This is a test API for " + tt.name), + option.WithReflectorConfig( + option.RequiredPropByValidateTag(), + ), + } + if len(tt.options) > 0 { + opts = append(opts, tt.options...) + } + r := fiberopenapi.NewRouter(app, opts...) + + if tt.setup != nil { + tt.setup(r) + } + + if tt.shouldErr { + err := r.Validate() + require.Error(t, err, "expected error for invalid OpenAPI configuration") + return + } + err := r.Validate() + require.NoError(t, err, "failed to validate OpenAPI configuration") + + // Test the OpenAPI schema generation + schema, err := r.GenerateSchema() + + require.NoError(t, err, "failed to generate OpenAPI schema") + goldenFile := filepath.Join("testdata", tt.golden) + + if *update { + err = r.WriteSchemaTo(goldenFile) + require.NoError(t, err, "failed to write golden file") + t.Logf("Updated golden file: %s", goldenFile) + } + + want, err := os.ReadFile(goldenFile) + require.NoError(t, err, "failed to read golden file %s", goldenFile) + + testutil.EqualYAML(t, want, schema) + }) + } +} + +type SingleRouteFunc func(string, fiber.Handler, ...any) fiberopenapi.Route + +func TestRouter_Single(t *testing.T) { + tests := []struct { + method string + path string + methodFunc func(r fiberopenapi.Router) SingleRouteFunc + }{ + {"GET", "/ping", func(r fiberopenapi.Router) SingleRouteFunc { return r.Get }}, + {"HEAD", "/ping", func(r fiberopenapi.Router) SingleRouteFunc { return r.Head }}, + {"POST", "/ping", func(r fiberopenapi.Router) SingleRouteFunc { return r.Post }}, + {"PUT", "/ping", func(r fiberopenapi.Router) SingleRouteFunc { return r.Put }}, + {"PATCH", "/ping", func(r fiberopenapi.Router) SingleRouteFunc { return r.Patch }}, + {"DELETE", "/ping", func(r fiberopenapi.Router) SingleRouteFunc { return r.Delete }}, + {"CONNECT", "/ping", func(r fiberopenapi.Router) SingleRouteFunc { return r.Connect }}, + {"OPTIONS", "/ping", func(r fiberopenapi.Router) SingleRouteFunc { return r.Options }}, + {"TRACE", "/ping", func(r fiberopenapi.Router) SingleRouteFunc { return r.Trace }}, + } + for _, tt := range tests { + t.Run(tt.method, func(t *testing.T) { + app := fiber.New() + r := fiberopenapi.NewRouter(app) + + routeFunc := tt.methodFunc(r) + route := routeFunc(tt.path, func(c fiber.Ctx) error { + return c.SendString("pong") + }).With( + option.OperationID("ping"), + option.Summary("Ping Endpoint"), + ).Name("ping") + + assert.NotNil(t, route, "expected route to be created for %s %s", tt.method, tt.path) + fr := app.GetRoute("ping") + assert.NotEmpty(t, fr.Name, "expected route name to be set for %s %s", tt.method, tt.path) + + req, _ := http.NewRequest(tt.method, tt.path, nil) + res, err := app.Test(req, fiber.TestConfig{Timeout: -1}) + require.NoError(t, err, "failed to test %s request", tt.method) + assert.Equal(t, http.StatusOK, res.StatusCode, "expected status OK for %s request", tt.method) + + if tt.method != "HEAD" { + var body []byte + body, err = io.ReadAll(res.Body) + require.NoError(t, err, "failed to read response body for %s request", tt.method) + assert.Equal(t, "pong", string(body), "expected response body to be 'pong' for %s request", tt.method) + } + if tt.method == "CONNECT" { + return // CONNECT method is not supported by OpenAPI, so we skip it + } + + schema, err := r.GenerateSchema() + require.NoError(t, err, "failed to generate OpenAPI schema for %s request", tt.method) + assert.NotEmpty(t, schema, "expected non-empty OpenAPI schema for %s request", tt.method) + + // Check if the route is registered in the OpenAPI schema + assert.Contains( + t, + string(schema), + "operationId: ping", + "expected operationId 'ping' in OpenAPI schema for %s request", + tt.method, + ) + }) + } + + t.Run("Static", func(t *testing.T) { + app := fiber.New() + r := fiberopenapi.NewRouter(app) + r.Get("/static/*.yaml", static.New("./testdata")) + req, _ := http.NewRequest(http.MethodGet, "/static/petstore.yaml", nil) + res, err := app.Test(req, fiber.TestConfig{Timeout: -1}) + require.NoError(t, err, "failed to test static file request") + assert.Equal(t, http.StatusOK, res.StatusCode, "expected status OK for static file request") + }) +} + +func TestRouter_Group(t *testing.T) { + t.Run("Group", func(t *testing.T) { + app := fiber.New() + r := fiberopenapi.NewRouter(app) + + group := r.Group("/api", func(c fiber.Ctx) error { + return c.Next() + }) + + group.Get("/ping", func(c fiber.Ctx) error { + return c.SendString("pong") + }).With( + option.OperationID("ping"), + option.Summary("Ping Endpoint"), + ) + + req, _ := http.NewRequest(http.MethodGet, "/api/ping", nil) + res, err := app.Test(req, fiber.TestConfig{Timeout: -1}) + require.NoError(t, err, "failed to test group route") + assert.Equal(t, http.StatusOK, res.StatusCode, "expected status OK for group route") + + body, err := io.ReadAll(res.Body) + require.NoError(t, err, "failed to read response body for group route") + assert.Equal(t, "pong", string(body), "expected response body to be 'pong' for group route") + }) + t.Run("Route", func(t *testing.T) { + app := fiber.New() + r := fiberopenapi.NewRouter(app) + + r.Route("/api", func(r fiberopenapi.Router) { + r.Get("/ping", func(c fiber.Ctx) error { + return c.SendString("pong") + }).With( + option.OperationID("ping"), + option.Summary("Ping Endpoint"), + ) + }) + + req, _ := http.NewRequest(http.MethodGet, "/api/ping", nil) + res, err := app.Test(req, fiber.TestConfig{Timeout: -1}) + require.NoError(t, err, "failed to test route") + assert.Equal(t, http.StatusOK, res.StatusCode, "expected status OK for route") + + body, err := io.ReadAll(res.Body) + require.NoError(t, err, "failed to read response body for route") + assert.Equal(t, "pong", string(body), "expected response body to be 'pong' for route") + }) +} + +func TestRouter_Middleware(t *testing.T) { + t.Run("Use", func(t *testing.T) { + called := false + middleware := func(c fiber.Ctx) error { + called = true + return c.Next() + } + app := fiber.New() + r := fiberopenapi.NewRouter(app) + r.Use(middleware) + r.Get("/ping", func(c fiber.Ctx) error { + return c.SendString("pong") + }) + + req, _ := http.NewRequest(http.MethodGet, "/ping", nil) + res, err := app.Test(req, fiber.TestConfig{Timeout: -1}) + require.NoError(t, err, "failed to test middleware route") + assert.Equal(t, http.StatusOK, res.StatusCode, "expected status OK for middleware route") + assert.True(t, called, "expected middleware to be called") + }) +} + +func TestGenerator_Docs(t *testing.T) { + // Test that the docs route is registered + app := fiber.New() + r := fiberopenapi.NewRouter(app) + r.Get("/ping", PingHandler).With( + option.Summary("Ping Endpoint"), + ) + + t.Run("should serve docs", func(t *testing.T) { + req, _ := http.NewRequest(http.MethodGet, "/docs", nil) + res, err := app.Test(req, fiber.TestConfig{Timeout: -1}) + require.NoError(t, err, "failed to test docs route") + assert.Equal(t, http.StatusOK, res.StatusCode, "expected status OK for docs route") + + body, err := io.ReadAll(res.Body) + require.NoError(t, err, "failed to read response body for docs route") + assert.Contains( + t, + string(body), + "Fiber v3 OpenAPI", + "expected response body to contain 'Fiber v3 OpenAPI' for docs route", + ) + }) + t.Run("should serve OpenAPI YAML", func(t *testing.T) { + req, _ := http.NewRequest(http.MethodGet, "/docs/openapi.yaml", nil) + res, err := app.Test(req, fiber.TestConfig{Timeout: -1}) + require.NoError(t, err, "failed to test OpenAPI YAML route") + assert.Equal(t, http.StatusOK, res.StatusCode, "expected status OK for OpenAPI YAML route") + + body, err := io.ReadAll(res.Body) + require.NoError(t, err, "failed to read response body for OpenAPI YAML route") + assert.NotEmpty(t, body, "expected non-empty response body for OpenAPI YAML route") + assert.Contains( + t, + string(body), + "openapi: 3.0.3", + "expected OpenAPI version in response body for OpenAPI YAML route", + ) + }) +} + +func TestGenerator_DisableDocs(t *testing.T) { + pingHandler := func(c fiber.Ctx) error { + return c.SendString("pong") + } + app := fiber.New() + r := fiberopenapi.NewRouter(app, option.WithDisableDocs()) + r.Get("/ping", pingHandler).With( + option.Summary("Ping Endpoint"), + option.Description("Endpoint to test ping functionality"), + ) + + t.Run("should not register docs route", func(t *testing.T) { + reqDocs, _ := http.NewRequest(http.MethodGet, "/docs", nil) + resDocs, err := app.Test(reqDocs, fiber.TestConfig{Timeout: -1}) + require.NoError(t, err, "failed to test docs route") + assert.Equal(t, http.StatusNotFound, resDocs.StatusCode, "expected status Not Found for docs route") + _ = resDocs.Body.Close() + }) + t.Run("should not register openapi.yaml route", func(t *testing.T) { + reqOpenAPI, _ := http.NewRequest(http.MethodGet, "/docs/openapi.yaml", nil) + resOpenAPI, err := app.Test(reqOpenAPI, fiber.TestConfig{Timeout: -1}) + require.NoError(t, err, "failed to test OpenAPI YAML route") + assert.Equal(t, http.StatusNotFound, resOpenAPI.StatusCode, "expected status Not Found for OpenAPI YAML route") + _ = resOpenAPI.Body.Close() + }) +} + +func TestGenerator_WriteSchemaTo(t *testing.T) { + app := fiber.New() + r := fiberopenapi.NewGenerator(app, + option.WithTitle("Test API Write Schema"), + option.WithVersion("1.0.0"), + option.WithDescription("This is a test API for writing OpenAPI schema to file"), + ) + + r.Get("/ping", PingHandler).With( + option.Summary("Ping Endpoint"), + option.Description("Endpoint to test ping functionality"), + ) + + err := r.Validate() + require.NoError(t, err, "failed to validate OpenAPI configuration") + + tempFile, err := os.CreateTemp(t.TempDir(), "openapi-schema-*.yaml") + require.NoError(t, err, "failed to create temporary file for OpenAPI schema") + defer func() { + err = os.Remove(tempFile.Name()) + require.NoError(t, err, "failed to remove temporary file") + }() + + err = r.WriteSchemaTo(tempFile.Name()) + require.NoError(t, err, "failed to write OpenAPI schema to file") + + schema, err := os.ReadFile(tempFile.Name()) + require.NoError(t, err, "failed to read OpenAPI schema from file") + assert.NotEmpty(t, schema, "expected non-empty OpenAPI schema") +} + +func TestGenerator_MarshalYAML(t *testing.T) { + app := fiber.New() + r := fiberopenapi.NewRouter(app, + option.WithTitle("Test API Marshall YAML"), + option.WithVersion("1.0.0"), + option.WithDescription("This is a test API for marshalling OpenAPI schema to YAML"), + ) + + r.Get("/ping", PingHandler).With( + option.Summary("Ping Endpoint"), + option.Description("Endpoint to test ping functionality"), + ) + + err := r.Validate() + require.NoError(t, err, "failed to validate OpenAPI configuration") + + yamlData, err := r.MarshalYAML() + require.NoError(t, err, "failed to marshal OpenAPI schema to YAML") + assert.NotEmpty(t, yamlData, "expected non-empty YAML data") +} + +func TestGeneratorMarshalJSON(t *testing.T) { + app := fiber.New() + r := fiberopenapi.NewRouter(app, + option.WithTitle("Test API Marshall JSON"), + option.WithVersion("1.0.0"), + option.WithDescription("This is a test API for marshalling OpenAPI schema to JSON"), + ) + + r.Get("/ping", PingHandler).With( + option.Summary("Ping Endpoint"), + option.Description("Endpoint to test ping functionality"), + ) + + err := r.Validate() + require.NoError(t, err, "failed to validate OpenAPI configuration") + + jsonData, err := r.MarshalJSON() + require.NoError(t, err, "failed to marshal OpenAPI schema to JSON") + assert.NotEmpty(t, jsonData, "expected non-empty JSON data") +} diff --git a/adapter/fiberopenapi/v3/testdata/petstore.yaml b/adapter/fiberopenapi/v3/testdata/petstore.yaml new file mode 100644 index 0000000..3bc4dfa --- /dev/null +++ b/adapter/fiberopenapi/v3/testdata/petstore.yaml @@ -0,0 +1,536 @@ +openapi: 3.0.3 +info: + contact: + email: apiteam@swagger.io + description: This is a sample Petstore server. + license: + name: Apache 2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + termsOfService: https://swagger.io/terms/ + title: Test API Pet Store API + version: 1.0.0 +externalDocs: + description: Find more info here about swagger + url: https://swagger.io +servers: +- url: https://petstore3.swagger.io/api/v3 +tags: +- description: Everything about your Pets + externalDocs: + description: Find out more about our Pets + url: https://swagger.io + name: pet +- description: Access to Petstore orders + externalDocs: + description: Find out more about our Store + url: https://swagger.io + name: store +- description: Operations about user + name: user +paths: + /pet: + post: + description: Add a new pet to the store. + operationId: addPet + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DtoPet' + responses: + "201": + content: + application/json: + schema: + $ref: '#/components/schemas/DtoPet' + description: Created + security: + - petstore_auth: + - write:pets + - read:pets + summary: Add a new pet + tags: + - pet + put: + description: Update the details of an existing pet in the store. + operationId: updatePet + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DtoPet' + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/DtoPet' + description: OK + security: + - petstore_auth: + - write:pets + - read:pets + summary: Update an existing pet + tags: + - pet + /pet/{petId}: + delete: + description: Delete a pet from the store by its ID. + operationId: deletePet + parameters: + - in: path + name: petId + required: true + schema: + type: integer + - in: header + name: api_key + schema: + type: string + responses: + "204": + description: No Content + security: + - petstore_auth: + - write:pets + - read:pets + summary: Delete a pet + tags: + - pet + get: + description: Retrieve a pet by its ID. + operationId: getPetById + parameters: + - in: path + name: petId + required: true + schema: + type: integer + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/DtoPet' + description: OK + security: + - petstore_auth: + - write:pets + - read:pets + summary: Get pet by ID + tags: + - pet + post: + description: Updates a pet in the store with form data. + operationId: updatePetWithForm + parameters: + - in: path + name: petId + required: true + schema: + type: integer + requestBody: + content: + application/x-www-form-urlencoded: + schema: + $ref: '#/components/schemas/FormDataDtoUpdatePetWithFormRequest' + responses: + "200": + description: OK + security: + - petstore_auth: + - write:pets + - read:pets + summary: Update pet with form + tags: + - pet + /pet/{petId}/uploadImage: + post: + description: Uploads an image for a pet. + operationId: uploadFile + parameters: + - in: query + name: additionalMetadata + schema: + type: string + - in: path + name: petId + required: true + schema: + format: int64 + type: integer + requestBody: + content: + application/octet-stream: + schema: + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/DtoAPIResponse' + description: OK + security: + - petstore_auth: + - write:pets + - read:pets + summary: Upload an image for a pet + tags: + - pet + /pet/findByStatus: + get: + description: Finds Pets by status. Multiple status values can be provided with + comma separated strings. + operationId: findPetsByStatus + parameters: + - in: query + name: status + schema: + enum: + - available + - pending + - sold + type: string + responses: + "200": + content: + application/json: + schema: + items: + $ref: '#/components/schemas/DtoPet' + type: array + description: OK + security: + - petstore_auth: + - write:pets + - read:pets + summary: Find pets by status + tags: + - pet + /pet/findByTags: + get: + description: Finds Pets by tags. Multiple tags can be provided with comma separated + strings. + operationId: findPetsByTags + parameters: + - in: query + name: tags + schema: + items: + type: string + type: array + responses: + "200": + content: + application/json: + schema: + items: + $ref: '#/components/schemas/DtoPet' + type: array + description: OK + security: + - petstore_auth: + - write:pets + - read:pets + summary: Find pets by tags + tags: + - pet + /store/order: + post: + description: Place a new order for a pet. + operationId: placeOrder + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DtoOrder' + responses: + "201": + content: + application/json: + schema: + $ref: '#/components/schemas/DtoOrder' + description: Created + summary: Place an order + tags: + - store + /store/order/{orderId}: + delete: + description: Delete an order by its ID. + operationId: deleteOrder + parameters: + - in: path + name: orderId + required: true + schema: + type: integer + responses: + "204": + description: No Content + summary: Delete an order + tags: + - store + get: + description: Retrieve an order by its ID. + operationId: getOrderById + parameters: + - in: path + name: orderId + required: true + schema: + type: integer + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/DtoOrder' + description: OK + "404": + description: Not Found + summary: Get order by ID + tags: + - store + /user: + post: + description: Create a new user in the store. + operationId: createUser + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DtoPetUser' + responses: + "201": + content: + application/json: + schema: + $ref: '#/components/schemas/DtoPetUser' + description: Created + summary: Create a new user + tags: + - user + /user/{username}: + delete: + description: Delete a user from the store by their username. + operationId: deleteUser + parameters: + - in: path + name: username + required: true + schema: + type: string + responses: + "204": + description: No Content + summary: Delete a user + tags: + - user + get: + description: Retrieve a user by their username. + operationId: getUserByName + parameters: + - in: path + name: username + required: true + schema: + type: string + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/DtoPetUser' + description: OK + "404": + description: Not Found + summary: Get user by username + tags: + - user + put: + description: Update the details of an existing user. + operationId: updateUser + parameters: + - in: path + name: username + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + properties: + email: + type: string + firstName: + type: string + id: + type: integer + lastName: + type: string + password: + type: string + phone: + type: string + userStatus: + enum: + - 0 + - 1 + - 2 + type: integer + username: + type: string + type: object + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/DtoPetUser' + description: OK + "404": + description: Not Found + summary: Update an existing user + tags: + - user + /user/createWithList: + post: + description: Create multiple users in the store with a list. + operationId: createUsersWithList + requestBody: + content: + application/json: + schema: + items: + $ref: '#/components/schemas/DtoPetUser' + nullable: true + type: array + responses: + "201": + description: Created + summary: Create users with list + tags: + - user +components: + schemas: + DtoAPIResponse: + properties: + code: + type: integer + message: + type: string + type: + type: string + type: object + DtoCategory: + properties: + id: + type: integer + name: + type: string + type: object + DtoOrder: + properties: + complete: + type: boolean + id: + type: integer + petId: + type: integer + quantity: + type: integer + shipDate: + format: date-time + type: string + status: + enum: + - placed + - approved + - delivered + type: string + type: object + DtoPet: + properties: + category: + $ref: '#/components/schemas/DtoCategory' + id: + type: integer + name: + type: string + photoUrls: + items: + type: string + nullable: true + type: array + status: + enum: + - available + - pending + - sold + type: string + tags: + items: + $ref: '#/components/schemas/DtoTag' + nullable: true + type: array + type: + type: string + type: object + DtoPetUser: + properties: + email: + type: string + firstName: + type: string + id: + type: integer + lastName: + type: string + password: + type: string + phone: + type: string + userStatus: + enum: + - 0 + - 1 + - 2 + type: integer + username: + type: string + type: object + DtoTag: + properties: + id: + type: integer + name: + type: string + type: object + FormDataDtoUpdatePetWithFormRequest: + properties: + name: + type: string + status: + enum: + - available + - pending + - sold + type: string + required: + - name + type: object + securitySchemes: + apiKey: + in: header + name: api_key + type: apiKey + petstore_auth: + flows: + implicit: + authorizationUrl: https://petstore3.swagger.io/oauth/authorize + scopes: + read:pets: read your pets + write:pets: modify pets in your account + type: oauth2 diff --git a/adapter/fiberopenapi/v3/types.go b/adapter/fiberopenapi/v3/types.go new file mode 100644 index 0000000..caa0f34 --- /dev/null +++ b/adapter/fiberopenapi/v3/types.go @@ -0,0 +1,63 @@ +package fiberopenapi + +import ( + "github.com/gofiber/fiber/v3" + "github.com/oaswrap/spec/option" +) + +// Generator defines the interface for generating OpenAPI schemas. +type Generator interface { + Router + + // Validate checks for errors at OpenAPI router initialization. + Validate() error + + // GenerateSchema generates the OpenAPI schema in the specified format. + GenerateSchema(format ...string) ([]byte, error) + // MarshalYAML marshals the OpenAPI schema to YAML format. + MarshalYAML() ([]byte, error) + // MarshalJSON marshals the OpenAPI schema to JSON format. + MarshalJSON() ([]byte, error) + + // WriteSchemaTo writes the OpenAPI schema to a file. + WriteSchemaTo(filePath string) error +} + +// Router defines the interface for an OpenAPI router. +type Router interface { + // Use applies middleware to the router. + Use(args ...any) Router + + // Get registers a GET route. + Get(path string, handler fiber.Handler, handlers ...any) Route + // Head registers a HEAD route. + Head(path string, handler fiber.Handler, handlers ...any) Route + // Post registers a POST route. + Post(path string, handler fiber.Handler, handlers ...any) Route + // Put registers a PUT route. + Put(path string, handler fiber.Handler, handlers ...any) Route + // Patch registers a PATCH route. + Patch(path string, handler fiber.Handler, handlers ...any) Route + // Delete registers a DELETE route. + Delete(path string, handler fiber.Handler, handlers ...any) Route + // Connect registers a CONNECT route. + Connect(path string, handler fiber.Handler, handlers ...any) Route + // Options registers an OPTIONS route. + Options(path string, handler fiber.Handler, handlers ...any) Route + // Trace registers a TRACE route. + Trace(path string, handler fiber.Handler, handlers ...any) Route + + // Add registers a route with the specified method and path. + Add(methods []string, path string, handler fiber.Handler, handlers ...any) Route + + // Group creates a new sub-router with the specified prefix and handlers. + // The prefix is prepended to all routes in the sub-router. + Group(prefix string, handlers ...any) Router + + // Route creates a new sub-router with the specified prefix and applies options. + Route(prefix string, fn func(router Router), opts ...option.GroupOption) Router + + // With applies options to the router. + // This allows you to configure tags, security, and visibility for the routes. + With(opts ...option.GroupOption) Router +} diff --git a/adapter/ginopenapi/examples/basic/go.mod b/adapter/ginopenapi/examples/basic/go.mod index c483cb8..8d99d91 100644 --- a/adapter/ginopenapi/examples/basic/go.mod +++ b/adapter/ginopenapi/examples/basic/go.mod @@ -1,8 +1,6 @@ module github.com/oaswrap/spec/adapter/ginopenapi/examples/basic -go 1.23.0 - -toolchain go1.23.12 +go 1.24.0 require ( github.com/gin-gonic/gin v1.10.1 @@ -35,10 +33,10 @@ require ( github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect golang.org/x/arch v0.8.0 // indirect - golang.org/x/crypto v0.38.0 // indirect - golang.org/x/net v0.40.0 // indirect - golang.org/x/sys v0.33.0 // indirect - golang.org/x/text v0.25.0 // indirect + golang.org/x/crypto v0.44.0 // indirect + golang.org/x/net v0.47.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/text v0.31.0 // indirect google.golang.org/protobuf v1.34.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/adapter/ginopenapi/examples/basic/go.sum b/adapter/ginopenapi/examples/basic/go.sum index 3770eec..1bbcd69 100644 --- a/adapter/ginopenapi/examples/basic/go.sum +++ b/adapter/ginopenapi/examples/basic/go.sum @@ -41,7 +41,9 @@ github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuV github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -52,6 +54,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/oaswrap/spec v0.3.6 h1:igKJvrrEYP/pK5I4TzEzYVcdbbr8eJ1gfALUXgZ/Oc8= +github.com/oaswrap/spec v0.3.6/go.mod h1:e6cGQJcVCkQozwsw8T0ydSWEgQPA/dHFmQME4KawOYU= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= github.com/oaswrap/spec-ui v0.1.4/go.mod h1:D8EnD6zbYJ3q65wdltw6QHXfw+nut5XwSSA1xtlSEQQ= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= @@ -72,11 +75,13 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= github.com/swaggest/jsonschema-go v0.3.78 h1:5+YFQrLxOR8z6CHvgtZc42WRy/Q9zRQQ4HoAxlinlHw= github.com/swaggest/jsonschema-go v0.3.78/go.mod h1:4nniXBuE+FIGkOGuidjOINMH7OEqZK3HCSbfDuLRI0g= github.com/swaggest/openapi-go v0.2.60 h1:kglHH/WIfqAglfuWL4tu0LPakqNYySzklUWx06SjSKo= +github.com/swaggest/openapi-go v0.2.60/go.mod h1:jmFOuYdsWGtHU0BOuILlHZQJxLqHiAE6en+baE+QQUk= github.com/swaggest/refl v1.4.0 h1:CftOSdTqRqs100xpFOT/Rifss5xBV/CT0S/FN60Xe9k= github.com/swaggest/refl v1.4.0/go.mod h1:4uUVFVfPJ0NSX9FPwMPspeHos9wPFlCMGoPRllUbpvA= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= @@ -90,16 +95,21 @@ github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDf golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= -golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= -golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU= +golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/adapter/ginopenapi/go.mod b/adapter/ginopenapi/go.mod index 14dc4a1..22c41e3 100644 --- a/adapter/ginopenapi/go.mod +++ b/adapter/ginopenapi/go.mod @@ -1,8 +1,6 @@ module github.com/oaswrap/spec/adapter/ginopenapi -go 1.23.0 - -toolchain go1.23.12 +go 1.24.0 require ( github.com/gin-gonic/gin v1.10.1 @@ -26,7 +24,7 @@ require ( github.com/google/go-cmp v0.7.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect - github.com/kr/text v0.1.0 // indirect + github.com/kr/text v0.2.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -39,10 +37,10 @@ require ( github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect golang.org/x/arch v0.8.0 // indirect - golang.org/x/crypto v0.38.0 // indirect - golang.org/x/net v0.40.0 // indirect - golang.org/x/sys v0.33.0 // indirect - golang.org/x/text v0.25.0 // indirect + golang.org/x/crypto v0.44.0 // indirect + golang.org/x/net v0.47.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/text v0.31.0 // indirect google.golang.org/protobuf v1.34.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/adapter/ginopenapi/go.sum b/adapter/ginopenapi/go.sum index 2707d35..6241bcd 100644 --- a/adapter/ginopenapi/go.sum +++ b/adapter/ginopenapi/go.sum @@ -10,6 +10,7 @@ github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/ github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -42,9 +43,8 @@ github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZY github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -96,16 +96,16 @@ github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDf golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= -golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= -golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= -golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= -golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU= +golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= -golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/adapter/httpopenapi/examples/basic/go.sum b/adapter/httpopenapi/examples/basic/go.sum index ec14753..0db5d80 100644 --- a/adapter/httpopenapi/examples/basic/go.sum +++ b/adapter/httpopenapi/examples/basic/go.sum @@ -9,8 +9,11 @@ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/oaswrap/spec v0.3.6 h1:igKJvrrEYP/pK5I4TzEzYVcdbbr8eJ1gfALUXgZ/Oc8= +github.com/oaswrap/spec v0.3.6/go.mod h1:e6cGQJcVCkQozwsw8T0ydSWEgQPA/dHFmQME4KawOYU= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= github.com/oaswrap/spec-ui v0.1.4/go.mod h1:D8EnD6zbYJ3q65wdltw6QHXfw+nut5XwSSA1xtlSEQQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -18,11 +21,13 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= github.com/swaggest/jsonschema-go v0.3.78 h1:5+YFQrLxOR8z6CHvgtZc42WRy/Q9zRQQ4HoAxlinlHw= github.com/swaggest/jsonschema-go v0.3.78/go.mod h1:4nniXBuE+FIGkOGuidjOINMH7OEqZK3HCSbfDuLRI0g= github.com/swaggest/openapi-go v0.2.60 h1:kglHH/WIfqAglfuWL4tu0LPakqNYySzklUWx06SjSKo= +github.com/swaggest/openapi-go v0.2.60/go.mod h1:jmFOuYdsWGtHU0BOuILlHZQJxLqHiAE6en+baE+QQUk= github.com/swaggest/refl v1.4.0 h1:CftOSdTqRqs100xpFOT/Rifss5xBV/CT0S/FN60Xe9k= github.com/swaggest/refl v1.4.0/go.mod h1:4uUVFVfPJ0NSX9FPwMPspeHos9wPFlCMGoPRllUbpvA= github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= @@ -31,6 +36,7 @@ github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3Ifn github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/adapter/httpopenapi/go.mod b/adapter/httpopenapi/go.mod index 5f841ec..42f7aec 100644 --- a/adapter/httpopenapi/go.mod +++ b/adapter/httpopenapi/go.mod @@ -11,7 +11,7 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/kr/text v0.1.0 // indirect + github.com/kr/text v0.2.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/swaggest/jsonschema-go v0.3.78 // indirect github.com/swaggest/openapi-go v0.2.60 // indirect diff --git a/adapter/httpopenapi/go.sum b/adapter/httpopenapi/go.sum index 0cdec49..98deb92 100644 --- a/adapter/httpopenapi/go.sum +++ b/adapter/httpopenapi/go.sum @@ -2,6 +2,7 @@ github.com/bool64/dev v0.2.39 h1:kP8DnMGlWXhGYJEZE/J0l/gVBdbuhoPGL+MJG4QbofE= github.com/bool64/dev v0.2.39/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -10,9 +11,8 @@ github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJ github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/oaswrap/spec v0.3.6 h1:igKJvrrEYP/pK5I4TzEzYVcdbbr8eJ1gfALUXgZ/Oc8= github.com/oaswrap/spec v0.3.6/go.mod h1:e6cGQJcVCkQozwsw8T0ydSWEgQPA/dHFmQME4KawOYU= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= diff --git a/adapter/httprouteropenapi/examples/basic/go.sum b/adapter/httprouteropenapi/examples/basic/go.sum index 2ec7299..f2f119e 100644 --- a/adapter/httprouteropenapi/examples/basic/go.sum +++ b/adapter/httprouteropenapi/examples/basic/go.sum @@ -11,8 +11,11 @@ github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJ github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/oaswrap/spec v0.3.6 h1:igKJvrrEYP/pK5I4TzEzYVcdbbr8eJ1gfALUXgZ/Oc8= +github.com/oaswrap/spec v0.3.6/go.mod h1:e6cGQJcVCkQozwsw8T0ydSWEgQPA/dHFmQME4KawOYU= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= github.com/oaswrap/spec-ui v0.1.4/go.mod h1:D8EnD6zbYJ3q65wdltw6QHXfw+nut5XwSSA1xtlSEQQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -20,11 +23,13 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= github.com/swaggest/jsonschema-go v0.3.78 h1:5+YFQrLxOR8z6CHvgtZc42WRy/Q9zRQQ4HoAxlinlHw= github.com/swaggest/jsonschema-go v0.3.78/go.mod h1:4nniXBuE+FIGkOGuidjOINMH7OEqZK3HCSbfDuLRI0g= github.com/swaggest/openapi-go v0.2.60 h1:kglHH/WIfqAglfuWL4tu0LPakqNYySzklUWx06SjSKo= +github.com/swaggest/openapi-go v0.2.60/go.mod h1:jmFOuYdsWGtHU0BOuILlHZQJxLqHiAE6en+baE+QQUk= github.com/swaggest/refl v1.4.0 h1:CftOSdTqRqs100xpFOT/Rifss5xBV/CT0S/FN60Xe9k= github.com/swaggest/refl v1.4.0/go.mod h1:4uUVFVfPJ0NSX9FPwMPspeHos9wPFlCMGoPRllUbpvA= github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= @@ -33,6 +38,7 @@ github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3Ifn github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/adapter/httprouteropenapi/go.mod b/adapter/httprouteropenapi/go.mod index 253110a..98b20af 100644 --- a/adapter/httprouteropenapi/go.mod +++ b/adapter/httprouteropenapi/go.mod @@ -12,7 +12,7 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/kr/text v0.1.0 // indirect + github.com/kr/text v0.2.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/swaggest/jsonschema-go v0.3.78 // indirect github.com/swaggest/openapi-go v0.2.60 // indirect diff --git a/adapter/httprouteropenapi/go.sum b/adapter/httprouteropenapi/go.sum index fd60f82..04934a3 100644 --- a/adapter/httprouteropenapi/go.sum +++ b/adapter/httprouteropenapi/go.sum @@ -2,6 +2,7 @@ github.com/bool64/dev v0.2.39 h1:kP8DnMGlWXhGYJEZE/J0l/gVBdbuhoPGL+MJG4QbofE= github.com/bool64/dev v0.2.39/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -12,9 +13,8 @@ github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4d github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/oaswrap/spec v0.3.6 h1:igKJvrrEYP/pK5I4TzEzYVcdbbr8eJ1gfALUXgZ/Oc8= github.com/oaswrap/spec v0.3.6/go.mod h1:e6cGQJcVCkQozwsw8T0ydSWEgQPA/dHFmQME4KawOYU= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= diff --git a/adapter/muxopenapi/examples/basic/go.sum b/adapter/muxopenapi/examples/basic/go.sum index 0027ed6..0c16995 100644 --- a/adapter/muxopenapi/examples/basic/go.sum +++ b/adapter/muxopenapi/examples/basic/go.sum @@ -11,8 +11,11 @@ github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWS github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/oaswrap/spec v0.3.6 h1:igKJvrrEYP/pK5I4TzEzYVcdbbr8eJ1gfALUXgZ/Oc8= +github.com/oaswrap/spec v0.3.6/go.mod h1:e6cGQJcVCkQozwsw8T0ydSWEgQPA/dHFmQME4KawOYU= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= github.com/oaswrap/spec-ui v0.1.4/go.mod h1:D8EnD6zbYJ3q65wdltw6QHXfw+nut5XwSSA1xtlSEQQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -20,11 +23,13 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= github.com/swaggest/jsonschema-go v0.3.78 h1:5+YFQrLxOR8z6CHvgtZc42WRy/Q9zRQQ4HoAxlinlHw= github.com/swaggest/jsonschema-go v0.3.78/go.mod h1:4nniXBuE+FIGkOGuidjOINMH7OEqZK3HCSbfDuLRI0g= github.com/swaggest/openapi-go v0.2.60 h1:kglHH/WIfqAglfuWL4tu0LPakqNYySzklUWx06SjSKo= +github.com/swaggest/openapi-go v0.2.60/go.mod h1:jmFOuYdsWGtHU0BOuILlHZQJxLqHiAE6en+baE+QQUk= github.com/swaggest/refl v1.4.0 h1:CftOSdTqRqs100xpFOT/Rifss5xBV/CT0S/FN60Xe9k= github.com/swaggest/refl v1.4.0/go.mod h1:4uUVFVfPJ0NSX9FPwMPspeHos9wPFlCMGoPRllUbpvA= github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= @@ -33,6 +38,7 @@ github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3Ifn github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/adapter/muxopenapi/go.mod b/adapter/muxopenapi/go.mod index 85ef982..4dd68bb 100644 --- a/adapter/muxopenapi/go.mod +++ b/adapter/muxopenapi/go.mod @@ -12,7 +12,7 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/kr/text v0.1.0 // indirect + github.com/kr/text v0.2.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/swaggest/jsonschema-go v0.3.78 // indirect github.com/swaggest/openapi-go v0.2.60 // indirect diff --git a/adapter/muxopenapi/go.sum b/adapter/muxopenapi/go.sum index 433d580..ecd6865 100644 --- a/adapter/muxopenapi/go.sum +++ b/adapter/muxopenapi/go.sum @@ -2,6 +2,7 @@ github.com/bool64/dev v0.2.39 h1:kP8DnMGlWXhGYJEZE/J0l/gVBdbuhoPGL+MJG4QbofE= github.com/bool64/dev v0.2.39/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -12,9 +13,8 @@ github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJ github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/oaswrap/spec v0.3.6 h1:igKJvrrEYP/pK5I4TzEzYVcdbbr8eJ1gfALUXgZ/Oc8= github.com/oaswrap/spec v0.3.6/go.mod h1:e6cGQJcVCkQozwsw8T0ydSWEgQPA/dHFmQME4KawOYU= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= diff --git a/examples/basic/go.mod b/examples/basic/go.mod index 28d2f67..fe18a58 100644 --- a/examples/basic/go.mod +++ b/examples/basic/go.mod @@ -5,7 +5,6 @@ go 1.21 require github.com/oaswrap/spec v0.3.6 require ( - github.com/kr/text v0.1.0 // indirect github.com/oaswrap/spec-ui v0.1.4 // indirect github.com/swaggest/jsonschema-go v0.3.78 // indirect github.com/swaggest/openapi-go v0.2.60 // indirect diff --git a/examples/basic/go.sum b/examples/basic/go.sum index ba4ec98..b98cadf 100644 --- a/examples/basic/go.sum +++ b/examples/basic/go.sum @@ -10,9 +10,8 @@ github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJ github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= github.com/oaswrap/spec-ui v0.1.4/go.mod h1:D8EnD6zbYJ3q65wdltw6QHXfw+nut5XwSSA1xtlSEQQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/examples/petstore/go.mod b/examples/petstore/go.mod index 7a04b89..9c4369a 100644 --- a/examples/petstore/go.mod +++ b/examples/petstore/go.mod @@ -5,7 +5,6 @@ go 1.21 require github.com/oaswrap/spec v0.3.6 require ( - github.com/kr/text v0.1.0 // indirect github.com/oaswrap/spec-ui v0.1.4 // indirect github.com/swaggest/jsonschema-go v0.3.78 // indirect github.com/swaggest/openapi-go v0.2.60 // indirect diff --git a/examples/petstore/go.sum b/examples/petstore/go.sum index ba4ec98..b98cadf 100644 --- a/examples/petstore/go.sum +++ b/examples/petstore/go.sum @@ -10,9 +10,8 @@ github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJ github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= github.com/oaswrap/spec-ui v0.1.4/go.mod h1:D8EnD6zbYJ3q65wdltw6QHXfw+nut5XwSSA1xtlSEQQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/go.mod b/go.mod index 2fad21d..c7450dc 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/kr/pretty v0.1.0 // indirect + github.com/kr/text v0.2.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/swaggest/refl v1.4.0 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect diff --git a/go.sum b/go.sum index ba4ec98..4f3d86d 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,7 @@ github.com/bool64/dev v0.2.39 h1:kP8DnMGlWXhGYJEZE/J0l/gVBdbuhoPGL+MJG4QbofE= github.com/bool64/dev v0.2.39/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg= github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= github.com/bool64/shared v0.1.5/go.mod h1:081yz68YC9jeFB3+Bbmno2RFWvGKv1lPKkMP6MHJlPs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -11,8 +12,9 @@ github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJ github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/oaswrap/spec-ui v0.1.4 h1:XM2Z/ZS2Su90EtDSVuOHGr2+DLpVc2933mxkn6F4aeU= github.com/oaswrap/spec-ui v0.1.4/go.mod h1:D8EnD6zbYJ3q65wdltw6QHXfw+nut5XwSSA1xtlSEQQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/go.work b/go.work index 60a798b..ebc6847 100644 --- a/go.work +++ b/go.work @@ -1,4 +1,4 @@ -go 1.23.0 +go 1.25.0 use ( . @@ -6,8 +6,10 @@ use ( ./adapter/chiopenapi/examples/basic ./adapter/echoopenapi ./adapter/echoopenapi/examples/basic - ./adapter/fiberopenapi - ./adapter/fiberopenapi/examples/basic + ./adapter/fiberopenapi/v2 + ./adapter/fiberopenapi/v2/examples/basic + ./adapter/fiberopenapi/v3 + ./adapter/fiberopenapi/v3/examples/basic ./adapter/ginopenapi ./adapter/ginopenapi/examples/basic ./adapter/httpopenapi diff --git a/go.work.sum b/go.work.sum index c58e3bc..3bb1119 100644 --- a/go.work.sum +++ b/go.work.sum @@ -25,12 +25,8 @@ github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/knz/go-libedit v1.10.1 h1:0pHpWtx9vcvC0xGZqEQlQdfSQs7WRlAjuPvk3fOZDCo= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= @@ -61,6 +57,7 @@ github.com/swaggest/refl v1.3.0/go.mod h1:3Ujvbmh1pfSbDYjC6JGG7nMgPvpG0ehQL4iNon github.com/swaggest/refl v1.3.1/go.mod h1:4uUVFVfPJ0NSX9FPwMPspeHos9wPFlCMGoPRllUbpvA= github.com/tinylib/msgp v1.2.5 h1:WeQg1whrXRFiZusidTQqzETkRpGjFjcIhW6uqWH09po= github.com/tinylib/msgp v1.2.5/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0= +github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/vearutop/statigz v1.4.0/go.mod h1:LYTolBLiz9oJISwiVKnOQoIwhO1LWX1A7OECawGS8XE= github.com/yosuke-furukawa/json5 v0.1.2-0.20201207051438-cf7bb3f354ff h1:7YqG491bE4vstXRz1lD38rbSgbXnirvROz1lZiOnPO8= github.com/yosuke-furukawa/json5 v0.1.2-0.20201207051438-cf7bb3f354ff/go.mod h1:sw49aWDqNdRJ6DYUtIQiaA3xyj2IL9tjeNYmX2ixwcU= @@ -85,6 +82,7 @@ golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -111,6 +109,7 @@ golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -148,6 +147,7 @@ golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= +golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -168,6 +168,7 @@ golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58 golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= +golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= @@ -179,8 +180,6 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=