openapi-spec-validator
openapi-spec-validator copied to clipboard
How to read from string?
I couldn't find a way to read from a string, without spamming a temporary file.
from openapi_spec_validator import validate
schema_text = """{"openapi": "3.0.0"}"""
schema: Schema = ???(schema_text)
validate(schema)
echo "string" | openapi-spec-validator -
Apologies, I mean from within python.
there's read_from_filename, read_from_stdin, but no read_from_str.
just use json.loads?
@luckydonald Code similar to this may do what you want.
import json
import pathlib
from openapi_spec_validator import validate
schema = json.loads(pathlib.Path("your-file.json").read_text())
validate(schema)
@p1c2u I recommend closing this issue. It's had no follow-up in the past year.