Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Remove workaround #27
Browse files Browse the repository at this point in the history
  • Loading branch information
minchao committed Sep 30, 2020
1 parent d543966 commit 378c079
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 77 deletions.
12 changes: 6 additions & 6 deletions oas.bus.v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,6 @@
"Taipei"
],
"x-enum": {
"Taichung": "臺中市",
"Taoyuan": "桃園市",
"TaitungCounty": "臺東縣",
"LienchiangCounty": "連江縣",
Expand All @@ -2264,7 +2263,8 @@
"HualienCounty": "花蓮縣",
"ChiayiCounty": "嘉義縣",
"Chiayi": "嘉義市",
"Tainan": "臺南市"
"Tainan": "臺南市",
"Taichung": "臺中市"
}
},
{
Expand Down Expand Up @@ -3668,7 +3668,6 @@
"KinmenCounty"
],
"x-enum": {
"Kaohsiung": "高雄市",
"YunlinCounty": "雲林縣",
"TaitungCounty": "臺東縣",
"PenghuCounty": "澎湖縣",
Expand All @@ -3689,7 +3688,8 @@
"ChiayiCounty": "嘉義縣",
"PingtungCounty": "屏東縣",
"Hsinchu": "新竹市",
"ChanghuaCounty": "彰化縣"
"ChanghuaCounty": "彰化縣",
"Kaohsiung": "高雄市"
}
},
{
Expand Down Expand Up @@ -3800,7 +3800,6 @@
"KinmenCounty"
],
"x-enum": {
"Kaohsiung": "高雄市",
"YunlinCounty": "雲林縣",
"TaitungCounty": "臺東縣",
"PenghuCounty": "澎湖縣",
Expand All @@ -3821,7 +3820,8 @@
"ChiayiCounty": "嘉義縣",
"PingtungCounty": "屏東縣",
"Hsinchu": "新竹市",
"ChanghuaCounty": "彰化縣"
"ChanghuaCounty": "彰化縣",
"Kaohsiung": "高雄市"
}
},
{
Expand Down
60 changes: 30 additions & 30 deletions oas.rail.v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@
"TRTCMG"
],
"x-enum": {
"TRTC": "臺北捷運",
"TRTCMG": "貓空纜車",
"KRTC": "高雄捷運",
"TYMC": "桃園捷運",
"TRTC": "臺北捷運"
"TYMC": "桃園捷運"
}
},
{
Expand Down Expand Up @@ -197,12 +197,12 @@
"TRTCMG"
],
"x-enum": {
"TYMC": "桃園捷運",
"KLRT": "高雄輕軌",
"TRTCMG": "貓空纜車",
"TRTC": "臺北捷運",
"NTDLRT": "淡海輕軌",
"KRTC": "高雄捷運",
"TYMC": "桃園捷運",
"KLRT": "高雄輕軌"
"KRTC": "高雄捷運"
}
},
{
Expand Down Expand Up @@ -290,12 +290,12 @@
"TRTCMG"
],
"x-enum": {
"TRTC": "臺北捷運",
"KLRT": "高雄輕軌",
"KRTC": "高雄捷運",
"TRTC": "臺北捷運",
"NTDLRT": "淡海輕軌",
"TYMC": "桃園捷運",
"TRTCMG": "貓空纜車",
"KRTC": "高雄捷運"
"TRTCMG": "貓空纜車"
}
},
{
Expand Down Expand Up @@ -389,9 +389,9 @@
"TRTCMG"
],
"x-enum": {
"KLRT": "高雄輕軌",
"TRTC": "臺北捷運",
"KRTC": "高雄捷運",
"KLRT": "高雄輕軌",
"TYMC": "桃園捷運",
"NTDLRT": "淡海輕軌",
"TRTCMG": "貓空纜車"
Expand Down Expand Up @@ -563,8 +563,8 @@
"TYMC"
],
"x-enum": {
"TRTC": "臺北捷運",
"KRTC": "高雄捷運",
"TRTC": "臺北捷運",
"TYMC": "桃園捷運"
}
},
Expand Down Expand Up @@ -651,9 +651,9 @@
"TRTCMG"
],
"x-enum": {
"TRTC": "臺北捷運",
"KLRT": "高雄輕軌",
"TYMC": "桃園捷運",
"TRTC": "臺北捷運",
"KRTC": "高雄捷運",
"TRTCMG": "貓空纜車"
}
Expand Down Expand Up @@ -747,10 +747,10 @@
"NTDLRT"
],
"x-enum": {
"KRTC": "高雄捷運",
"NTDLRT": "淡海輕軌",
"TRTC": "臺北捷運",
"TYMC": "桃園捷運",
"KRTC": "高雄捷運"
"TYMC": "桃園捷運"
}
},
{
Expand Down Expand Up @@ -836,10 +836,10 @@
"NTDLRT"
],
"x-enum": {
"KRTC": "高雄捷運",
"TYMC": "桃園捷運",
"TRTC": "臺北捷運",
"NTDLRT": "淡海輕軌"
"NTDLRT": "淡海輕軌",
"KRTC": "高雄捷運",
"TYMC": "桃園捷運"
}
},
{
Expand Down Expand Up @@ -926,9 +926,9 @@
],
"x-enum": {
"KRTC": "高雄捷運",
"KLRT": "高雄輕軌",
"TYMC": "桃園捷運",
"TRTC": "臺北捷運",
"KLRT": "高雄輕軌"
"TRTC": "臺北捷運"
}
},
{
Expand Down Expand Up @@ -1100,10 +1100,10 @@
"KLRT"
],
"x-enum": {
"TRTC": "臺北捷運",
"KLRT": "高雄輕軌",
"KRTC": "高雄捷運",
"TYMC": "桃園捷運"
"TYMC": "桃園捷運",
"TRTC": "臺北捷運",
"KLRT": "高雄輕軌"
}
},
{
Expand Down Expand Up @@ -1192,11 +1192,11 @@
],
"x-enum": {
"TYMC": "桃園捷運",
"TRTCMG": "貓空纜車",
"KRTC": "高雄捷運",
"NTDLRT": "淡海輕軌",
"KLRT": "高雄輕軌",
"TRTC": "臺北捷運"
"KRTC": "高雄捷運",
"TRTC": "臺北捷運",
"TRTCMG": "貓空纜車",
"NTDLRT": "淡海輕軌"
}
},
{
Expand Down Expand Up @@ -1452,8 +1452,8 @@
"enum": [
"TRTC",
"KRTC",
"NTDLRT",
"TYMC"
"TYMC",
"NTDLRT"
],
"x-enum": {
"KRTC": "高雄捷運",
Expand Down Expand Up @@ -3482,7 +3482,7 @@
],
"summary": "**(開發用測試版)** 取得指定[日期]對號座即時剩餘位資料(加值型列車起迄段OD角度)",
"description": "取得指定[日期]對號座即時剩餘位資料(加值型列車起迄段OD角度)\r\n- 當日(D)之更新頻率為每10分鐘\r\n- 當日後27日(D+1~D+27)之更新頻率為每日的10、16、22時\r\n- **(本服務尚在測試中,穩定度及更新頻率將持續優化)**",
"operationId": "THSRApi_AvailableSeatStatus_2",
"operationId": "THSRApi_AvailableSeatStatus_OD",
"produces": [
"application/json",
"application/xml"
Expand Down Expand Up @@ -3565,7 +3565,7 @@
],
"summary": "**(開發用測試版)** 取得指定[日期], [起迄站]對號座即時剩餘位資料(加值型列車起迄段OD角度)",
"description": "取得指定[日期], [起迄站]對號座即時剩餘位資料(加值型列車起迄段OD角度)\r\n- 當日(D)之更新頻率為每10分鐘\r\n- 當日後27日(D+1~D+27)之更新頻率為每日的10、16、22時\r\n- **(本服務尚在測試中,穩定度及更新頻率將持續優化)**",
"operationId": "THSRApi_AvailableSeatStatus_3",
"operationId": "THSRApi_AvailableSeatStatus_OD_1",
"produces": [
"application/json",
"application/xml"
Expand Down Expand Up @@ -3662,7 +3662,7 @@
],
"summary": "**(開發用測試版)** 取得指定[日期], [車次], [起迄站]對號座即時剩餘位資料(加值型列車起迄段OD角度)",
"description": "取得指定[日期], [起迄站]對號座即時剩餘位資料(加值型列車起迄段OD角度)\r\n- 當日(D)之更新頻率為每10分鐘\r\n- 當日後27日(D+1~D+27)之更新頻率為每日的10、16、22時\r\n- **(本服務尚在測試中,穩定度及更新頻率將持續優化)**",
"operationId": "THSRApi_AvailableSeatStatus_4",
"operationId": "THSRApi_AvailableSeatStatus_OD_2",
"produces": [
"application/json",
"application/xml"
Expand Down
32 changes: 16 additions & 16 deletions oas.tourism.v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@
"LienchiangCounty"
],
"x-enum": {
"Taoyuan": "桃園市",
"Keelung": "基隆市",
"ChiayiCounty": "嘉義縣",
"TaitungCounty": "臺東縣",
"Taipei": "臺北市",
"Chiayi": "嘉義市",
"LienchiangCounty": "連江縣",
"HsinchuCounty": "新竹縣",
"KinmenCounty": "金門縣",
Expand All @@ -138,20 +144,14 @@
"NantouCounty": "南投縣",
"Taichung": "臺中市",
"YilanCounty": "宜蘭縣",
"Taoyuan": "桃園市",
"NewTaipei": "新北市",
"Keelung": "基隆市",
"Chiayi": "嘉義市",
"Kaohsiung": "高雄市",
"HualienCounty": "花蓮縣",
"PingtungCounty": "屏東縣",
"ChanghuaCounty": "彰化縣",
"YunlinCounty": "雲林縣",
"Hsinchu": "新竹市",
"PenghuCounty": "澎湖縣",
"ChiayiCounty": "嘉義縣",
"TaitungCounty": "臺東縣",
"Taipei": "臺北市"
"PenghuCounty": "澎湖縣"
}
},
{
Expand Down Expand Up @@ -337,15 +337,16 @@
"LienchiangCounty"
],
"x-enum": {
"Taoyuan": "桃園市",
"ChanghuaCounty": "彰化縣",
"HualienCounty": "花蓮縣",
"TaitungCounty": "臺東縣",
"NewTaipei": "新北市",
"Taipei": "臺北市",
"HsinchuCounty": "新竹縣",
"PenghuCounty": "澎湖縣",
"PingtungCounty": "屏東縣",
"Taichung": "臺中市",
"Taoyuan": "桃園市",
"HualienCounty": "花蓮縣",
"YilanCounty": "宜蘭縣",
"Chiayi": "嘉義市",
"Tainan": "臺南市",
Expand All @@ -357,7 +358,6 @@
"NantouCounty": "南投縣",
"ChiayiCounty": "嘉義縣",
"KinmenCounty": "金門縣",
"ChanghuaCounty": "彰化縣",
"YunlinCounty": "雲林縣"
}
},
Expand Down Expand Up @@ -544,6 +544,8 @@
"LienchiangCounty"
],
"x-enum": {
"NantouCounty": "南投縣",
"Taoyuan": "桃園市",
"KinmenCounty": "金門縣",
"Hsinchu": "新竹市",
"PingtungCounty": "屏東縣",
Expand All @@ -552,7 +554,6 @@
"Tainan": "臺南市",
"YilanCounty": "宜蘭縣",
"HualienCounty": "花蓮縣",
"NantouCounty": "南投縣",
"Chiayi": "嘉義市",
"Keelung": "基隆市",
"Taipei": "臺北市",
Expand All @@ -564,8 +565,7 @@
"Taichung": "臺中市",
"YunlinCounty": "雲林縣",
"ChanghuaCounty": "彰化縣",
"TaitungCounty": "臺東縣",
"Taoyuan": "桃園市"
"TaitungCounty": "臺東縣"
}
},
{
Expand Down Expand Up @@ -751,6 +751,8 @@
"LienchiangCounty"
],
"x-enum": {
"NantouCounty": "南投縣",
"Taoyuan": "桃園市",
"KinmenCounty": "金門縣",
"Hsinchu": "新竹市",
"PingtungCounty": "屏東縣",
Expand All @@ -759,7 +761,6 @@
"Tainan": "臺南市",
"YilanCounty": "宜蘭縣",
"HualienCounty": "花蓮縣",
"NantouCounty": "南投縣",
"Chiayi": "嘉義市",
"Keelung": "基隆市",
"Taipei": "臺北市",
Expand All @@ -771,8 +772,7 @@
"Taichung": "臺中市",
"YunlinCounty": "雲林縣",
"ChanghuaCounty": "彰化縣",
"TaitungCounty": "臺東縣",
"Taoyuan": "桃園市"
"TaitungCounty": "臺東縣"
}
},
{
Expand Down
25 changes: 0 additions & 25 deletions spec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ func main() {
{
Filename: "oas.rail.v2.json",
URL: "https://ptx.transportdata.tw/MOTC/v2/Rail/api-docs/oas",
Pipeline: []Step{
fixNotDefinedProperty,
},
},
{
Filename: "oas.rail.v3.json",
Expand All @@ -48,9 +45,6 @@ func main() {
{
Filename: "oas.ship.v3.json",
URL: "https://ptx.transportdata.tw/MOTC/v3/Ship/api-docs/oas",
Pipeline: []Step{
fixProperty,
},
},
} {
fmt.Printf("Generate %s\n", oas.Filename)
Expand Down Expand Up @@ -94,22 +88,3 @@ func writeFile(filename string, data []byte) {
_ = enc.Encode(v)
_ = ioutil.WriteFile(filename, bf.Bytes(), 0644)
}

func fixProperty(data []byte) []byte {
return bytes.Replace(data, []byte(`"description": "資料版本編號<span class=\"emphasis fas fa-pen\" rel=\"與來源Inbound XML不同,為提供資料的版本編號[該欄位由本平台自動產製]\"></span>",
"type": "integer"
},
"Items": {`), []byte(`"description": "資料版本編號<span class=\"emphasis fas fa-pen\" rel=\"與來源Inbound XML不同,為提供資料的版本編號[該欄位由本平台自動產製]\"></span>",
"type": "integer"
},
"Ports": {`), -1)
}

// see https://github.com/minchao/go-ptx/issues/27
func fixNotDefinedProperty(data []byte) []byte {
return bytes.Replace(data,
[]byte(`"EndingStationName","StopStations","SrcUpdateTime","UpdateTime"`),
[]byte(`"EndingStationName","StopStations"`),
1,
)
}

0 comments on commit 378c079

Please sign in to comment.