UNPKG

molstar

Version:

A comprehensive macromolecular library.

179 lines 6.61 kB
/** * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal <david.sehnal@gmail.com> */ import { __spreadArray } from "tslib"; import { VERSION } from '../version'; import { QueryParamType, CommonQueryParamsInfo, QueryList } from './api'; import { ModelServerConfig as ServerConfig } from '../config'; export var shortcutIconLink = "<link rel='shortcut icon' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAnUExURQAAAMIrHrspHr0oH7soILonHrwqH7onILsoHrsoH7soH7woILwpIKgVokoAAAAMdFJOUwAQHzNxWmBHS5XO6jdtAmoAAACZSURBVDjLxZNRCsQgDAVNXmwb9f7nXZEaLRgXloXOhwQdjMYYwpOLw55fBT46KhbOKhmRR2zLcFJQj8UR+HxFgArIF5BKJbEncC6NDEdI5SatBRSDJwGAoiFDONrEJXWYhGMIcRJGCrb1TOtDahfUuQXd10jkFYq0ViIrbUpNcVT6redeC1+b9tH2WLR93Sx2VCzkv/7NjfABxjQHksGB7lAAAAAASUVORK5CYII=' />"; export function getApiSchema() { return { openapi: '3.0.0', info: { version: VERSION, title: 'ModelServer', description: 'The ModelServer is a service for accessing subsets of macromolecular model data.', }, tags: [ { name: 'General', } ], paths: getPaths(), components: { parameters: { id: { name: 'id', in: 'path', description: 'Id of the entry (i.e. 1tqn).', required: true, schema: { type: 'string', }, style: 'simple' }, } } }; } function getPaths() { var ret = {}; for (var _i = 0, QueryList_1 = QueryList; _i < QueryList_1.length; _i++) { var _a = QueryList_1[_i], name_1 = _a.name, definition = _a.definition; ret[ServerConfig.apiPrefix + "/v1/{id}/" + name_1] = getQueryInfo(definition); } var queryManySummary = 'Executes multiple queries at the same time and writes them as separate data blocks.'; var queryManyExample = { queries: [ { entryId: '1cbs', query: 'residueInteraction', params: { atom_site: [{ label_comp_id: 'REA' }], radius: 5 } }, { entryId: '1tqn', query: 'full', copy_all_categories: true } ], encoding: 'cif', asTarGz: false }; ret[ServerConfig.apiPrefix + "/v1/query-many"] = { get: { tags: ['General'], summary: queryManySummary, operationId: 'query-many', parameters: [{ name: 'query', in: 'query', description: 'URI encoded JSON object with the query definiton.', required: true, schema: { type: 'string', }, example: JSON.stringify(queryManyExample), style: 'simple' }], responses: { 200: { description: 'Separate CIF data blocks with the result', content: { 'text/plain': {}, 'application/octet-stream': {}, } } } }, post: { tags: ['General'], summary: queryManySummary, operationId: 'query-many-post', parameters: [], requestBody: { content: { 'application/json': { schema: { type: 'object' }, example: queryManyExample } } }, responses: { 200: { description: 'Separate CIF data blocks with the result', content: { 'text/plain': {}, 'application/octet-stream': {}, } } } } }; return ret; } function getQueryInfo(def) { var jsonExample = {}; def.jsonParams.forEach(function (p) { if (!p.exampleValues || !p.exampleValues.length) return; jsonExample[p.name] = p.exampleValues[0]; }); return { get: { tags: ['General'], summary: def.description, operationId: def.name, parameters: __spreadArray(__spreadArray([ { $ref: '#/components/parameters/id' } ], def.restParams.map(getParamInfo), true), CommonQueryParamsInfo.map(getParamInfo), true), responses: { 200: { description: def.description, content: { 'text/plain': {}, 'application/octet-stream': {}, } } } }, post: { tags: ['General'], summary: def.description, operationId: def.name + '-post', parameters: __spreadArray([ { $ref: '#/components/parameters/id' } ], CommonQueryParamsInfo.map(getParamInfo), true), requestBody: { content: { 'application/json': { schema: { type: 'object' }, example: jsonExample } } }, responses: { 200: { description: def.description, content: { 'text/plain': {}, 'application/octet-stream': {}, } } } } }; } function getParamInfo(info) { return { name: info.name, in: 'query', description: info.description, required: !!info.required, schema: { type: info.type === QueryParamType.String ? 'string' : info.type === QueryParamType.Integer ? 'integer' : info.type === QueryParamType.Boolean ? 'boolean' : 'number', enum: info.supportedValues ? info.supportedValues : void 0, default: info.defaultValue }, style: 'simple' }; } //# sourceMappingURL=api-schema.js.map