Skip to content

Commit

Permalink
Rename module post-move (oapi-codegen#1643)
Browse files Browse the repository at this point in the history
* Rename module post-move

* Regenerate boilerplate

* Make tidy

* Add CODEOWNERS
  • Loading branch information
mromaszewicz authored Jun 5, 2024
1 parent 2f0ff75 commit c734650
Show file tree
Hide file tree
Showing 280 changed files with 384 additions and 381 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @oapi-codegen/maintainers
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ This would give you a `tools/tools.go`:
package main

import (
_ "github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen"
_ "github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen"
)
```

Then, each invocation of `oapi-codegen` would be used like so:

```go
//go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml ../../api.yaml
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml ../../api.yaml
```

Alternatively, you can install it as a binary with:

```sh
$ go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@latest
$ go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
$ oapi-codegen -version
```

Expand All @@ -64,9 +64,9 @@ To do so, you can run:

```sh
# pin to the latest version on the default branch
$ go get github.com/deepmap/oapi-codegen/v2@master
$ go get github.com/oapi-codegen/oapi-codegen/v2@master
# alternatively, to a commit hash i.e. https://github.com/deepmap/oapi-codegen/commit/71e916c59688a6379b5774dfe5904ec222b9a537
$ go get github.com/deepmap/oapi-codegen/v2@71e916c59688a6379b5774dfe5904ec222b9a537
$ go get github.com/oapi-codegen/oapi-codegen/v2@71e916c59688a6379b5774dfe5904ec222b9a537
```

This will then make a change such as:
Expand All @@ -77,15 +77,15 @@ index 44f29a4..436a780 100644
--- go.mod
+++ go.mod
@@ -2,21 +2,20 @@
-require github.com/deepmap/oapi-codegen/v2 v2.1.0
+require github.com/deepmap/oapi-codegen/v2 v2.1.1-0.20240331212514-80f0b978ef16
-require github.com/oapi-codegen/oapi-codegen/v2 v2.1.0
+require github.com/oapi-codegen/oapi-codegen/v2 v2.1.1-0.20240331212514-80f0b978ef16
```

## Usage

`oapi-codegen` is largely configured using a YAML configuration file, to simplify the number of flags that users need to remember, and to make reading the `go:generate` command less daunting.

For full details of what is supported, it's worth checking out [the GoDoc for `codegen.Configuration`](https://pkg.go.dev/github.com/deepmap/oapi-codegen/v2/pkg/codegen#Configuration).
For full details of what is supported, it's worth checking out [the GoDoc for `codegen.Configuration`](https://pkg.go.dev/github.com/oapi-codegen/oapi-codegen/v2/pkg/codegen#Configuration).

We also have [a JSON Schema](configuration-schema.json) that can be used by IDEs/editors with the Language Server Protocol (LSP) to perform intelligent suggestions, i.e.:

Expand All @@ -99,7 +99,7 @@ package: api

Although we strive to retain backwards compatibility - as a project that's using a stable API per SemVer - there are sometimes opportunities we must take to fix a bug that could cause a breaking change for [people relying upon the behaviour](https://xkcd.com/1172/).

In this case, we will expose a [compatibility option](https://pkg.go.dev/github.com/deepmap/oapi-codegen/v2/pkg/codegen#CompatibilityOptions) to restore old behaviour.
In this case, we will expose a [compatibility option](https://pkg.go.dev/github.com/oapi-codegen/oapi-codegen/v2/pkg/codegen#CompatibilityOptions) to restore old behaviour.

## Features

Expand Down Expand Up @@ -679,7 +679,7 @@ import (
"log"
"net/http"

"github.com/deepmap/oapi-codegen/v2/examples/minimal-server/stdhttp/api"
"github.com/oapi-codegen/oapi-codegen/v2/examples/minimal-server/stdhttp/api"
)

func main() {
Expand Down Expand Up @@ -816,7 +816,7 @@ import (
"log"
"net/http"

"github.com/deepmap/oapi-codegen/v2/examples/minimal-server/chi/api"
"github.com/oapi-codegen/oapi-codegen/v2/examples/minimal-server/chi/api"
"github.com/go-chi/chi/v5"
)

Expand Down Expand Up @@ -943,7 +943,7 @@ import (
"log"
"net/http"

"github.com/deepmap/oapi-codegen/v2/examples/minimal-server/gorillamux/api"
"github.com/oapi-codegen/oapi-codegen/v2/examples/minimal-server/gorillamux/api"
"github.com/gorilla/mux"
)

Expand Down Expand Up @@ -1074,7 +1074,7 @@ Now we've got our implementation, we can then write the following code to wire i
import (
"log"

"github.com/deepmap/oapi-codegen/v2/examples/minimal-server/echo/api"
"github.com/oapi-codegen/oapi-codegen/v2/examples/minimal-server/echo/api"
"github.com/labstack/echo/v4"
)

Expand Down Expand Up @@ -1191,7 +1191,7 @@ Now we've got our implementation, we can then write the following code to wire i
import (
"log"

"github.com/deepmap/oapi-codegen/v2/examples/minimal-server/fiber/api"
"github.com/oapi-codegen/oapi-codegen/v2/examples/minimal-server/fiber/api"
"github.com/gofiber/fiber/v2"
)

Expand Down Expand Up @@ -1306,7 +1306,7 @@ import (
"log"
"net/http"

"github.com/deepmap/oapi-codegen/v2/examples/minimal-server/gin/api"
"github.com/oapi-codegen/oapi-codegen/v2/examples/minimal-server/gin/api"
"github.com/gin-gonic/gin"
)

Expand Down Expand Up @@ -1430,7 +1430,7 @@ Now we've got our implementation, we can then write the following code to wire i
import (
"log"

"github.com/deepmap/oapi-codegen/v2/examples/minimal-server/iris/api"
"github.com/oapi-codegen/oapi-codegen/v2/examples/minimal-server/iris/api"
"github.com/kataras/iris/v12"
)

Expand Down Expand Up @@ -1565,7 +1565,7 @@ And a `generate.go`:
```go
package client
//go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen -config cfg.yaml api.yaml
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen -config cfg.yaml api.yaml
```

This would then generate:
Expand Down Expand Up @@ -1641,7 +1641,7 @@ import (
"log"
"net/http"

"github.com/deepmap/oapi-codegen/v2/examples/client"
"github.com/oapi-codegen/oapi-codegen/v2/examples/client"
)

func TestClient_canCall() {
Expand Down Expand Up @@ -1764,7 +1764,7 @@ And a `generate.go`:
```go
package onlymodels
//go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen -config cfg.yaml api.yaml
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen -config cfg.yaml api.yaml
```

This would then generate:
Expand Down Expand Up @@ -1903,7 +1903,7 @@ output-options:
skip-prune: true
import-mapping:
# for a given file/URL that is $ref'd, point `oapi-codegen` to the Go package that this spec is generated into, to perform Go package imports
../common/api.yaml: github.com/deepmap/oapi-codegen/v2/examples/import-mapping/common
../common/api.yaml: github.com/oapi-codegen/oapi-codegen/v2/examples/import-mapping/common
```
This will then generate the following code:
Expand All @@ -1913,7 +1913,7 @@ package admin

import (
// ...
externalRef0 "github.com/deepmap/oapi-codegen/v2/examples/import-mapping/common"
externalRef0 "github.com/oapi-codegen/oapi-codegen/v2/examples/import-mapping/common"
)

// User defines model for User.
Expand Down Expand Up @@ -2873,7 +2873,7 @@ import (
"fmt"
"log"

"github.com/deepmap/oapi-codegen/v2/pkg/securityprovider"
"github.com/oapi-codegen/oapi-codegen/v2/pkg/securityprovider"
)

func main() {
Expand All @@ -2895,7 +2895,7 @@ func main() {
}
```

Notice that we're using a pre-built provider from the [`pkg/securityprovider` package](https://pkg.go.dev/github.com/deepmap/oapi-codegen/v2/pkg/securityprovider), which has some inbuilt support for other types of authentication, too.
Notice that we're using a pre-built provider from the [`pkg/securityprovider` package](https://pkg.go.dev/github.com/oapi-codegen/oapi-codegen/v2/pkg/securityprovider), which has some inbuilt support for other types of authentication, too.

## Custom code generation

Expand Down Expand Up @@ -3853,7 +3853,7 @@ output-options:
exclude-schemas: []
```
Check [the docs](https://pkg.go.dev/github.com/deepmap/oapi-codegen/v2/pkg/codegen#OutputOptions) for more details of usage.
Check [the docs](https://pkg.go.dev/github.com/oapi-codegen/oapi-codegen/v2/pkg/codegen#OutputOptions) for more details of usage.
### Should I commit the generated code?
Expand Down
4 changes: 2 additions & 2 deletions cmd/oapi-codegen/oapi-codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (

"gopkg.in/yaml.v2"

"github.com/deepmap/oapi-codegen/v2/pkg/codegen"
"github.com/deepmap/oapi-codegen/v2/pkg/util"
"github.com/oapi-codegen/oapi-codegen/v2/pkg/codegen"
"github.com/oapi-codegen/oapi-codegen/v2/pkg/util"
)

func errExit(format string, args ...interface{}) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/oapi-codegen/oapi-codegen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"testing"

"github.com/deepmap/oapi-codegen/v2/pkg/util"
"github.com/oapi-codegen/oapi-codegen/v2/pkg/util"
)

func TestLoader(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion examples/anyof-allof-oneof/anyofallofoneof.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/anyof-allof-oneof/generate.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package anyofallofoneof

//go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen -config cfg.yaml api.yaml
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen -config cfg.yaml api.yaml
2 changes: 1 addition & 1 deletion examples/authenticated-api/echo/api/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/authenticated-api/echo/api/doc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package api

//go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml ../../api.yaml
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml ../../api.yaml
4 changes: 2 additions & 2 deletions examples/authenticated-api/echo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"log"
"net"

"github.com/deepmap/oapi-codegen/v2/examples/authenticated-api/echo/api"
"github.com/deepmap/oapi-codegen/v2/examples/authenticated-api/echo/server"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/oapi-codegen/oapi-codegen/v2/examples/authenticated-api/echo/api"
"github.com/oapi-codegen/oapi-codegen/v2/examples/authenticated-api/echo/server"
)

func main() {
Expand Down
5 changes: 3 additions & 2 deletions examples/authenticated-api/echo/server/fake_jws.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import (
"crypto/ecdsa"
"fmt"

"github.com/deepmap/oapi-codegen/v2/pkg/ecdsafile"
"github.com/lestrrat-go/jwx/jwa"
"github.com/lestrrat-go/jwx/jwk"
"github.com/lestrrat-go/jwx/jws"
"github.com/lestrrat-go/jwx/jwt"
"github.com/oapi-codegen/oapi-codegen/v2/pkg/ecdsafile"
)

// PrivateKey is an ECDSA private key which was generated with the following
// command:
// openssl ecparam -name prime256v1 -genkey -noout -out ecprivatekey.pem
//
// openssl ecparam -name prime256v1 -genkey -noout -out ecprivatekey.pem
//
// We are using a hard coded key here in this example, but in real applications,
// you would never do this. Your JWT signing key must never be in your application,
Expand Down
2 changes: 1 addition & 1 deletion examples/authenticated-api/echo/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"sort"
"sync"

"github.com/deepmap/oapi-codegen/v2/examples/authenticated-api/echo/api"
"github.com/getkin/kin-openapi/openapi3filter"
"github.com/labstack/echo/v4"
middleware "github.com/oapi-codegen/echo-middleware"
"github.com/oapi-codegen/oapi-codegen/v2/examples/authenticated-api/echo/api"
)

type server struct {
Expand Down
4 changes: 2 additions & 2 deletions examples/authenticated-api/echo/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"net/http"
"testing"

"github.com/deepmap/oapi-codegen/v2/examples/authenticated-api/echo/api"
"github.com/oapi-codegen/testutil"
"github.com/labstack/echo/v4"
"github.com/oapi-codegen/oapi-codegen/v2/examples/authenticated-api/echo/api"
"github.com/oapi-codegen/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
2 changes: 1 addition & 1 deletion examples/authenticated-api/stdhttp/api/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/authenticated-api/stdhttp/api/doc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package api

//go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml ../../api.yaml
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml ../../api.yaml
6 changes: 3 additions & 3 deletions examples/authenticated-api/stdhttp/go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module github.com/deepmap/oapi-codegen/v2/examples/authenticated-api/stdhttp
module github.com/oapi-codegen/oapi-codegen/v2/examples/authenticated-api/stdhttp

go 1.22

replace github.com/deepmap/oapi-codegen/v2 => ../../../
replace github.com/oapi-codegen/oapi-codegen/v2 => ../../../

require (
github.com/deepmap/oapi-codegen/v2 v2.0.0-00010101000000-000000000000
github.com/getkin/kin-openapi v0.124.0
github.com/lestrrat-go/jwx v1.2.29
github.com/oapi-codegen/nethttp-middleware v1.0.2
github.com/oapi-codegen/oapi-codegen/v2 v2.0.0-00010101000000-000000000000
github.com/oapi-codegen/testutil v1.1.0
github.com/stretchr/testify v1.9.0
)
Expand Down
4 changes: 2 additions & 2 deletions examples/authenticated-api/stdhttp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"
"net/http"

"github.com/deepmap/oapi-codegen/v2/examples/authenticated-api/stdhttp/api"
"github.com/deepmap/oapi-codegen/v2/examples/authenticated-api/stdhttp/server"
"github.com/oapi-codegen/oapi-codegen/v2/examples/authenticated-api/stdhttp/api"
"github.com/oapi-codegen/oapi-codegen/v2/examples/authenticated-api/stdhttp/server"
)

func main() {
Expand Down
5 changes: 3 additions & 2 deletions examples/authenticated-api/stdhttp/server/fake_jws.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import (
"crypto/ecdsa"
"fmt"

"github.com/deepmap/oapi-codegen/v2/pkg/ecdsafile"
"github.com/lestrrat-go/jwx/jwa"
"github.com/lestrrat-go/jwx/jwk"
"github.com/lestrrat-go/jwx/jws"
"github.com/lestrrat-go/jwx/jwt"
"github.com/oapi-codegen/oapi-codegen/v2/pkg/ecdsafile"
)

// PrivateKey is an ECDSA private key which was generated with the following
// command:
// openssl ecparam -name prime256v1 -genkey -noout -out ecprivatekey.pem
//
// openssl ecparam -name prime256v1 -genkey -noout -out ecprivatekey.pem
//
// We are using a hard coded key here in this example, but in real applications,
// you would never do this. Your JWT signing key must never be in your application,
Expand Down
2 changes: 1 addition & 1 deletion examples/authenticated-api/stdhttp/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"sort"
"sync"

"github.com/deepmap/oapi-codegen/v2/examples/authenticated-api/stdhttp/api"
"github.com/getkin/kin-openapi/openapi3filter"
middleware "github.com/oapi-codegen/nethttp-middleware"
"github.com/oapi-codegen/oapi-codegen/v2/examples/authenticated-api/stdhttp/api"
)

type server struct {
Expand Down
2 changes: 1 addition & 1 deletion examples/authenticated-api/stdhttp/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"net/http"
"testing"

"github.com/deepmap/oapi-codegen/v2/examples/authenticated-api/stdhttp/api"
"github.com/oapi-codegen/oapi-codegen/v2/examples/authenticated-api/stdhttp/api"
"github.com/oapi-codegen/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion examples/authenticated-api/stdhttp/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
package tools

import (
_ "github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen"
_ "github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen"
)
Loading

0 comments on commit c734650

Please sign in to comment.