From 64cf83112fa869453fb7d4a1c965968e5d04b23d Mon Sep 17 00:00:00 2001 From: ilemiashonak <100114259+ilemiashonak@users.noreply.github.com> Date: Fri, 28 Oct 2022 14:31:20 +0300 Subject: [PATCH] phone country code enum dash removed (#28) * 6106 phone country code, phone number, language name 2 and 3 char codes and postal code types * makefile gen-phone gen-language commands added * swagger update * fix travis-ci * readme update * swagger + languages/phone generator fixes * swagger + languages/phone generator fixes * dial code valuer fix * travis ci go-lint script update * postal_code validation fix * postal_code validation fix * country unmarshalling empty value fix * unmarshalling empty value fix * phone country code enum dash removed Co-authored-by: ivan-lemiashonak --- phone/.generator/generator.js | 8 +-- phone/codes_mapping_gen.go | 94 +++++++++++++++++------------------ phone/dial_code_gen.go | 92 +++++++++++++++++----------------- postal_code/swagger.yaml | 2 +- swagger.yaml | 54 ++++++++++---------- 5 files changed, 125 insertions(+), 125 deletions(-) diff --git a/phone/.generator/generator.js b/phone/.generator/generator.js index 2305074..19e6af5 100644 --- a/phone/.generator/generator.js +++ b/phone/.generator/generator.js @@ -73,10 +73,10 @@ function preparePhoneCountryCodes(rawCodes) { let codesByCountry = codes[requestCountryDialKey].split(",") if (codesByCountry.length > 1) { codesByCountry.forEach(code => { - result.push({ [innerCountryDialKey]: code, [innerCountryKey]: codes[requestCountryKey] }) + result.push({ [innerCountryDialKey]: code.replace("-", ""), [innerCountryKey]: codes[requestCountryKey] }) }) } else { - result[result.length] = { [innerCountryDialKey]: codes[requestCountryDialKey], [innerCountryKey]: codes[requestCountryKey] } + result[result.length] = { [innerCountryDialKey]: codes[requestCountryDialKey].replace("-", ""), [innerCountryKey]: codes[requestCountryKey] } } } @@ -93,7 +93,7 @@ ${renderByAlpha2Codes(trimRedundantDominicana(codes))} } function trimRedundantDominicana(codes) { - let redundant = ["1-809", "1-849"] + let redundant = ["1809", "1849"] return codes.filter(({ [innerCountryDialKey]: dialCode }) => !redundant.some(el => dialCode === el)) } @@ -143,7 +143,7 @@ function renderSpecification(codes) { components: { schemas: { DialCountryCode: { - example: "1-829", + example: "1829", type: "string", format: "E.164", enum: [...Object.keys(concatenateCountriesByDialCode(codes))], diff --git a/phone/codes_mapping_gen.go b/phone/codes_mapping_gen.go index 081e971..44d95e6 100644 --- a/phone/codes_mapping_gen.go +++ b/phone/codes_mapping_gen.go @@ -889,79 +889,79 @@ var countryCodeByDialString = map[string][]country.Alpha2Code{ "998": { country.Alpha2Code("UZ"), }, - "1-684": { - country.Alpha2Code("AS"), - }, - "1-264": { - country.Alpha2Code("AI"), - }, - "1-268": { - country.Alpha2Code("AG"), - }, - "1-242": { + "1242": { country.Alpha2Code("BS"), }, - "1-246": { + "1246": { country.Alpha2Code("BB"), }, - "1-441": { - country.Alpha2Code("BM"), + "1264": { + country.Alpha2Code("AI"), }, - "1-284": { + "1268": { + country.Alpha2Code("AG"), + }, + "1284": { country.Alpha2Code("VG"), }, - "1-345": { + "1340": { + country.Alpha2Code("VI"), + }, + "1345": { country.Alpha2Code("KY"), }, - "1-767": { - country.Alpha2Code("DM"), + "1441": { + country.Alpha2Code("BM"), }, - "1-809": { - country.Alpha2Code("DO"), + "1473": { + country.Alpha2Code("GD"), }, - "1-829": { - country.Alpha2Code("DO"), + "1649": { + country.Alpha2Code("TC"), }, - "1-849": { - country.Alpha2Code("DO"), + "1664": { + country.Alpha2Code("MS"), }, - "1-473": { - country.Alpha2Code("GD"), + "1670": { + country.Alpha2Code("MP"), }, - "1-671": { + "1671": { country.Alpha2Code("GU"), }, - "39-06": { - country.Alpha2Code("VA"), + "1684": { + country.Alpha2Code("AS"), }, - "1-876": { - country.Alpha2Code("JM"), + "1721": { + country.Alpha2Code("SX"), }, - "1-664": { - country.Alpha2Code("MS"), + "1758": { + country.Alpha2Code("LC"), }, - "1-670": { - country.Alpha2Code("MP"), + "1767": { + country.Alpha2Code("DM"), }, - "1-869": { - country.Alpha2Code("KN"), + "1784": { + country.Alpha2Code("VC"), }, - "1-758": { - country.Alpha2Code("LC"), + "1809": { + country.Alpha2Code("DO"), }, - "1-784": { - country.Alpha2Code("VC"), + "1829": { + country.Alpha2Code("DO"), }, - "1-721": { - country.Alpha2Code("SX"), + "1849": { + country.Alpha2Code("DO"), }, - "1-868": { + "1868": { country.Alpha2Code("TT"), }, - "1-649": { - country.Alpha2Code("TC"), + "1869": { + country.Alpha2Code("KN"), }, - "1-340": { - country.Alpha2Code("VI"), + "1876": { + country.Alpha2Code("JM"), + }, + "3906": { + country.Alpha2Code("VA"), }, } \ No newline at end of file diff --git a/phone/dial_code_gen.go b/phone/dial_code_gen.go index 8a329f3..d8b1263 100644 --- a/phone/dial_code_gen.go +++ b/phone/dial_code_gen.go @@ -9,18 +9,18 @@ const ( AL = DialCode("355") // 213 is 'DZ' country dial code DZ = DialCode("213") - // 1-684 is 'AS' country dial code - AS = DialCode("1-684") + // 1684 is 'AS' country dial code + AS = DialCode("1684") // 376 is 'AD' country dial code AD = DialCode("376") // 244 is 'AO' country dial code AO = DialCode("244") - // 1-264 is 'AI' country dial code - AI = DialCode("1-264") + // 1264 is 'AI' country dial code + AI = DialCode("1264") // 672 is 'AQ' country dial code AQ = DialCode("672") - // 1-268 is 'AG' country dial code - AG = DialCode("1-268") + // 1268 is 'AG' country dial code + AG = DialCode("1268") // 54 is 'AR' country dial code AR = DialCode("54") // 374 is 'AM' country dial code @@ -33,14 +33,14 @@ const ( AT = DialCode("43") // 994 is 'AZ' country dial code AZ = DialCode("994") - // 1-242 is 'BS' country dial code - BS = DialCode("1-242") + // 1242 is 'BS' country dial code + BS = DialCode("1242") // 973 is 'BH' country dial code BH = DialCode("973") // 880 is 'BD' country dial code BD = DialCode("880") - // 1-246 is 'BB' country dial code - BB = DialCode("1-246") + // 1246 is 'BB' country dial code + BB = DialCode("1246") // 375 is 'BY' country dial code BY = DialCode("375") // 32 is 'BE' country dial code @@ -49,8 +49,8 @@ const ( BZ = DialCode("501") // 229 is 'BJ' country dial code BJ = DialCode("229") - // 1-441 is 'BM' country dial code - BM = DialCode("1-441") + // 1441 is 'BM' country dial code + BM = DialCode("1441") // 975 is 'BT' country dial code BT = DialCode("975") // 591 is 'BO' country dial code @@ -67,8 +67,8 @@ const ( BR = DialCode("55") // 246 is 'IO' country dial code IO = DialCode("246") - // 1-284 is 'VG' country dial code - VG = DialCode("1-284") + // 1284 is 'VG' country dial code + VG = DialCode("1284") // 673 is 'BN' country dial code BN = DialCode("673") // 359 is 'BG' country dial code @@ -85,8 +85,8 @@ const ( CM = DialCode("237") // 1 is 'CA' country dial code CA = DialCode("1") - // 1-345 is 'KY' country dial code - KY = DialCode("1-345") + // 1345 is 'KY' country dial code + KY = DialCode("1345") // 236 is 'CF' country dial code CF = DialCode("236") // 235 is 'TD' country dial code @@ -133,10 +133,10 @@ const ( DK = DialCode("45") // 253 is 'DJ' country dial code DJ = DialCode("253") - // 1-767 is 'DM' country dial code - DM = DialCode("1-767") - // 1-829 is 'DO' country dial code - DO = DialCode("1-829") + // 1767 is 'DM' country dial code + DM = DialCode("1767") + // 1829 is 'DO' country dial code + DO = DialCode("1829") // 593 is 'EC' country dial code EC = DialCode("593") // 20 is 'EG' country dial code @@ -185,12 +185,12 @@ const ( GR = DialCode("30") // 299 is 'GL' country dial code GL = DialCode("299") - // 1-473 is 'GD' country dial code - GD = DialCode("1-473") + // 1473 is 'GD' country dial code + GD = DialCode("1473") // 590 is 'GP' country dial code GP = DialCode("590") - // 1-671 is 'GU' country dial code - GU = DialCode("1-671") + // 1671 is 'GU' country dial code + GU = DialCode("1671") // 502 is 'GT' country dial code GT = DialCode("502") // 44 is 'GG' country dial code @@ -205,8 +205,8 @@ const ( HT = DialCode("509") // 672 is 'HM' country dial code HM = DialCode("672") - // 39-06 is 'VA' country dial code - VA = DialCode("39-06") + // 3906 is 'VA' country dial code + VA = DialCode("3906") // 504 is 'HN' country dial code HN = DialCode("504") // 36 is 'HU' country dial code @@ -229,8 +229,8 @@ const ( IL = DialCode("972") // 39 is 'IT' country dial code IT = DialCode("39") - // 1-876 is 'JM' country dial code - JM = DialCode("1-876") + // 1876 is 'JM' country dial code + JM = DialCode("1876") // 81 is 'JP' country dial code JP = DialCode("81") // 44 is 'JE' country dial code @@ -297,8 +297,8 @@ const ( MN = DialCode("976") // 382 is 'ME' country dial code ME = DialCode("382") - // 1-664 is 'MS' country dial code - MS = DialCode("1-664") + // 1664 is 'MS' country dial code + MS = DialCode("1664") // 212 is 'MA' country dial code MA = DialCode("212") // 258 is 'MZ' country dial code @@ -327,8 +327,8 @@ const ( NU = DialCode("683") // 672 is 'NF' country dial code NF = DialCode("672") - // 1-670 is 'MP' country dial code - MP = DialCode("1-670") + // 1670 is 'MP' country dial code + MP = DialCode("1670") // 47 is 'NO' country dial code NO = DialCode("47") // 968 is 'OM' country dial code @@ -373,16 +373,16 @@ const ( BL = DialCode("590") // 290 is 'SH' country dial code SH = DialCode("290") - // 1-869 is 'KN' country dial code - KN = DialCode("1-869") - // 1-758 is 'LC' country dial code - LC = DialCode("1-758") + // 1869 is 'KN' country dial code + KN = DialCode("1869") + // 1758 is 'LC' country dial code + LC = DialCode("1758") // 590 is 'MF' country dial code MF = DialCode("590") // 508 is 'PM' country dial code PM = DialCode("508") - // 1-784 is 'VC' country dial code - VC = DialCode("1-784") + // 1784 is 'VC' country dial code + VC = DialCode("1784") // 685 is 'WS' country dial code WS = DialCode("685") // 378 is 'SM' country dial code @@ -401,8 +401,8 @@ const ( SL = DialCode("232") // 65 is 'SG' country dial code SG = DialCode("65") - // 1-721 is 'SX' country dial code - SX = DialCode("1-721") + // 1721 is 'SX' country dial code + SX = DialCode("1721") // 421 is 'SK' country dial code SK = DialCode("421") // 386 is 'SI' country dial code @@ -449,16 +449,16 @@ const ( TK = DialCode("690") // 676 is 'TO' country dial code TO = DialCode("676") - // 1-868 is 'TT' country dial code - TT = DialCode("1-868") + // 1868 is 'TT' country dial code + TT = DialCode("1868") // 216 is 'TN' country dial code TN = DialCode("216") // 90 is 'TR' country dial code TR = DialCode("90") // 993 is 'TM' country dial code TM = DialCode("993") - // 1-649 is 'TC' country dial code - TC = DialCode("1-649") + // 1649 is 'TC' country dial code + TC = DialCode("1649") // 688 is 'TV' country dial code TV = DialCode("688") // 256 is 'UG' country dial code @@ -471,8 +471,8 @@ const ( GB = DialCode("44") // 255 is 'TZ' country dial code TZ = DialCode("255") - // 1-340 is 'VI' country dial code - VI = DialCode("1-340") + // 1340 is 'VI' country dial code + VI = DialCode("1340") // 1 is 'US' country dial code US = DialCode("1") // 598 is 'UY' country dial code diff --git a/postal_code/swagger.yaml b/postal_code/swagger.yaml index 8e7cabc..7072043 100644 --- a/postal_code/swagger.yaml +++ b/postal_code/swagger.yaml @@ -5,4 +5,4 @@ components: example: CA6633 type: string format: postal-code - x-go-type: github.com/mikekonan/go-types/v2/postalcode.PostalCode + x-go-type: github.com/mikekonan/go-types/v2/postal_code.PostalCode diff --git a/swagger.yaml b/swagger.yaml index 11bf01b..54aa6d2 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -2144,7 +2144,7 @@ components: - zul x-go-type: github.com/mikekonan/go-types/v2/language.Alpha3Code DialCountryCode: - example: 1-829 + example: "1829" type: string format: E.164 enum: @@ -2353,31 +2353,31 @@ components: - "995" - "996" - "998" - - 1-684 - - 1-264 - - 1-268 - - 1-242 - - 1-246 - - 1-441 - - 1-284 - - 1-345 - - 1-767 - - 1-809 - - 1-829 - - 1-849 - - 1-473 - - 1-671 - - 39-06 - - 1-876 - - 1-664 - - 1-670 - - 1-869 - - 1-758 - - 1-784 - - 1-721 - - 1-868 - - 1-649 - - 1-340 + - "1242" + - "1246" + - "1264" + - "1268" + - "1284" + - "1340" + - "1345" + - "1441" + - "1473" + - "1649" + - "1664" + - "1670" + - "1671" + - "1684" + - "1721" + - "1758" + - "1767" + - "1784" + - "1809" + - "1829" + - "1849" + - "1868" + - "1869" + - "1876" + - "3906" x-go-type: github.com/mikekonan/go-types/v2/phone.DialCode PhoneNumber: example: 2505550199 @@ -2388,7 +2388,7 @@ components: example: CA6633 type: string format: postal-code - x-go-type: github.com/mikekonan/go-types/v2/postalcode.PostalCode + x-go-type: github.com/mikekonan/go-types/v2/postal_code.PostalCode Date: example: 2006-01-02 type: string