def go(): optionStr = '' lowerVersionFilePath = '' higherVersionFilePath = '' if len(sys.argv) > 3 : optionStr = sys.argv[1] lowerVersionFilePath = sys.argv[2] higherVersionFilePath = sys.argv[3] elif len(sys.argv) > 2 : lowerVersionFilePath = sys.argv[1] higherVersionFilePath = sys.argv[2] else: print('Two files needed to diff') exit(1) options = parseOptions(optionStr) lowerVersionFile = dereferenceBrAPI(lowerVersionFilePath) higherVersionFile = dereferenceBrAPI(higherVersionFilePath) deletedDeprecatedPaths, deletedPaths, modifiedPaths, addedPaths = comparePaths(lowerVersionFile, higherVersionFile) compareParams(modifiedPaths, lowerVersionFile, higherVersionFile) compareResults(modifiedPaths, lowerVersionFile, higherVersionFile) printResults(deletedDeprecatedPaths, deletedPaths, modifiedPaths, addedPaths, options)
def buildReadMes(rootPath, specificPath): fullBrAPI = dereferenceAll.dereferenceBrAPI(filePath=rootPath + '/brapi_openapi.yaml') for dir in glob.iglob(rootPath + specificPath + '/', recursive=False): readMeStr = buildReadMe(dir, fullBrAPI) fileName = dir + '/README.md' with open(fileName, 'w') as outfile: outfile.write(readMeStr) print("fileName - " + fileName)
def go(filePath='./brapi_openapi.yaml'): fileObj = dereferenceAll.dereferenceBrAPI(filePath) searchList = transform(fileObj) search(searchList)
schemaObj = { "$schema": "http://json-schema.org/draft-04/schema#", "title": "metadata", "type": "object", "properties": { "metadata": metaSchema }, "required": ["metadata"] } filename = rootPath + 'schemas/v1.3/metadata.json' os.makedirs(os.path.dirname(filename), exist_ok=True) with open(filename, 'w') as outfile: json.dump(schemaObj, outfile, indent=4, sort_keys=True) rootPath = './out/' verbose = False if len(sys.argv) > 1: rootPath = sys.argv[1] if rootPath[-1] != '/': rootPath = rootPath + '/' if len(sys.argv) > 2: verbose = sys.argv[2] == '-v' parentFile = dereferenceAll.dereferenceBrAPI() buildCollection(parentFile) buildMetaData(parentFile)
def addDataType(self, dataType): self.dataTypes.append(dataType) def addVersions(self, version): self.versions = list(set(self.versions + version)) self.versions.sort() ##---------------------------------------------------------------------- class MyEncoder(JSONEncoder): def default(self, o): return o.__dict__ ##---------------------------------------------------------------------- fileObj = dereferenceAll.dereferenceBrAPI('./brapi_openapi.yaml') baseURL = 'http://localhost:8080/brapi/v1' change = raw_input('Test URL (default: ' + baseURL + ') > ') if change != '': baseURL = change calls = [] unavCalls = [] badCalls = [] reg = re.compile('\{[^\{\}]*\}') if 'paths' in fileObj: for path in list(fileObj['paths'].keys()): testURL = ''
os.makedirs(os.path.dirname(filename), exist_ok=True) with open(filename, 'w') as outfile: json.dump(schemaObj, outfile, indent=4, sort_keys=True) outPath = './out/' yamlPath = './brapi_openapi.yaml' versionNumber = 'vX.X' verbose = False verbose = '-v' in sys.argv if '-version' in sys.argv: vi = sys.argv.index('-version') versionNumber = sys.argv[vi + 1] if '-brapi' in sys.argv: bi = sys.argv.index('-brapi') yamlPath = sys.argv[bi + 1] if '-out' in sys.argv: ri = sys.argv.index('-out') outPath = sys.argv[ri + 1] if outPath[-1] != '/': outPath = outPath + '/' parentFile = dereferenceAll.dereferenceBrAPI(filePath=yamlPath) buildCollection(parentFile) buildMetaData(parentFile)
for method in obj['paths'][path]: for responseCode in obj['paths'][path][method][ 'responses']: if responseCode == '200' and 'content' in obj['paths'][ path][method]['responses'][responseCode]: response = obj['paths'][path][method]['responses'][ responseCode]['content']['application/json'] if ('schema' in response): schema = deepcopy(response['schema']) success, error = testPath(schema, path, method) if not success: print(error) return obj rootPath = '/' verbose = False baseURL = 'http://localhost:8080/brapi/v1' if len(sys.argv) > 1: rootPath += sys.argv[1] if len(sys.argv) > 2: verbose = sys.argv[2] == '-v' print(rootPath) brapi = dereferenceAll.dereferenceBrAPI( 'C:/Users/ps664/Documents/BrAPI/API/brapi_openapi.yaml') testPaths(brapi)
if type(parent[fieldName]) is dict: newParent[fieldName] = allowNullFields(parent[fieldName]) return newParent outPath = './out/' yamlPath = './brapi_openapi.yaml' verbose = False verbose = '-v' in sys.argv if '-brapi' in sys.argv: bi = sys.argv.index('-brapi') yamlPath = sys.argv[bi + 1] if '-out' in sys.argv: ri = sys.argv.index('-out') outPath = sys.argv[ri + 1] if outPath[-1] != '/': outPath = outPath + '/' if verbose: print('input YAML file: ' + yamlPath) print('output directory: ' + outPath) parentFile = dereferenceAll.dereferenceBrAPI(yamlPath, verbose) buildJSONSchemas(parentFile, verbose)