Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restgen json access enhancements #487

Closed
leondz opened this issue Feb 19, 2024 · 0 comments · Fixed by #651
Closed

restgen json access enhancements #487

leondz opened this issue Feb 19, 2024 · 0 comments · Fixed by #651
Assignees
Labels
enhancement Architectural upgrades generators Interfaces with LLMs
Milestone

Comments

@leondz
Copy link
Collaborator

leondz commented Feb 19, 2024

currently, when services return json, folk can only specify a top-level dict key from where to get the response

this doesn't work - it might a list, or not top level, or...

proposal: move to a JSONPath in the response_json_field variable

logic:

  • if response_json_field contains no JSONPath special chars, treat it as a top-level dict key (retaining backward compat)
  • if response_json_field starts with a $, treat is as a raw JSONPath
  • if response_json_field contains JSONPath special chars, treat it as a JSONPath, but prepend a $ (this allows python-like structures such as [0][0]
  • if we're very nice, write a note suggesting people escape stuff from the YAML parser

JSONPath likes to return a list. hmm

  • if the result is a str: return that str
  • if the result is a list of 1: return result[0]
  • if the result is a list of len>1: return the list
  • note that the output should be List[str]. if we're really nice, we could type check that, and log an error if we don't get it back
@leondz leondz added enhancement Architectural upgrades generators Interfaces with LLMs labels Feb 19, 2024
@leondz leondz added this to the release 0.9.1 milestone Mar 24, 2024
@leondz leondz self-assigned this May 2, 2024
@leondz leondz linked a pull request May 2, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Architectural upgrades generators Interfaces with LLMs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant