From 0e06cbec2d1a12d270ba87afa10149045a5852c8 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Fri, 27 Oct 2023 23:18:14 +0200 Subject: [PATCH] feat(o2k): add inso-compatible flag This will generate a deck config without ids, and the generated names will be the same as Inso. --- cmd/file_openapi2kong.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/file_openapi2kong.go b/cmd/file_openapi2kong.go index 43b3e6ab8..8f2bdd316 100644 --- a/cmd/file_openapi2kong.go +++ b/cmd/file_openapi2kong.go @@ -18,6 +18,8 @@ var ( cmdO2KdocName string cmdO2KoutputFormat string cmdO2KentityTags []string + cmdO2KskipID bool + cmdO2KinsoCompat bool ) // Executes the CLI command "openapi2kong" @@ -32,9 +34,14 @@ func executeOpenapi2Kong(cmd *cobra.Command, _ []string) error { cmdO2KoutputFormat = strings.ToUpper(cmdO2KoutputFormat) + if cmdO2KinsoCompat { + cmdO2KskipID = true // this is implicit in inso compatibility mode + } options := openapi2kong.O2kOptions{ - Tags: cmdO2KentityTags, - DocName: cmdO2KdocName, + Tags: cmdO2KentityTags, + DocName: cmdO2KdocName, + SkipID: cmdO2KskipID, + InsoCompat: cmdO2KinsoCompat, } trackInfo := deckformat.HistoryNewEntry("openapi2kong") @@ -90,6 +97,12 @@ The output will be targeted at Kong version 3.x. openapi2kongCmd.Flags().StringSliceVar(&cmdO2KentityTags, "select-tag", nil, "Select tags to apply to all entities. If omitted, uses the \"x-kong-tags\"\n"+ "directive from the file.") + openapi2kongCmd.Flags().BoolVar(&cmdO2KskipID, "no-id", false, + "Setting this flag will skip UUID generation for entities (no 'id' fields\n"+ + "will be added, implicit if '--inso-compatible' is set).") + openapi2kongCmd.Flags().BoolVarP(&cmdO2KinsoCompat, "inso-compatible", "i", false, + "This flag will enable Inso compatibility. The generated entity names will be\n"+ + "the same, and no 'id' fields will be gnerated.") return openapi2kongCmd }