checking dictionaries based on json schema
testSchema = 'https://gist.githubusercontent.com/thanakijwanavit/e2720d091ae0cef710a49b57c0c9cd4c/raw/ed2d322eac4900ee0f95b431d0f9067a40f3e0f0/squirrelOpenApiV0.0.3.yaml'
path = 'components/schemas/Location'
getSchemaPath(testSchema, path)
url = 'https://raw.githubusercontent.com/thanakijwanavit/villaMasterSchema/master/Product.json'
input_ = {'iprcode': 4, 'cprcode': 123 , 'oprCode': '123'}
validateUrl(url, input_)
errorProduct = [{ 'cprcode': '0171670', 'iprcode': '0171670', 'oprcode': '0171670', 'ordertype': 'Y', 'pr_abb': 'JIRAPAT YOUNG KALE 2', 'pr_active': 'Y', 'pr_cgcode': '05', 'pr_code': '0171670', 'pr_dpcode': '19', 'pr_engname': 'JIRAAT YOUNG KALE 200 G.', 'pr_ggcode': '057', 'pr_market': 'JIRAPAT ยอดคะน้า 200 G.', 'pr_name': 'JIRAPAT ยอดคะน้า 200 G.', 'pr_puqty': '1', 'pr_sa_method': '1', 'pr_sucode1': 'CM845', 'pr_suref3': 'A', 'prtype': 'I', 'psqty': '1', 'pstype': '1'}] #ProductDatabase.valueUpdate({'items':sampleProducts})
url = 'https://raw.githubusercontent.com/thanakijwanavit/villaMasterSchema/master/valueUpdate.json'
try:
validateUrl(url, errorProduct)
except Exception as e:
print(f'{e}')
url = 'https://gist.githubusercontent.com/thanakijwanavit/241c4cc443f39ea096820f5dfb84017d/raw/61694a0c5fbac3f6408fbb11217cc4265d38e38d/sampleYaml.yaml'
input_ = {'iprcode': 4, 'cprcode': 123 , 'oprCode': '123'}
print(validateUrl(url, input_, format_='yaml'))
try:
print(validateUrl(url, errorProduct, format_='yaml'))
except Exception as e:
print(f'{e}')
url = 'https://raw.githubusercontent.com/thanakijwanavit/villaMasterSchema/dev-manual/inventory/inventory.yaml'
getTypes(url)
url = 'https://raw.githubusercontent.com/thanakijwanavit/villaMasterSchema/dev-manual/inventory/inventory.yaml'
inv = {
'iprcode': '0000009',
'brcode': '1000',
'ib_cf_qty': '50',
'new_ib_vs_stock_cv': '27',
'onlineflag': True
}
typeMapJsonSchema(url, input_=inv)
typeMapJsonSchema(url, input_=inv)