fencer icon indicating copy to clipboard operation
fencer copied to clipboard

Does not support anyOf in the schema

Open dionysio opened this issue 7 months ago • 0 comments

Hi, just tried running your tool, in my schema I have something like this:

"ChatCreate":{"properties":{"topic_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Topic Id"}},"type":"object"

your parser crashes because of the missing type under the "topic_id" schema:

Traceback (most recent call last):
  File ".../python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File ".../python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.11/site-packages/fencer/cli.py", line 34, in run
    api_spec.load_endpoints()
  File "...lib/python3.11/site-packages/fencer/api_spec.py", line 255, in load_endpoints
    body=self.resolve_body(self.paths[path][method].get('requestBody')),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.11/site-packages/fencer/api_spec.py", line 273, in resolve_body
    schema = self.resolve_schema(body['content']['application/json']['schema']['$ref'])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.11/site-packages/fencer/api_spec.py", line 306, in resolve_schema
    if description['type'] == 'array' and '$ref' in description['items']:
       ~~~~~~~~~~~^^^^^^^^
KeyError: 'type'

When I removed this object, the tool went through correctly.

dionysio avatar Jun 30 '24 19:06 dionysio