tk0miya / sphinxcontrib-jsonschema

Other
2 stars 2 forks source link

Parse or ignore unknown fields #7

Open janbrohl opened 7 years ago

janbrohl commented 7 years ago

Please make sure to not stop the build when encountering unknown fields - ignoring them would be an option.

You could use https://schematic-ipsum.herokuapp.com/ with the core schema from http://json-schema.org/documentation.html to generate valid (but strange) schemas for testing.

tk0miya commented 7 years ago

Could you show me an example?

janbrohl commented 7 years ago

I thought an example would be required or enum but they seem to work now - so I cannot give a minimal example but I get an exception on the Core/Validation Meta-Schema that you can find on http://json-schema.org/documentation.html - I think it would be a good idea to test all schemas on that page and propably those from http://schemastore.org/json/ too.

Log for my exception:


# Sphinx version: 1.5.2
# Python version: 3.5.2 (CPython)
# Docutils version: 0.13.1 release
# Jinja2 version: 2.9.5
# Last messages:
#   Running Sphinx v1.5.2
#   loading translations [de]...
#   done
#   loading pickled environment...
#   done
#   building [mo]: targets for 0 po files that are out of date
#   building [html]: targets for 1 source files that are out of date
#   updating environment:
#   0 added, 1 changed, 0 removed
#   reading sources... [100%] index
# Loaded extensions:
#   sphinx.ext.doctest (1.5.2) from c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinx\ext\doctest.py
#   sphinx.ext.todo (1.5.2) from c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinx\ext\todo.py
#   alabaster (0.7.9) from c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\alabaster\__init__.py
#   sphinxcontrib.jsonschema (unknown version) from c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinxcontrib\jsonschema.py
#   sphinxcontrib.httpdomain (unknown version) from c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinxcontrib\httpdomain.py
#   sphinx.ext.autodoc (1.5.2) from c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinx\ext\autodoc.py
Traceback (most recent call last):
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinx\cmdline.py", line 296, in main
    app.build(opts.force_all, filenames)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinx\application.py", line 333, in build
    self.builder.build_update()
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinx\builders\__init__.py", line 251, in build_update
    'out of date' % len(to_build))
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinx\builders\__init__.py", line 265, in build
    self.doctreedir, self.app))
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinx\environment\__init__.py", line 556, in update
    self._read_serial(docnames, app)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinx\environment\__init__.py", line 576, in _read_serial
    self.read_doc(docname, app)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinx\environment\__init__.py", line 684, in read_doc
    pub.publish()
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\core.py", line 217, in publish
    self.settings)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinx\io.py", line 55, in read
    self.parse()
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\readers\__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\__init__.py", line 185, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\states.py", line 170, in run
    input_source=document['source'])
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\statemachine.py", line 239, in run
    context, state, transitions)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\states.py", line 2745, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\states.py", line 326, in section
    self.new_subsection(title, lineno, messages)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\states.py", line 394, in new_subsection
    node=section_node, match_titles=True)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\states.py", line 281, in nested_parse
    node=node, match_titles=match_titles)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\statemachine.py", line 239, in run
    context, state, transitions)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\states.py", line 2320, in explicit_markup
    self.explicit_list(blank_finish)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\states.py", line 2350, in explicit_list
    match_titles=self.state_machine.match_titles)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\states.py", line 318, in nested_list_parse
    node=node, match_titles=match_titles)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\statemachine.py", line 239, in run
    context, state, transitions)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\statemachine.py", line 460, in check_line
    return method(match, context, next_state)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\states.py", line 2623, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\states.py", line 2330, in explicit_construct
    return method(self, expmatch)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\states.py", line 2073, in directive
    directive_class, match, type_name, option_presets)
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\docutils\parsers\rst\states.py", line 2122, in run_directive
    result = directive_instance.run()
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinxcontrib\jsonschema.py", line 62, in run
    for prop in schema:
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinxcontrib\jsonschema.py", line 363, in __iter__
    for subprop in prop:
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinxcontrib\jsonschema.py", line 359, in __iter__
    for prop in self.get_properties():
  File "c:\users\janbr\documents\github\docu-scoutnet-apis\env\lib\site-packages\sphinxcontrib\jsonschema.py", line 380, in get_properties
    yield JSONSchema.instantiate(prefix + '*', attr)
UnboundLocalError: local variable 'attr' referenced before assignment
tk0miya commented 7 years ago

It seems related with additionalProperties. But, unfortunately, I don't have time to investigate. Could you check your schema defintion?