httpie / http-prompt

An interactive command-line HTTP and API testing client built on top of HTTPie featuring autocomplete, syntax highlighting, and more. https://twitter.com/httpie
https://http-prompt.com
MIT License
8.96k stars 326 forks source link

Collects parameters directly below of the endpoint paths #154

Closed michilu closed 3 years ago

michilu commented 5 years ago

The endpoint paths can have the parameters to directly below.

An example: https://github.com/apiaryio/swagger-zoo/blob/aa9118ac8db87594fb9ceb4e5c7ad0bb55a7a2f3/fixtures/examples/swagger/instagram.yaml#L215-L219

paths:
  /users/{user-id}:
    parameters:
      - $ref: '#/parameters/user-id'
    get:
      ...
nicolai-shape commented 4 years ago

I need this. It basically means I can't load any of my specs because they all use parameters like this.

lalmeras commented 3 years ago

I just push a PR #188 addressing the same issue, and see this PR afterward.

It seems to me that this PR does not handle parameter unicity when it merges parameters values from Path and Operation. And it doesn't seem it includes anything more than my PR.

lalmeras commented 3 years ago

PR #188 was merged today and address the same issue.

@michilu @nicolai-shape Does current master fix your issue ?

michilu commented 3 years ago

@lalmeras Yes, it works!

before 189321f:

$ poetry run http-prompt https://www.instagram.com --spec instagram.yaml
.venv/lib/python3.9/site-packages/http_prompt/cli.py:118: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  spec = yaml.load(content)
Traceback (most recent call last):
  File ".venv/bin/http-prompt", line 33, in <module>
    sys.exit(load_entry_point('http-prompt==1.0.0', 'console_scripts', 'http-prompt')())
  File ".venv/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File ".venv/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File ".venv/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File ".venv/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File ".venv/lib/python3.9/site-packages/http_prompt/cli.py", line 128, in cli
    context = Context(url, spec=spec)
  File ".venv/lib/python3.9/site-packages/http_prompt/context/__init__.py", line 39, in __init__
    params = info.get('parameters')
AttributeError: 'list' object has no attribute 'get'

now ac598fd:

$ poetry run http-prompt https://www.instagram.com --spec instagram.yaml
Version: 1.0.0
.venv/lib/python3.9/site-packages/http_prompt/cli.py:119: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  spec = yaml.load(content)
https://www.instagram.com> 

Thanks!