Insomnia: Tags are not applied to plugin entities in the generated declarative config

Created on 1 Oct 2020  路  4Comments  路  Source: Kong/insomnia

Describe the bug
When the x-kong-plugin entity is used in a spec, when generating config using one of the entry point methods (for example generateFromString, the default tag or any tags provided are not applied to the generated declarative config of the plugin.

See example in the comment below.

To Reproduce
Steps to reproduce the behavior:

  1. In Insomnia Designer or the inso CLI, take a spec
  2. Click Generate Config or run inso generate config

Expected behavior
The generated declarative config should tag the Services, Routes and plug-ins appropriately.

INS-175

bug good first issue packagopenapi-2-kong

All 4 comments

Example spec:

openapi: 3.0.0
info:
  version: '1.5'
  title: LCE Order API
servers:
  - url: 'http://mockbin.org/request'
    description: mockbin
paths:    
  '/v1/order/{id}':
    get:
      summary: Fetches an order
      x-kong-plugin-mocking:
        enabled: true
        config:
          api_specification_filename: orders.yaml
      x-kong-plugin-rate-limiting:
        enabled: true
        config:
          minute: 5
          limit_by: ip
          policy: local

Should generate the following config:

_format_version: "1.1"
services:
  - name: LCE_Order_API
    url: http://mockbin.org/request
    plugins: []
    routes:
      - tags:
          - OAS3_import
        name: LCE_Order_API-path-get
        methods:
          - GET
        paths:
          - /v1/order/(?<id>\S+)$
        strip_path: false
        plugins:
          - name: mocking
            config:
              api_specification_filename: orders.yaml
+           tags: 
+             - OAS3_import 
          - name: rate-limiting
            config:
              minute: 5
              limit_by: ip
              policy: local
+           tags: 
+             - OAS3_import 
    tags:
      - OAS3_import
upstreams:
  - name: LCE_Order_API
    targets:
      - target: mockbin.org:80
    tags:
      - OAS3_import

Config is generated using insomnia-plugin-kong-declarative-config which, in turn uses openapi-2-kong, all existing in the code.

The tag value for plugins should be sourced from wherever the other tag values are sourced from - the various entry points in https://github.com/Kong/insomnia/blob/develop/packages/openapi-2-kong/src/index.js.

I'm a little confused about the examples provided for this issue. In the original post, the provided example shows a case where there is a tags array specified at the plugin object level, and it is not passed through to the plugin's declarative config. However, the "expected behavior" from the original post (as well as the example provided by @develohpanda) seem to refer to a different issue, where tags provided to the plugin's parent are not passed through to the plugin's output. Both of these appear to be issues, but I'm not sure which one should be fixed (maybe both :smile:).

I'll work a PR assuming that both items need to be addressed, but please let me know if it's actually one or the other.

Good eyes, and thanks for clarifying upfront @rmsy 馃憖

The only way to provide tags (currently) is to send them as arguments to the entry point functions in index.js. Here is some documentation showing how tags behave currently.

The original issue report overlaps another feature request - to provide tags _from the spec_ #2682 - which is not yet accepted.

I will remove the example from the original post and move it to the related issue. That will leave my comment with the example spec and the expected output, with _no tags_ in the input spec. In this example, the default OAS3_import tag, or any provided as an argument to, for example, generateFromString should be applied to the plugin.

Does that clear things up?

That clears it up, thank you!

Was this page helpful?
0 / 5 - 0 ratings