12 Commits

Author SHA1 Message Date
Federico Maggi
ef1ac5fd7e Upgrade version to v0.10.1 2025-10-06 15:34:42 +02:00
Federico Maggi
fc597bec00 bump kin openapi version CVE-2025-30153 (#169) 2025-10-06 15:30:34 +02:00
Federico Maggi
eb3c4d9c98 refactor: rename swagger to oas in errors (#165) 2024-11-08 19:52:34 +01:00
Davide Bianchi
3563d41c0f feat: add support to multiple params (#162) 2024-08-07 16:24:59 +02:00
dependabot[bot]
1802f29ad3 chore(deps): bump github.com/gofiber/fiber/v2 from 2.52.4 to 2.52.5 (#159)
Bumps [github.com/gofiber/fiber/v2](https://github.com/gofiber/fiber) from 2.52.4 to 2.52.5.
- [Release notes](https://github.com/gofiber/fiber/releases)
- [Commits](https://github.com/gofiber/fiber/compare/v2.52.4...v2.52.5)

---
updated-dependencies:
- dependency-name: github.com/gofiber/fiber/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-01 11:01:28 +02:00
dependabot[bot]
56651d1029 chore(deps): bump github.com/getkin/kin-openapi from 0.124.0 to 0.125.0 (#158)
Bumps [github.com/getkin/kin-openapi](https://github.com/getkin/kin-openapi) from 0.124.0 to 0.125.0.
- [Release notes](https://github.com/getkin/kin-openapi/releases)
- [Commits](https://github.com/getkin/kin-openapi/compare/v0.124.0...v0.125.0)

---
updated-dependencies:
- dependency-name: github.com/getkin/kin-openapi
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-11 09:31:31 +02:00
Stefano Del Tufo
91f50dd0e4 Added test using enum in request body schema (#157) 2024-04-23 14:29:05 +02:00
dependabot[bot]
a98a205453 chore(deps): bump github.com/labstack/echo/v4 from 4.11.4 to 4.12.0 (#156)
Bumps [github.com/labstack/echo/v4](https://github.com/labstack/echo) from 4.11.4 to 4.12.0.
- [Release notes](https://github.com/labstack/echo/releases)
- [Changelog](https://github.com/labstack/echo/blob/master/CHANGELOG.md)
- [Commits](https://github.com/labstack/echo/compare/v4.11.4...v4.12.0)

---
updated-dependencies:
- dependency-name: github.com/labstack/echo/v4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-23 11:45:47 +02:00
dependabot[bot]
3720da7606 chore(deps): bump github.com/gofiber/fiber/v2 from 2.52.2 to 2.52.4 (#154)
Bumps [github.com/gofiber/fiber/v2](https://github.com/gofiber/fiber) from 2.52.2 to 2.52.4.
- [Release notes](https://github.com/gofiber/fiber/releases)
- [Commits](https://github.com/gofiber/fiber/compare/v2.52.2...v2.52.4)

---
updated-dependencies:
- dependency-name: github.com/gofiber/fiber/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-23 10:27:01 +02:00
dependabot[bot]
fb94293412 chore(deps): bump github.com/getkin/kin-openapi from 0.123.0 to 0.124.0 (#155)
Bumps [github.com/getkin/kin-openapi](https://github.com/getkin/kin-openapi) from 0.123.0 to 0.124.0.
- [Release notes](https://github.com/getkin/kin-openapi/releases)
- [Commits](https://github.com/getkin/kin-openapi/compare/v0.123.0...v0.124.0)

---
updated-dependencies:
- dependency-name: github.com/getkin/kin-openapi
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-08 14:11:34 +02:00
dependabot[bot]
d1f6294d95 chore(deps): bump github.com/stretchr/testify from 1.8.4 to 1.9.0 (#152)
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.4 to 1.9.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](https://github.com/stretchr/testify/compare/v1.8.4...v1.9.0)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-04 10:38:22 +01:00
dependabot[bot]
a828758065 chore(deps): bump github.com/gofiber/fiber/v2 from 2.52.1 to 2.52.2 (#151)
Bumps [github.com/gofiber/fiber/v2](https://github.com/gofiber/fiber) from 2.52.1 to 2.52.2.
- [Release notes](https://github.com/gofiber/fiber/releases)
- [Commits](https://github.com/gofiber/fiber/compare/v2.52.1...v2.52.2)

---
updated-dependencies:
- dependency-name: github.com/gofiber/fiber/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-04 10:38:14 +01:00
34 changed files with 296 additions and 182 deletions

View File

@@ -9,10 +9,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go_version: ['1.20', '1.21']
go_version: ['1.24', '1.25']
os: [ubuntu-latest]
include:
- go_version: '1.21'
- go_version: '1.25'
os: macos-latest
steps:
- uses: actions/checkout@v1

View File

@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
## 0.10.1 - 06-10-2025
### Refactor
- renamed swagger to openapi in error messages
## 0.10.0 - 28-02-2024
### BREAKING CHANGES

28
go.mod
View File

@@ -1,20 +1,15 @@
module github.com/davidebianchi/gswagger
go 1.20
go 1.24
require (
github.com/getkin/kin-openapi v0.123.0
github.com/getkin/kin-openapi v0.131.0
github.com/ghodss/yaml v1.0.0
github.com/go-openapi/swag v0.22.8 // indirect
github.com/gofiber/fiber/v2 v2.52.5
github.com/gorilla/mux v1.8.1
github.com/labstack/echo/v4 v4.11.4
github.com/mailru/easyjson v0.7.7 // indirect
github.com/stretchr/testify v1.8.4
)
require (
github.com/gofiber/fiber/v2 v2.52.1
github.com/invopop/jsonschema v0.12.0
github.com/labstack/echo/v4 v4.12.0
github.com/stretchr/testify v1.9.0
)
require (
@@ -22,16 +17,19 @@ require (
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/invopop/yaml v0.2.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
@@ -40,9 +38,9 @@ require (
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect

49
go.sum
View File

@@ -6,33 +6,34 @@ github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMU
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
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/getkin/kin-openapi v0.123.0 h1:zIik0mRwFNLyvtXK274Q6ut+dPh6nlxBp0x7mNrPhs8=
github.com/getkin/kin-openapi v0.123.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM=
github.com/getkin/kin-openapi v0.131.0 h1:NO2UeHnFKRYhZ8wg6Nyh5Cq7dHk4suQQr72a4pMrDxE=
github.com/getkin/kin-openapi v0.131.0/go.mod h1:3OlG51PCYNsPByuiMB0t4fjnNlIDnaEDsjiKUV8nL58=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-openapi/jsonpointer v0.20.2 h1:mQc3nmndL8ZBzStEo3JYF8wzmeWffDH4VbXz58sAx6Q=
github.com/go-openapi/jsonpointer v0.20.2/go.mod h1:bHen+N0u1KEO3YlmqOjTT9Adn1RfD91Ar825/PuiRVs=
github.com/go-openapi/swag v0.22.8 h1:/9RjDSQ0vbFR+NyjGMkFTsA1IA0fmhKSThmfGZjicbw=
github.com/go-openapi/swag v0.22.8/go.mod h1:6QT22icPLEqAM/z/TChgb4WAveCHF92+2gF0CNjHpPI=
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
github.com/gofiber/fiber/v2 v2.52.1 h1:1RoU2NS+b98o1L77sdl5mboGPiW+0Ypsi5oLmcYlgHI=
github.com/gofiber/fiber/v2 v2.52.1/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/gofiber/fiber/v2 v2.52.5 h1:tWoP1MJQjGEe4GB5TUGOi7P2E0ZMMRx5ZTG4rT+yGMo=
github.com/gofiber/fiber/v2 v2.52.5/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI=
github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
github.com/invopop/yaml v0.2.0 h1:7zky/qH+O0DwAyoobXUqvVBwgBFRxKoQ/3FjcVpjTMY=
github.com/invopop/yaml v0.2.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM=
github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/labstack/echo/v4 v4.11.4 h1:vDZmA+qNeh1pd/cCkEicDMrjtrnMGQ1QFI9gWN1zGq8=
github.com/labstack/echo/v4 v4.11.4/go.mod h1:noh7EvLwqDsmh/X/HWKPUl1AjzJrhyptRyEbQJfxen8=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0=
github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM=
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
@@ -46,6 +47,10 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 h1:G7ERwszslrBzRxj//JalHPu/3yz+De2J+4aLtSRlHiY=
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037/go.mod h1:2bpvgLBZEtENV5scfDFEtB/5+1M4hkQhDQrccEJ/qGw=
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 h1:bQx3WeLcUWy+RletIKwUIt4x3t8n2SxavmoclizMb8c=
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90/go.mod h1:y5+oSEHCPT/DGrS++Wc/479ERge0zTFxaF8PbGKcg2o=
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=
github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -53,9 +58,11 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
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=
@@ -66,20 +73,20 @@ github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVS
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
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/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

61
main.go
View File

@@ -13,21 +13,26 @@ import (
)
var (
// ErrGenerateSwagger throws when fails the marshalling of the swagger struct.
ErrGenerateSwagger = errors.New("fail to generate swagger")
// ErrValidatingSwagger throws when given swagger params are not correct.
ErrValidatingSwagger = errors.New("fails to validate swagger")
// ErrGenerateOAS throws when fails the marshalling of the swagger struct.
ErrGenerateOAS = errors.New("fail to generate openapi")
// ErrValidatingOAS throws when given openapi params are not correct.
ErrValidatingOAS = errors.New("fails to validate openapi")
// Deprecated: ErrGenerateSwagger has been deprecated, use ErrGenerateOAS instead.
ErrGenerateSwagger = ErrGenerateOAS
// Deprecated: ErrValidatingSwagger has been deprecated, use ErrValidatingOAS instead.
ErrValidatingSwagger = ErrValidatingOAS
)
const (
// DefaultJSONDocumentationPath is the path of the swagger documentation in json format.
// DefaultJSONDocumentationPath is the path of the openapi documentation in json format.
DefaultJSONDocumentationPath = "/documentation/json"
// DefaultYAMLDocumentationPath is the path of the swagger documentation in yaml format.
// DefaultYAMLDocumentationPath is the path of the openapi documentation in yaml format.
DefaultYAMLDocumentationPath = "/documentation/yaml"
defaultOpenapiVersion = "3.0.0"
)
// Router handle the api router and the swagger schema.
// Router handle the api router and the openapi schema.
// api router supported out of the box are:
// - gorilla mux
type Router[HandlerFunc, Route any] struct {
@@ -51,11 +56,11 @@ type Options struct {
PathPrefix string
}
// NewRouter generate new router with swagger. Default to OpenAPI 3.0.0
// NewRouter generate new router with openapi. Default to OpenAPI 3.0.0
func NewRouter[HandlerFunc, Route any](router apirouter.Router[HandlerFunc, Route], options Options) (*Router[HandlerFunc, Route], error) {
swagger, err := generateNewValidOpenapi(options.Openapi)
openapi, err := generateNewValidOpenapi(options.Openapi)
if err != nil {
return nil, fmt.Errorf("%w: %s", ErrValidatingSwagger, err)
return nil, fmt.Errorf("%w: %s", ErrValidatingOAS, err)
}
var ctx = options.Context
@@ -81,7 +86,7 @@ func NewRouter[HandlerFunc, Route any](router apirouter.Router[HandlerFunc, Rout
return &Router[HandlerFunc, Route]{
router: router,
swaggerSchema: swagger,
swaggerSchema: openapi,
context: ctx,
yamlDocumentationPath: yamlDocumentationPath,
jsonDocumentationPath: jsonDocumentationPath,
@@ -104,46 +109,46 @@ func (r Router[HandlerFunc, Route]) SubRouter(router apirouter.Router[HandlerFun
}, nil
}
func generateNewValidOpenapi(swagger *openapi3.T) (*openapi3.T, error) {
if swagger == nil {
return nil, fmt.Errorf("swagger is required")
func generateNewValidOpenapi(openapi *openapi3.T) (*openapi3.T, error) {
if openapi == nil {
return nil, fmt.Errorf("openapi is required")
}
if swagger.OpenAPI == "" {
swagger.OpenAPI = defaultOpenapiVersion
if openapi.OpenAPI == "" {
openapi.OpenAPI = defaultOpenapiVersion
}
if swagger.Paths == nil {
swagger.Paths = &openapi3.Paths{}
if openapi.Paths == nil {
openapi.Paths = &openapi3.Paths{}
}
if swagger.Info == nil {
return nil, fmt.Errorf("swagger info is required")
if openapi.Info == nil {
return nil, fmt.Errorf("openapi info is required")
}
if swagger.Info.Title == "" {
return nil, fmt.Errorf("swagger info title is required")
if openapi.Info.Title == "" {
return nil, fmt.Errorf("openapi info title is required")
}
if swagger.Info.Version == "" {
return nil, fmt.Errorf("swagger info version is required")
if openapi.Info.Version == "" {
return nil, fmt.Errorf("openapi info version is required")
}
return swagger, nil
return openapi, nil
}
// GenerateAndExposeOpenapi creates a /documentation/json route on router and
// expose the generated swagger
func (r Router[_, _]) GenerateAndExposeOpenapi() error {
if err := r.swaggerSchema.Validate(r.context); err != nil {
return fmt.Errorf("%w: %s", ErrValidatingSwagger, err)
return fmt.Errorf("%w: %s", ErrValidatingOAS, err)
}
jsonSwagger, err := r.swaggerSchema.MarshalJSON()
if err != nil {
return fmt.Errorf("%w json marshal: %s", ErrGenerateSwagger, err)
return fmt.Errorf("%w json marshal: %s", ErrGenerateOAS, err)
}
r.router.AddRoute(http.MethodGet, r.jsonDocumentationPath, r.router.SwaggerHandler("application/json", jsonSwagger))
yamlSwagger, err := yaml.JSONToYAML(jsonSwagger)
if err != nil {
return fmt.Errorf("%w yaml marshal: %s", ErrGenerateSwagger, err)
return fmt.Errorf("%w yaml marshal: %s", ErrGenerateOAS, err)
}
r.router.AddRoute(http.MethodGet, r.yamlDocumentationPath, r.router.SwaggerHandler("text/plain", yamlSwagger))

View File

@@ -33,7 +33,7 @@ func TestNewRouter(t *testing.T) {
r, err := NewRouter(mAPIRouter, Options{})
require.Nil(t, r)
require.EqualError(t, err, fmt.Sprintf("%s: swagger is required", ErrValidatingSwagger))
require.EqualError(t, err, fmt.Sprintf("%s: openapi is required", ErrValidatingOAS))
})
t.Run("ok - with default context", func(t *testing.T) {
@@ -119,50 +119,50 @@ func TestNewRouter(t *testing.T) {
}
func TestGenerateValidSwagger(t *testing.T) {
t.Run("not ok - empty swagger info", func(t *testing.T) {
swagger := &openapi3.T{}
t.Run("not ok - empty openapi info", func(t *testing.T) {
openapi := &openapi3.T{}
swagger, err := generateNewValidOpenapi(swagger)
require.Nil(t, swagger)
require.EqualError(t, err, "swagger info is required")
openapi, err := generateNewValidOpenapi(openapi)
require.Nil(t, openapi)
require.EqualError(t, err, "openapi info is required")
})
t.Run("not ok - empty info title", func(t *testing.T) {
swagger := &openapi3.T{
openapi := &openapi3.T{
Info: &openapi3.Info{},
}
swagger, err := generateNewValidOpenapi(swagger)
require.Nil(t, swagger)
require.EqualError(t, err, "swagger info title is required")
openapi, err := generateNewValidOpenapi(openapi)
require.Nil(t, openapi)
require.EqualError(t, err, "openapi info title is required")
})
t.Run("not ok - empty info version", func(t *testing.T) {
swagger := &openapi3.T{
openapi := &openapi3.T{
Info: &openapi3.Info{
Title: "title",
},
}
swagger, err := generateNewValidOpenapi(swagger)
require.Nil(t, swagger)
require.EqualError(t, err, "swagger info version is required")
openapi, err := generateNewValidOpenapi(openapi)
require.Nil(t, openapi)
require.EqualError(t, err, "openapi info version is required")
})
t.Run("ok - custom swagger", func(t *testing.T) {
swagger := &openapi3.T{
t.Run("ok - custom openapi", func(t *testing.T) {
openapi := &openapi3.T{
Info: &openapi3.Info{},
}
swagger, err := generateNewValidOpenapi(swagger)
require.Nil(t, swagger)
require.EqualError(t, err, "swagger info title is required")
openapi, err := generateNewValidOpenapi(openapi)
require.Nil(t, openapi)
require.EqualError(t, err, "openapi info title is required")
})
t.Run("not ok - swagger is required", func(t *testing.T) {
swagger, err := generateNewValidOpenapi(nil)
require.Nil(t, swagger)
require.EqualError(t, err, "swagger is required")
t.Run("not ok - openapi is required", func(t *testing.T) {
openapi, err := generateNewValidOpenapi(nil)
require.Nil(t, openapi)
require.EqualError(t, err, "openapi is required")
})
t.Run("ok", func(t *testing.T) {
@@ -170,22 +170,22 @@ func TestGenerateValidSwagger(t *testing.T) {
Title: "my title",
Version: "my version",
}
swagger := &openapi3.T{
openapi := &openapi3.T{
Info: info,
}
swagger, err := generateNewValidOpenapi(swagger)
openapi, err := generateNewValidOpenapi(openapi)
require.NoError(t, err)
require.Equal(t, &openapi3.T{
OpenAPI: defaultOpenapiVersion,
Info: info,
Paths: &openapi3.Paths{},
}, swagger)
}, openapi)
})
}
func TestGenerateAndExposeSwagger(t *testing.T) {
t.Run("fails swagger validation", func(t *testing.T) {
t.Run("fails openapi validation", func(t *testing.T) {
mRouter := mux.NewRouter()
router, err := NewRouter(gorilla.NewRouter(mRouter), Options{
Openapi: &openapi3.T{
@@ -204,17 +204,17 @@ func TestGenerateAndExposeSwagger(t *testing.T) {
err = router.GenerateAndExposeOpenapi()
require.Error(t, err)
require.True(t, strings.HasPrefix(err.Error(), fmt.Sprintf("%s:", ErrValidatingSwagger)))
require.True(t, strings.HasPrefix(err.Error(), fmt.Sprintf("%s:", ErrValidatingOAS)))
})
t.Run("correctly expose json documentation from loaded swagger file", func(t *testing.T) {
t.Run("correctly expose json documentation from loaded openapi file", func(t *testing.T) {
mRouter := mux.NewRouter()
swagger, err := openapi3.NewLoader().LoadFromFile("testdata/users_employees.json")
openapi, err := openapi3.NewLoader().LoadFromFile("testdata/users_employees.json")
require.NoError(t, err)
router, err := NewRouter(gorilla.NewRouter(mRouter), Options{
Openapi: swagger,
Openapi: openapi,
})
require.NoError(t, err)
@@ -234,14 +234,14 @@ func TestGenerateAndExposeSwagger(t *testing.T) {
require.JSONEq(t, string(actual), body)
})
t.Run("correctly expose json documentation from loaded swagger file - custom path", func(t *testing.T) {
t.Run("correctly expose json documentation from loaded openapi file - custom path", func(t *testing.T) {
mRouter := mux.NewRouter()
swagger, err := openapi3.NewLoader().LoadFromFile("testdata/users_employees.json")
openapi, err := openapi3.NewLoader().LoadFromFile("testdata/users_employees.json")
require.NoError(t, err)
router, err := NewRouter(gorilla.NewRouter(mRouter), Options{
Openapi: swagger,
Openapi: openapi,
JSONDocumentationPath: "/custom/path",
})
require.NoError(t, err)
@@ -262,14 +262,14 @@ func TestGenerateAndExposeSwagger(t *testing.T) {
require.JSONEq(t, string(actual), body)
})
t.Run("correctly expose yaml documentation from loaded swagger file", func(t *testing.T) {
t.Run("correctly expose yaml documentation from loaded openapi file", func(t *testing.T) {
mRouter := mux.NewRouter()
swagger, err := openapi3.NewLoader().LoadFromFile("testdata/users_employees.json")
openapi, err := openapi3.NewLoader().LoadFromFile("testdata/users_employees.json")
require.NoError(t, err)
router, err := NewRouter(gorilla.NewRouter(mRouter), Options{
Openapi: swagger,
Openapi: openapi,
})
require.NoError(t, err)
@@ -289,14 +289,14 @@ func TestGenerateAndExposeSwagger(t *testing.T) {
require.YAMLEq(t, string(expected), body, string(body))
})
t.Run("correctly expose yaml documentation from loaded swagger file - custom path", func(t *testing.T) {
t.Run("correctly expose yaml documentation from loaded openapi file - custom path", func(t *testing.T) {
mRouter := mux.NewRouter()
swagger, err := openapi3.NewLoader().LoadFromFile("testdata/users_employees.json")
openapi, err := openapi3.NewLoader().LoadFromFile("testdata/users_employees.json")
require.NoError(t, err)
router, err := NewRouter(gorilla.NewRouter(mRouter), Options{
Openapi: swagger,
Openapi: openapi,
YAMLDocumentationPath: "/custom/path",
})
require.NoError(t, err)
@@ -323,8 +323,8 @@ func TestGenerateAndExposeSwagger(t *testing.T) {
router, err := NewRouter(gorilla.NewRouter(mRouter), Options{
Openapi: &openapi3.T{
Info: &openapi3.Info{
Title: "test swagger title",
Version: "test swagger version",
Title: "test openapi title",
Version: "test openapi version",
},
},
JSONDocumentationPath: "/custom/path",
@@ -402,8 +402,8 @@ func TestGenerateAndExposeSwagger(t *testing.T) {
router, err := NewRouter(gorilla.NewRouter(mRouter), Options{
Openapi: &openapi3.T{
Info: &openapi3.Info{
Title: "test swagger title",
Version: "test swagger version",
Title: "test openapi title",
Version: "test openapi version",
},
},
JSONDocumentationPath: "/custom/path",

View File

@@ -27,7 +27,7 @@ func TestNewOperation(t *testing.T) {
operation.Responses = openapi3.NewResponses()
return operation
},
expectedJSON: `{"info":{"title":"test swagger title","version":"test swagger version"},"openapi":"3.0.0","paths":{"/":{"post":{"requestBody":{"content":{"application/json":{"schema":{"properties":{"bar":{"maximum":15,"minimum":5,"type":"integer"},"foo":{"type":"string"}},"type":"object"}}}},"responses":{"default":{"description":""}}}}}}`,
expectedJSON: `{"info":{"title":"test openapi title","version":"test openapi version"},"openapi":"3.0.0","paths":{"/":{"post":{"requestBody":{"content":{"application/json":{"schema":{"properties":{"bar":{"maximum":15,"minimum":5,"type":"integer"},"foo":{"type":"string"}},"type":"object"}}}},"responses":{"default":{"description":""}}}}}}`,
},
{
name: "add response",
@@ -36,19 +36,19 @@ func TestNewOperation(t *testing.T) {
operation.AddResponse(200, response)
return operation
},
expectedJSON: `{"info":{"title":"test swagger title","version":"test swagger version"},"openapi":"3.0.0","paths":{"/":{"post":{"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"bar":{"maximum":15,"minimum":5,"type":"integer"},"foo":{"type":"string"}},"type":"object"}}},"description":""}}}}}}`,
expectedJSON: `{"info":{"title":"test openapi title","version":"test openapi version"},"openapi":"3.0.0","paths":{"/":{"post":{"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"bar":{"maximum":15,"minimum":5,"type":"integer"},"foo":{"type":"string"}},"type":"object"}}},"description":""}}}}}}`,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
swagger := getBaseSwagger(t)
swagger.OpenAPI = "3.0.0"
openapi := getBaseSwagger(t)
openapi.OpenAPI = "3.0.0"
operation := test.getOperation(t, NewOperation())
swagger.AddOperation("/", http.MethodPost, operation.Operation)
openapi.AddOperation("/", http.MethodPost, operation.Operation)
data, _ := swagger.MarshalJSON()
data, _ := openapi.MarshalJSON()
jsonData := string(data)
require.JSONEq(t, test.expectedJSON, jsonData, "actual json data: %s", jsonData)
})

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"path"
"regexp"
"sort"
"strings"
@@ -23,7 +24,7 @@ var (
)
// AddRawRoute add route to router with specific method, path and handler. Add the
// router also to the swagger schema, after validating it
// router also to the openapi schema, after validating it
func (r Router[HandlerFunc, Route]) AddRawRoute(method string, routePath string, handler HandlerFunc, operation Operation) (Route, error) {
op := operation.Operation
if op != nil {
@@ -289,15 +290,18 @@ func (r Router[_, _]) addContentToOASSchema(content Content) (openapi3.Content,
func getPathParamsAutoComplete(schema Definitions, path string) ParameterValue {
if schema.PathParams == nil {
pathParams := strings.Split(path, "/")
for _, param := range pathParams {
if strings.HasPrefix(param, "{") && strings.HasSuffix(param, "}") {
if schema.PathParams == nil {
schema.PathParams = make(ParameterValue)
}
param = strings.Replace(param, "{", "", 1)
param = strings.Replace(param, "}", "", 1)
schema.PathParams[param] = Parameter{
re := regexp.MustCompile(`\{([^}]+)\}`)
segments := strings.Split(path, "/")
for _, segment := range segments {
params := re.FindAllStringSubmatch(segment, -1)
if len(params) == 0 {
continue
}
if schema.PathParams == nil {
schema.PathParams = make(ParameterValue)
}
for _, param := range params {
schema.PathParams[param[1]] = Parameter{
Schema: &Schema{Value: ""},
}
}

View File

@@ -48,6 +48,7 @@ func TestAddRoutes(t *testing.T) {
FirstName string `json:"firstName" jsonschema:"title=user first name"`
LastName string `json:"lastName" jsonschema:"title=user last name"`
Metadata interface{} `json:"metadata,omitempty" jsonschema:"title=custom properties,oneof_type=string;number"`
UserType string `json:"userType,omitempty" jsonschema:"title=type of user,enum=simple,enum=advanced"`
}
okHandler := func(w http.ResponseWriter, req *http.Request) {
@@ -186,7 +187,7 @@ func TestAddRoutes(t *testing.T) {
fixturesPath: "testdata/params.json",
},
{
name: "schema without params autofilled",
name: "schema without explicit params autofill them",
routes: func(t *testing.T, router *TestRouter) {
_, err := router.AddRoute(http.MethodGet, "/users/{userId}", okHandler, Definitions{
Querystring: ParameterValue{
@@ -199,8 +200,11 @@ func TestAddRoutes(t *testing.T) {
_, err = router.AddRoute(http.MethodGet, "/cars/{carId}/drivers/{driverId}", okHandler, Definitions{})
require.NoError(t, err)
_, err = router.AddRoute(http.MethodGet, "/files/{name}.{extension}", okHandler, Definitions{})
require.NoError(t, err)
},
testPath: "/users/12",
testPath: "/files/myid.yaml",
fixturesPath: "testdata/params-autofill.json",
},
{
@@ -376,7 +380,7 @@ func TestAddRoutes(t *testing.T) {
fixturesPath: "testdata/anyof.json",
},
{
name: "oneOf support on properties",
name: "oneOf and enum are supported on properties",
routes: func(t *testing.T, router *TestRouter) {
_, err := router.AddRoute(http.MethodPost, "/user-profile", okHandler, Definitions{
RequestBody: &ContentValue{
@@ -529,7 +533,7 @@ func TestAddRoutes(t *testing.T) {
require.Equal(t, "OK", body)
}
t.Run("and generate swagger documentation in json", func(t *testing.T) {
t.Run("and generate openapi documentation in json", func(t *testing.T) {
w := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, DefaultJSONDocumentationPath, nil)
@@ -1112,8 +1116,66 @@ func getBaseSwagger(t *testing.T) *openapi3.T {
return &openapi3.T{
Info: &openapi3.Info{
Title: "test swagger title",
Version: "test swagger version",
Title: "test openapi title",
Version: "test openapi version",
},
}
}
func TestGetPathParamsAutoComplete(t *testing.T) {
testCases := map[string]struct {
schemaDefinition Definitions
path string
expected ParameterValue
}{
"no path params": {
schemaDefinition: Definitions{},
path: "/users",
expected: nil,
},
"with path params": {
schemaDefinition: Definitions{},
path: "/users/{userId}",
expected: ParameterValue{
"userId": {
Schema: &Schema{Value: ""},
},
},
},
"with multiple path params": {
schemaDefinition: Definitions{},
path: "/foo/{bar}.{taz}",
expected: ParameterValue{
"bar": {
Schema: &Schema{Value: ""},
},
"taz": {
Schema: &Schema{Value: ""},
},
},
},
"with nested multiple path params": {
schemaDefinition: Definitions{},
path: "/foo/{bar}.{taz}/{baz}/ok",
expected: ParameterValue{
"bar": {
Schema: &Schema{Value: ""},
},
"taz": {
Schema: &Schema{Value: ""},
},
"baz": {
Schema: &Schema{Value: ""},
},
},
},
}
for name, test := range testCases {
t.Run(name, func(t *testing.T) {
actual := getPathParamsAutoComplete(test.schemaDefinition, test.path)
require.Equal(t, test.expected, actual)
})
}
}

View File

@@ -17,8 +17,8 @@ import (
)
const (
swaggerOpenapiTitle = "test swagger title"
swaggerOpenapiVersion = "test swagger version"
swaggerOpenapiTitle = "test openapi title"
swaggerOpenapiVersion = "test openapi version"
)
type echoSwaggerRouter = swagger.Router[echo.HandlerFunc, *echo.Route]

View File

@@ -19,8 +19,8 @@ import (
type SwaggerRouter = swagger.Router[oasFiber.HandlerFunc, oasFiber.Route]
const (
swaggerOpenapiTitle = "test swagger title"
swaggerOpenapiVersion = "test swagger version"
swaggerOpenapiTitle = "test openapi title"
swaggerOpenapiVersion = "test openapi version"
)
func TestFiberIntegration(t *testing.T) {

View File

@@ -16,8 +16,8 @@ import (
)
const (
swaggerOpenapiTitle = "test swagger title"
swaggerOpenapiVersion = "test swagger version"
swaggerOpenapiTitle = "test openapi title"
swaggerOpenapiVersion = "test openapi version"
)
type SwaggerRouter = swagger.Router[gorilla.HandlerFunc, gorilla.Route]

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

4
testdata/allof.json vendored
View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

4
testdata/anyof.json vendored
View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

4
testdata/empty.json vendored
View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {}

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

9
testdata/oneOf.json vendored
View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {
@@ -78,6 +78,11 @@
}
],
"title": "custom properties"
},
"userType": {
"title": "type of user",
"type": "string",
"enum": ["simple", "advanced"]
}
},
"required": [

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {
@@ -57,6 +57,33 @@
}
}
}
},
"/files/{name}.{extension}": {
"get": {
"parameters": [
{
"in": "path",
"name": "extension",
"required": true,
"schema": {
"type": "string"
}
},
{
"in": "path",
"name": "name",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"default": {
"description": ""
}
}
}
}
}
}

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

4
testdata/query.json vendored
View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

4
testdata/tags.json vendored
View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

View File

@@ -1,7 +1,7 @@
{
"info": {
"title": "test swagger title",
"version": "test swagger version"
"title": "test openapi title",
"version": "test openapi version"
},
"openapi": "3.0.0",
"paths": {

View File

@@ -1,6 +1,6 @@
info:
title: test swagger title
version: test swagger version
title: test openapi title
version: test openapi version
openapi: 3.0.0
paths:
/employees: