Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

拉取了 deepmap/master 上游,把 shanbay fork 里新增的嵌套 struct 功能改为了可选参数 #6

Merged
merged 76 commits into from
Dec 8, 2021

Conversation

sljeff
Copy link

@sljeff sljeff commented Dec 7, 2021

  • 拉取上游原本是为了合入 deepmap 主线的,但是我提了 PR 以后他们一直不回复我,导致现在 shanbay deepmap 以及我的个人仓库有三种代码
    • 由于要验证我提交的东西能正常用,有些项目一直是在使用我个人仓库的版本,很混乱
    • 现在在我个人仓库基础上拉取了最新的上游,合并到 shanbay 里以后都用 shanbay 的二进制就好

改动:

  • 拉取了最新的上游
  • 按照他们在另一个 issue 里的意思,把我们新加的功能做成了一个选项

  • 我们生产环境有两个项目一直在使用这个版本的 oapi-codegen,是可以正常用的

BREAKING CHANGE:

  • oapi-codegen 命令需要是 -generate=types,nested-types,client,server,spec,skip-prune 参数,带上 nested-types 才会去嵌套生成匿名 struct
  • enum 生成的变量名变了,比如 AudioAddressApp_ALL 现在是 AudioAddressAppALL
  • go.mod 里依赖的 oapi-codegen 要改到至少 v1.8.2
    • 实测可以到目前最新的 v1.9.0
  • 由于这个 issue,kin-openapi 至少要升级到 v0.83.0
    • 实测可以到目前最新的 v0.85.0

marcinromaszewicz and others added 30 commits February 8, 2021 09:56
PR 258 broke generated code when the security scheme is an invalid
Go identifier. Sanitize the name as a quick fix.
… echo as well (oapi-codegen#315)

* add missing github.com/labstack/echo/v4

* add missing go.sum entry for golang.org/x/time/rate

* tidy up go.mod
)

Co-authored-by: Marcin Romaszewicz <47459980+deepmap-marcinr@users.noreply.github.com>
* Fix typo

* Update templates.gen.go

* fix
- `strconv.FormatFloat` was using 64 bitSize for both float32 and float64
- float32 should use 32 bitSize (https://golang.org/src/strconv/ftoa.go?s=1697:1760#L37)
- this conversion caused a bug when you send pointer *float32 e.g. 1.05, you get something like 1.0499999523162842
* Upgrade Chi

* Add line back

* Go mod tidy

Co-authored-by: Marcin Romaszewicz <47459980+deepmap-marcinr@users.noreply.github.com>
This ensures the generated constants are output in a deterministic order.
…nce. (oapi-codegen#308)

It fixes the following case:
$ cat main.yml:
  ...
      elements:
        type: array
        items:
          $ref: './schemas/items.yml'

$ cat ./schemas/items.yml
type: object
properties:
  id:
    type: integer
    format: int64
  name:
    type: string

Co-authored-by: Lukiianchuk Dmitrii <d.lukiyanchuk@butik.ru>
Co-authored-by: Marcin Romaszewicz <47459980+deepmap-marcinr@users.noreply.github.com>
…gen#306)

Co-authored-by: Marcin Romaszewicz <47459980+deepmap-marcinr@users.noreply.github.com>
…codegen#313)"

This reverts commit 720dae1. It broke
path handling in a different way. We will fix this differently.
This fixes oapi-codegen#312, by ensuring that queries are properly escaped in
the client, and properly unescaped in the server.
The client can have a per-request editor function, so add it to the
ClientWithResponses for consistency.
This fixes oapi-codegen#316. Maps are randomized, so sort the keys.
Kin 0.48+ requires Go 1.16 because it uses the embed directive, so we
can't use it.
kin-openapi requires Go 1.14, and therefore, so do we.
…en#322)

Co-authored-by: Marcin Romaszewicz <47459980+deepmap-marcinr@users.noreply.github.com>
…pi-codegen#322)"

This reverts commit 88f937a.

The kin legacy routers force pulling in kin-openapi@0.52.0 which requires
Go 1.16
This fixes oapi-codegen#302. We were really sloppy with escaping and unescaping
parameters, so I added another parameter to Bind/StyleParam which
informs where the parameter is located, so that we can do proper
escaping based on location. The server code performs corresponding
unescaping.
…nt. (oapi-codegen#331)

* Change default client template to use new http.Client not DefaultClient.

* Update generated client code among tests.

* Update generated client code at example petstore-expanded.

* Update generated client code at package codegen templates.
…gen#329) (oapi-codegen#330)

* fix when responseBody has multiple media types

* fix failing test
* add description field

* use description field in template

* fix tests

* remove last line

* Update templates.gen.go

* Update templates.gen.go

* remove hardcoded stuff

* Update typedef.tmpl

* simplify by adding description to Schema

* Update components.gen.go

* Update templates.gen.go

* Update schema.go

* fix tests

* fix tests

* Update schema.go

* fix tests
I don't like how ClientWithResponses meta-info snuck into the very
generic TypeDefinition, so create a struct called ResponseTypeDefinition
which embeds TypeDefinition and adds extra fields. I eventually want to
refactor this completely, and separating these two types will prevent
them becoming more conjoined.
Co-authored-by: Weidong Feng <weidong.feng@shanbay.com>
Co-authored-by: Marcin Romaszewicz <47459980+deepmap-marcinr@users.noreply.github.com>
* implemented openapi specification loading in runtime with external reference resolution

* go generate ./...

* test "GetSwagger" function using the example with external references
* fix(model): Copying servers from path definition to operation definition

* feat(enums): Adding support for enums in all positions
hexdigest and others added 28 commits July 21, 2021 07:48
Eliminate the generation of an empty body content type switch.

Also:
* Just declare a new buffer no need to call bytes.NewBufferString.
Fix the depth check in RefPathToGoType which was incorrectly resulting
in an error when processing URL or Remote references.

Also:
* Leverage sub tests to add more tests to TestRefPathToGoType to
  cover all the different types of expected refs.
* Fix the URL example in RefPathToGoType doc comment.
Remove the unneeded separating new line from the first field of a struct.
* Fix tests of oapi-codegen#312 to check real urls

* Fix double escape of uri parameters
Tweak the body templates to remove the duplicate space from the
"with any body" comments.
Fixes the net/http server generation example to use valid function
parameters.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
* fix: fix panic when printing the nil Date

Not sure why, but this is only happening when running with delve.
It seems like printing a nil Stringer causes a panic when debugging
with delve but is handled gracefully outside of delve.

Steps to reproduce:
1. Start debugger
2. Print the value of a nil Date
```go
var d *Date
fmt.Sprintf("%v", d)
```

Theory:
`time.Time` is embedded within the `Date` type. This means that if
Date is nil and Stringer is used to get the string representation of
it, it'll try to call Date.Time.String() which will result in a nil
dereferencing error.

* Regenerate code

Co-authored-by: Beng Lim <beng.lim@outlook.com>
replacing:  `oapi-generate`
with: `oapi-codegen`
* remove github.com/pkg/errors

* `go mod tidy`

* fix losted err wrap
…gen#427)

Co-authored-by: kotyara85 <konrasko@gmail.com>
Co-authored-by: Marcin Romaszewicz <47459980+deepmap-marcinr@users.noreply.github.com>
My manual conflict merge created problems, regenerate the affected file.
* fix: client response template to ignore errors

Presently rsp.Body.Close masks away the error without checking for them.
This code will do the same but give linters the assumption that it alteast
considering to look at them.

* Ran all commands in travisCI.yaml
This fixes a merge issue from a PR which didn't include some new changes.
This change creates a little program which shows how to perform
JWT validation.
…en#459)

* oapi-codegen#367 error handler callback

* removing logs

* refactoring, checking if function is declared and using default otherwise
)

* expand chi server wrapper errors with more information

* update travis go version
* fix for ci

* update readme

* feat: add gin server support

* save work

* save work

* save work

* save work

* save work

* save work

* tidy mod

* update ci

* add gin mw

* bump go version to 1.16

Co-authored-by: Marcin Romaszewicz <47459980+deepmap-marcinr@users.noreply.github.com>
…sing a path (oapi-codegen#474)

Co-authored-by: Marcin Romaszewicz <47459980+deepmap-marcinr@users.noreply.github.com>
@fenngwd
Copy link

fenngwd commented Dec 8, 2021

LGTM

@fenngwd fenngwd merged commit 5a84739 into shanbay:master Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet