Documentation
¶
Overview ¶
Package kinddiff compares two versions of a kind of request from their requests directories: the kind's description in types/<kind>.json, and the operations the kind owns in openapi.json. It uses the standard library alone.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Diff ¶
type Diff struct {
Kind string
OldVersion int
NewVersion int
NewKind bool
// contains filtered or unexported fields
}
Diff is what differs between two versions of a kind. OldVersion is 0 for a new kind.
func Compare ¶
Compare reads types/<kind>.json and the kind's operations in openapi.json from two requests directories and answers what changed. A nil old means the kind is new. It refuses a directory without the kind, a description that does not read, and two descriptions of different kinds.
Example ¶
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/i2y/ringi-server/kinddiff"
)
func main() {
oldDir := os.DirFS(filepath.Join("testdata", "v1"))
newDir := os.DirFS(filepath.Join("testdata", "v2"))
d, err := kinddiff.Compare(oldDir, newDir, "leave")
if err != nil {
panic(err)
}
for _, line := range d.Lines("en") {
fmt.Printf("%s api=%v: %s\n", line.Section, line.API, line.Text)
}
for _, line := range d.Lines("ja") {
fmt.Printf("%s api=%v: %s\n", line.Section, line.API, line.Text)
}
}
Output: form api=true: The number range of the field "Business days" (days) changes from 1 through 20 to 1 through 25. usable api=false: This version now takes effect from 2027-04-01. usable api=false: The first day the kind can be used changes from 2026-04-01 to 2027-04-01. usable api=false: The data deciding the first day the kind can be used changes from "the first version of the organization `shared/company.ringi` (data `../org`)" to "`effective from`". api api=true: In the request body of `submit_leave`, `maximum` of `form.days` changes from `20` to `25`. api api=true: In the request body of `resubmit_leave`, `maximum` of `form.days` changes from `20` to `25`. form api=true: 項目「営業日の日数」(days)の数値の範囲が1以上20以下から1以上25以下に変わります。 usable api=false: この版は2027-04-01から効きます。 usable api=false: この申請の種類を出せる最初の日が2026-04-01から2027-04-01に変わります。 usable api=false: 申請を出せる最初の日を決めるデータが「the first version of the organization `shared/company.ringi` (data `../org`)」から「`effective from`」に変わります。 api api=true: `submit_leave` に送る本文では、`form.days` の `maximum` が`20`から`25`に変わります。 api api=true: `resubmit_leave` に送る本文では、`form.days` の `maximum` が`20`から`25`に変わります。
func (*Diff) APIChanged ¶
APIChanged reports whether any operation of the kind takes or answers a different shape, or an operation of the kind is added or removed.