-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d357019
commit 86f810b
Showing
9 changed files
with
734 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
import json | ||
import os | ||
|
||
import requests | ||
|
||
from datacontract.model.exceptions import DataContractException | ||
|
||
|
||
def fetch_schema(location: str = None): | ||
|
||
if location is None: | ||
location = "https://datacontract.com/datacontract.schema.json" | ||
|
||
def fetch_schema(): | ||
schema_url = "https://datacontract.com/datacontract.schema.json" | ||
response = requests.get(schema_url) | ||
return response.json() | ||
if location.startswith("http://") or location.startswith("https://"): | ||
response = requests.get(location) | ||
return response.json() | ||
else: | ||
if not os.path.exists(location): | ||
raise DataContractException( | ||
type="lint", | ||
name=f"Reading schema from {path}", | ||
reason=f"The file '{path}' does not exist.", | ||
engine="datacontract", | ||
result="error" | ||
) | ||
with open(location, 'r') as file: | ||
file_content = file.read() | ||
return json.loads(file_content) |
Oops, something went wrong.