* INS-2639: add kong 3.x support for inso generate k8s config
* Update packages/openapi-2-kong/src/kubernetes/generate.test.ts
Co-authored-by: Michael Heap <m@michaelheap.com>
* test
---------
Co-authored-by: Michael Heap <m@michaelheap.com>
* update test to expose bug in regex generation
sanitizing the path-variable name is not done correctly, as it sanitizes the entire path. So it also makes unintended changes.
* fix failing test, add +1 test
---------
Co-authored-by: Filipe Freire <livrofubia@gmail.com>
* feat(plugins): enable support for service-level security definition plugins
* feat(plugins): add tests for service-level security plugins
* fix(syntax): match regexes to last commit
* fix lint
Co-authored-by: Filipe Freire <livrofubia@gmail.com>
* update type-fest imports
* move main css to html
* update electron imports
* update nunjucks imports
* use swagger ui dist
* remove commonjs-externals and add electron node require plugin
* update package
* fix misc.ts imports
* remove buffer from builtins since we use a package for it
* plugin docs
* Update packages/insomnia/src/main/window-utils.ts
Co-authored-by: Filipe Freire <livrofubia@gmail.com>
* commit progress
* save changes
* add components and $schema
* add components and $schema
* adding a doc
* add typings
* fix unit tests
* fix unit tests
* add fix and verified with kong cli
* fix unit tests
* Improve types and parameter/body resolution
Co-authored-by: Mark Kim <marckong@users.noreply.github.com>
* fix circular "components" issue
Co-authored-by: gatzjames <jamesgatzos@gmail.com>
Co-authored-by: Mark Kim <marckong@users.noreply.github.com>
* Concating x-kong-security-openid-connect config with security schemas config
* Removing enabled as it is enabled by default
* Small improvement + add tests
Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>
Co-authored-by: Filipe Freire <livrofubia@gmail.com>
Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>
* clears all errors in tests, enables overrides for spec generators
* removes copy/pasta in tests, uses spec generator, removes useless async
continuing from the last commit, but separated out for easier review
* consolidates openapi x-kong extension to one place, uses consistently
these were used for some things, not used for others, exported in some places, not exported in others. now it's uniform and we can look up references for each type.
* adds failing test for ticket
* only adds `enabled` where it was specified
* allows adding passing top-level properties to config
now, the line that was there specifically for `config` is redundant.
* adds tags to test result per review feedback
* removes unnecessary generic
for some reason, this didn't error before, but now it is.
* removes unnecessary argument
this failed on the CI with:
openapi-2-kong: FAIL src/generate.test.ts
openapi-2-kong: ● Test suite failed to run
openapi-2-kong: src/generate.test.ts:90:58 - error TS2769: No overload matches this call.
openapi-2-kong: Overload 1 of 2, '(src: string, options?: (ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions) | undefined): any', gave the following error.
openapi-2-kong: Argument of type '"utf8"' is not assignable to parameter of type '(ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions) | undefined'.
openapi-2-kong: Overload 2 of 2, '(src: string, reviver: Reviver, options?: (ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions) | undefined): any', gave the following error.
openapi-2-kong: Argument of type 'string' is not assignable to parameter of type 'Reviver'.
openapi-2-kong: 90 const parsedSpec = YAML.parse(dcFixtureFileString, 'utf8');
openapi-2-kong: ~~~~~~
openapi-2-kong: src/generate.test.ts💯59 - error TS2769: No overload matches this call.
openapi-2-kong: Overload 1 of 2, '(src: string, options?: (ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions) | undefined): any', gave the following error.
openapi-2-kong: Argument of type '"utf8"' is not assignable to parameter of type '(ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions) | undefined'.
openapi-2-kong: Overload 2 of 2, '(src: string, reviver: Reviver, options?: (ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions) | undefined): any', gave the following error.
openapi-2-kong: Argument of type 'string' is not assignable to parameter of type 'Reviver'.
openapi-2-kong: 100 const parsedSpec = YAML.parse(k8sFixtureFileString, 'utf8');
* removes unnecessary plugin indirection
there is no reason to have functions that literally call other functions with the same argument. well... maybe not _no_ reason, but the one valid reason I can think of (to satisfy an abstraction's constraints) is not met here. This serves no documentational value either because it creates indirection rather than showing what it's really doing (which is, to generate a plugin).
* reworks generatePlugins and generatePlugin signatures
adds Entry, removes optional `tags`, curries
* use option parameter syntax for generateRequestValidatorPlugin
also, many errors were occurring for OA3Operation.responses not being passed over and over again, leading me to believe it's valid to do so.
* ensures `generateOperationPlugins` has tags, uses option parameter
* removes flowtype comments
* updates readme examples along with readme function signatures
parseSpec and generate were `async` but never awaited
Co-authored-by: Opender Singh <opender.singh@konghq.com>
* updates Kubernetes types to actually match Kuberenetes Ingress/v1beta1 API
* checks type of result in tests
among other cosmetic changes
* enables strict mode in o2k (but leaves bug it uncovered that this PR fixes)
I really do need this to complete the task at hand. For example, there was an existing error in `ingressDocWithOverride`:
```
Type 'string | null | undefined' is not assignable to type 'string | undefined'.
Type 'null' is not assignable to type 'string | undefined'.ts(2322)
kubernetes-config.ts(36, 3): The expected type comes from property 'path' which is declared here on type 'K8sHTTPIngressPath'
```
That is caught only by strict mode. This is literally what I am fixing in this PR, so it seems like as good a time as any. Thankfully, only took me ~30 minutes to do because it was already super close.
* fixtures for `kong-for-kubernetes`
* index exporters for actual exports
when I made these files, I didn't understand that the lower-level helpers are not actually exported by the library, therefore there's no reason to have these index.ts files.
Furthermore, the types file could use it's own for the same reason, because those types _are_ actually exported.
* fixes bug: TLS is now an array and a child of K8sIngress.spec
* updates 'yaml'
for some reason I cannot explain, suddenly the CI is failing constantly because of this package. https://github.com/Kong/insomnia/runs/2639615988
The only `yaml` exports we use in`o2k` are `parse` and `stringify` and we don't re-export it in any way. Therefore, we should be safe to update it (many other projects in the monorepo are on different versions anyway). This recent version is written purely in TypeScript, so we don't need the types packages anymore.
* adds a few more docs
* makes this `yaml` import match all others
for better or for worse, until we upgrade `YAML` (it's now written in TypeScript) we should probably aim for consistency.
* adds overloads so that types of package exports
it would be FAR preferable to use an object with the arguments instead because then we don't have to fall into all the traps that come with overloads, but I am avoiding changing the actual call signature of these function.
* fixes and updates types
* corrects mispelling
* removes shim types and exports actual types from openapi-2-kong
we had everything in place for the rest of the build pipeline to consume these types, but were missing the main exports at the root index.ts file
* use actual openapi-2-kong types now that they're available
* use existing variable for filePath
* extracts o2k-specific helper data to live in o2k
evidently, this data is useful for the usage of o2k, therefore o2k should be the thing exporting it.
* use KubernetesManifest for name of kubernetes manifest union
when first naming this, I didn't have much more context than the property name (documents), so after taking a look, it's clear that these are kubernetes manifests
* removes attempt at correctly typing overloads
I will return to this, and so I'm leaving it here in a commit rather than squashing it out, but I can't see a way to get it to work without changing the signature in a big way.
* fixes error (now that there are yaml types)
* makes `K8s` vs `Kubernetes` type terminology consistent
part of the motivation for this is that there are significant things in common between the two kinds of configs, making them closer in form is therefore ideal.
* updates mistake in name per review feedback
* split url into components on a `service`
also fixes a bug to use the upstream name in a service instead
of an actual hostname from the 'servers' block
* fix parseUrl to not return 'null:null'
* do not add targets if there is no hostname
previously a server with just a path; '/some/path' would generate
a target 'null:null'.
* Update packages/openapi-2-kong/src/declarative-config/services.js
* Update packages/openapi-2-kong/src/declarative-config/services.js
Co-authored-by: Opender Singh <opender.singh@konghq.com>
existing regex '\S+' is equivalent to '[^\s]+' by adding the
'/' character as not allowed, we limit the regex to match only 1 path
segment
This path: "/tracks/{hello}/world/{there}”
Would create: “/tracks/(?<hello>\S+)/world/(?<there>\S+)$”
This path works as expected:
/tracks/xxx/world/yyy
With captures:
hello: xxx
there: yyy
This path also works, unexpected:
/tracks/xxx/zzz/world/yyy/andthensome
With captures:
hello: xxx/zzz
there: yyy/andthensome
The last one should have matched only a single path segment, but
actually matches multiple.