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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func SetupHandler() {
}
```

</summary></details>
</details>

<details><summary><code>Chi</code></summary>

Expand All @@ -230,7 +230,7 @@ func SetupHandler() {
}
```

</summary></details>
</details>

<details><summary><code>Gin</code></summary>

Expand Down Expand Up @@ -277,7 +277,7 @@ func SetupHandler() {
}
```

</summary></details>
</details>

<details><summary><code>net/http</code></summary>

Expand All @@ -298,14 +298,14 @@ func SetupHandler() {

Alternatively, [Gorilla](https://github.com/gorilla/mux) is also 100% compatible with `net/http` and can be generated with `-generate gorilla`.

</summary></details>
</details>

<details><summary><code>Iris</code></summary>

Code generated using `-generate iris`.

The usage of `iris` is out of scope of this doc, but once you have an
gin instance, we generate a utility function to help you associate your handlers
iris instance, we generate a utility function to help you associate your handlers
with this autogenerated code. For the pet store, it looks like this:

```go
Expand Down Expand Up @@ -348,7 +348,7 @@ func SetupHandler() {
}
```

</summary></details>
</details>

#### Strict server generation

Expand Down
3 changes: 3 additions & 0 deletions pkg/codegen/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ func (o Configuration) Validate() error {
if o.Generate.EchoServer {
nServers++
}
if o.Generate.GorillaServer {
nServers++
}
if o.Generate.GinServer {
nServers++
}
Expand Down
17 changes: 17 additions & 0 deletions pkg/codegen/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,23 @@ func TestSwaggerUriToFiberUri(t *testing.T) {
assert.Equal(t, "/path/:arg/foo", SwaggerUriToFiberUri("/path/{?arg*}/foo"))
}

func TestSwaggerUriToChiUri(t *testing.T) {
assert.Equal(t, "/path", SwaggerUriToChiUri("/path"))
assert.Equal(t, "/path/{arg}", SwaggerUriToChiUri("/path/{arg}"))
assert.Equal(t, "/path/{arg1}/{arg2}", SwaggerUriToChiUri("/path/{arg1}/{arg2}"))
assert.Equal(t, "/path/{arg1}/{arg2}/foo", SwaggerUriToChiUri("/path/{arg1}/{arg2}/foo"))

// Make sure all the exploded and alternate formats match too
assert.Equal(t, "/path/{arg}/foo", SwaggerUriToChiUri("/path/{arg}/foo"))
assert.Equal(t, "/path/{arg}/foo", SwaggerUriToChiUri("/path/{arg*}/foo"))
assert.Equal(t, "/path/{arg}/foo", SwaggerUriToChiUri("/path/{.arg}/foo"))
assert.Equal(t, "/path/{arg}/foo", SwaggerUriToChiUri("/path/{.arg*}/foo"))
assert.Equal(t, "/path/{arg}/foo", SwaggerUriToChiUri("/path/{;arg}/foo"))
assert.Equal(t, "/path/{arg}/foo", SwaggerUriToChiUri("/path/{;arg*}/foo"))
assert.Equal(t, "/path/{arg}/foo", SwaggerUriToChiUri("/path/{?arg}/foo"))
assert.Equal(t, "/path/{arg}/foo", SwaggerUriToChiUri("/path/{?arg*}/foo"))
}

func TestOrderedParamsFromUri(t *testing.T) {
result := OrderedParamsFromUri("/path/{param1}/{.param2}/{;param3*}/foo")
assert.EqualValues(t, []string{"param1", "param2", "param3"}, result)
Expand Down