Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

UnboundLocalError: local variable 'field' referenced before assignment #128

@yudongya

Description

@yudongya

import apistar
import yaml
import json
from apistar import Link
from typesystem import to_json_schema

def get_link(link: Link):
_data = {}
for field in link.fields:

    _data[field.name] = to_json_schema(field.schema)

return _data
#_data[link.fields[1].name] = to_json_schema(link.fields[1].schema)

str= open('API/api.json', encoding="utf-8")
openapi = json.load(str)
client = apistar.Client(openapi)
link = client.lookup_operation("uploadFile")
print(get_link(link))

run result
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions