Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Spec.from_dict when fetching from url gets stuck in case validator is not none#641

Unanswered
itsMGA asked this question inQ&A
Discussion options

So I am loading the yaml from an url:

    url= "https://my_host.com/main.yaml"    response = requests.get(url)    spec_dict = yaml.load(response.text, Loader=yaml.SafeLoader)    return Spec.from_dict(spec_dict, base_uri=url)

Main.yaml schema looks something like

openapi: 3.0.1info:  title: Fictive API  description: |    Welcome to the Fictive API overview. This API provides basic functionality for integration between your application, our SDK, and the Fictive Platform.    The Fictive API allows you to:      - manage users      - manage events      - manage data    To work with most methods, you need to acquire an access token:    <ol>      <li> Call <a href="#post-/fictive/login">POST fictive/login</a></li>      <li> Copy the "access_token" from the response</li>      <li> Go to <a href="#auth">"Authentication"</a> section</li>      <li> Paste the token value into the "api-token" field</li>      <li> Click the "set" button</li>    </ol>  termsOfService: 'https://developer.fictive.com/termsOfService'  contact:    email: support@fictive.com  version: 1.0.0externalDocs:  description: Find out more about Swagger  url: 'http://swagger.io'servers:  - url: https://api-prod.fictive.com/  - url: https://api-stage.fictive.com/tags:  - name: auth    description: Authentication and authorization  - name: users    description: User management  - name: events    description: Event management  - name: data    description: Data managementcomponents:  schemas:    UserRequest:      type: object      oneOf:        - type: object          required: [ user_id ]          properties:            user_id:              type: integer        - type: object          required: [ username ]          properties:            username:              type: string  responses:    OkResponse:      description: Success.      content:        'application/json':          schema:            type: object            required: [ result ]            properties:              result:                type: string                enum: [ OK ]    BadRequestError:      description: Bad request.      content:        'application/json':          schema:            type: object            required: [ result ]            properties:              result:                type: string                enum: [ BAD_REQUEST ]    NotAuthorizedError:      description: Not authorized.      content:        'application/json':          schema:            type: object            required: [ result ]            properties:              result:                type: string                enum: [ NOT_AUTHORIZED ]    NotFoundError:      description: Not found.      content:        'application/json':          schema:            type: object            required: [ result ]            properties:              result:                type: string                enum: [ NOT_FOUND ]    UnsupportedMediaTypeError:      description: Unsupported Content-Type in request.      content:        'application/json':          schema:            type: object            required: [ result ]            properties:              result:                type: string                enum: [ UNSUPPORTED_MEDIA_TYPE ]    InternalServerError:      description: Internal server error.      content:        'application/json':          schema:            type: object            required: [ result ]            properties:              result:                type: string                enum: [ INTERNAL_SERVER_ERROR ]    ServiceUnavailableError:      description: Service unavailable.      content:        'application/json':          schema:            type: object            required: [ result ]            properties:              result:                type: string                enum: [ SERVICE_UNAVAILABLE ]  securitySchemes:    bearerAuth:      type: http      scheme: bearerpaths:  /fictive/login:    $ref: './methods/fictive/login.yaml'  /fictive/logout:    $ref: './methods/fictive/logout.yaml'  /fictive/users:    $ref: './methods/fictive/users.yaml'  /fictive/users/{user_id}:    $ref: './methods/fictive/users-by-user_id.yaml'  /fictive/users/{user_id}/events:    $ref: './methods/fictive/users-events-by-user_id.yaml'  /fictive/events:    $ref: './methods/fictive/events.yaml'  /fictive/events/{event_id}:    $ref: './methods/fictive/events-by-event_id.yaml'  /fictive/data:    $ref: './methods/fictive/data.yaml'  /fictive/data/{data_id}:    $ref: './methods/fictive/data-by-data_id.yaml'

And more references inside referenced files, problem is when an spec validation error happens it does not return anything, the program runs forever

i only got it to work and actually get it to raise errors by loading spec from file:
return Spec.from_file_path(file_path=path)

You must be logged in to vote

Replies: 1 comment 2 replies

Comment options

You don't get any output when you kill the process? What if you kill the process bykill -9 pid?

You must be logged in to vote
2 replies
@itsMGA
Comment options

Traceback (most recent call last):  File "C:\Users\MunteanuGabriel\Desktop\dummy\partner-apis-framework\dummy.py", line 31, in <module>    load_spec_from_url(PARTNER_API_SCHEMA_URL)  File "C:\Users\MunteanuGabriel\Desktop\dummy\partner-apis-framework\dummy.py", line 20, in load_spec_from_url    return Spec.from_dict(spec_dict, base_uri=url)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\openapi_core\spec\paths.py", line 27, in from_dict    validator.validate(data, base_uri=base_uri, spec_url=spec_url)  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\openapi_spec_validator\validation\proxies.py", line 31, in validate    for err in validator.iter_errors(  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\openapi_spec_validator\validation\decorators.py", line 22, in wrapper    for err in errors:  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\openapi_spec_validator\validation\validators.py", line 107, in iter_errors    yield from self._iter_paths_errors(paths)  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\openapi_spec_validator\validation\validators.py", line 117, in _iter_paths_errors    yield from self._iter_path_errors(url, path_item)  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\openapi_spec_validator\validation\validators.py", line 131, in _iter_path_errors    yield from self._iter_operation_errors(  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\openapi_spec_validator\validation\validators.py", line 164, in _iter_operation_errors    names += list(self._get_path_param_names(parameters))             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\openapi_spec_validator\validation\validators.py", line 211, in _get_path_param_names    for param in params:  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\pathable\paths.py", line 200, in iter    for idx in range(self.accessor.len(self.parts)):                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\pathable\accessors.py", line 45, in len    with self.open(parts) as d:  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 137, in __enter__    return next(self.gen)           ^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\jsonschema_spec\accessors.py", line 55, in open    resolved = self._resolve(self.lookup, parts_deque)               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\jsonschema_spec\accessors.py", line 88, in _resolve    return self._resolve(target, parts_deque, resolver=resolver)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\jsonschema_spec\accessors.py", line 88, in _resolve    return self._resolve(target, parts_deque, resolver=resolver)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\jsonschema_spec\accessors.py", line 77, in _resolve    resolved = resolver.lookup(ref)               ^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\referencing\_core.py", line 586, in lookup    retrieved = self._registry.get_or_retrieve(uri)                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\referencing\_core.py", line 336, in get_or_retrieve    resource = registry._retrieve(uri)               ^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\jsonschema_spec\retrievers.py", line 33, in __call__    contents = handler(uri)               ^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\jsonschema_spec\handlers\file.py", line 45, in __call__    return self._open(uri)           ^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\jsonschema_spec\handlers\requests.py", line 20, in _open    response = requests.get(url, timeout=self.timeout)               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\api.py", line 73, in get    return request("get", url, params=params, **kwargs)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\api.py", line 59, in request    return session.request(method=method, url=url, **kwargs)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 589, in request    resp = self.send(prep, **send_kwargs)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\sessions.py", line 703, in send    r = adapter.send(request, **kwargs)        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\requests\adapters.py", line 486, in send    resp = conn.urlopen(           ^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 790, in urlopen    response = self._make_request(               ^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 467, in _make_request    self._validate_conn(conn)  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py", line 1092, in _validate_conn    conn.connect()  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connection.py", line 642, in connect    sock_and_verified = _ssl_wrap_socket_and_match_hostname(                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connection.py", line 783, in _ssl_wrap_socket_and_match_hostname    ssl_sock = ssl_wrap_socket(               ^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\ssl_.py", line 469, in ssl_wrap_socket    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\ssl_.py", line 513, in _ssl_wrap_socket_impl    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 517, in wrap_socket    return self.sslsocket_class._create(           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1075, in _create    self.do_handshake()  File "C:\Users\MunteanuGabriel\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1346, in do_handshake    self._sslobj.do_handshake()KeyboardInterruptProcess finished with exit code -1073741510 (0xC000013A: interrupted by Ctrl+C)

Here it is

@p1c2u
Comment options

It's because of the following issuep1c2u/jsonschema-path#57

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@itsMGA@p1c2u

[8]ページ先頭

©2009-2025 Movatter.jp