Giter VIP home page Giter VIP logo

Comments (2)

nikitastupin avatar nikitastupin commented on July 17, 2024

As far as I understood we can fix this by not raising https://github.com/Yelp/bravado-core/blob/015a2cd8baf1ecdf0af2739452871ee19bc7b3d1/bravado_core/model.py#L71 exception. However I'm not sure about side effects of this solution 😃

from bravado.

macisamuele avatar macisamuele commented on July 17, 2024

@nikitastupin Thanks a lot for reporting this. I've done some investigations, results are down the comment.

TL;DR; You could configure bravado to not use models in order to workaround the issue.

(venv) maci:~/ $ # It works
(venv) maci:~/ $ python3 -c 'from bravado.client import SwaggerClient; SwaggerClient.from_url("https://firefox.settings.services.mozilla.com/v1/__api__",config={"use_models": False})' &> /dev/null; echo $?

0
(venv) maci:~/ $ # It fails (as reported)
(venv) maci:~/ $ python3 -c 'from bravado.client import SwaggerClient; SwaggerClient.from_url("https://firefox.settings.services.mozilla.com/v1/__api__",config={"use_models": True})' &> /dev/null; echo $?

1
(venv) maci:~/ $                                                                                                                                                         [21:47:32]

Details
The reported issue is caused by the fact that bravado, using the default configurations, tries to define python classes that represent the models available on the specifications.
NOTE: The models discovery is actually performed by bravado-core and documented in here.

The python classes are named according to the x-model attribute, if present, or title as fallback.
The specifications report multiple usages of title: SchemaNode, title: ErrorSchema, etc. (full list at the end of this comment).

In order to prevent failures you might configure the bravado client to not use models (in this case a warning will be rendered) (documented in here).

A possible improvement (and I would suggest opening it into the bravado-core project) could be to make the model discovery smarter by allowing namesake models to coexist if their definition is exactly the same (as seems happening with the mozilla specifications).

Considering the above mentioned details this does not seems being an issue into bravado, but rather a potential feature request for bravado-core (which I would recommend opening in the correct project).


Full list of duplicated model names

(venv) maci:~/ $ curl --silent https://firefox.settings.services.mozilla.com/v1/__api__ | jq . | grep title | cut -d: -f2 | cut -d'"' -f2 | sort | uniq -dc | sort -n    [21:41:32]
      2 Cache Expires
      2 Collection
      2 Members
      2 Method
      3 Body
      3 Headers
      3 Path
      4 ObjectSchema
      4 Permissions
      4 Read
      4 Write
      7 Schema
      7 SchemaNode
     60 Code
     60 Errno
     60 Error
     60 ErrorSchema
     60 Info
     60 Message
(venv) maci:~/ $                                                                                                                                                         [21:41:36]

NOTE: The extraction is done in best-effort mode (aka there might be false-positive/false-negative) but is representative enough of the issue.

from bravado.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.