oapi-codegen + echo + go-playground/validator で API サーバのHTTP リクエストの Handlerをテンプレート化した

Repository

https://github.com/nakamurakzz/go-oapi-codegen-template

参考

概要

components:
  schemas:
    PostBookRequest:
      type: object
      required:
        - title
        - author
      properties:
        title:
          type: string
          minLength: 1
          maxLength: 256
          x-oapi-codegen-extra-tags:
            validate: "required,min=1,max=256"
        author:
          type: string
          minLength: 1
          maxLength: 256
          x-oapi-codegen-extra-tags:
            validate: "required,min=1,max=256"
        description:
          type: string
          maxLength: 1000
          x-oapi-codegen-extra-tags:
            validate: "max=1000"

良いところ

いまいちなところ