mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
- v2 generation ready, including javascript
This commit is contained in:
parent
cb1668fd1d
commit
4bfe976eac
7
src/client/interfaces/Model.d.ts
vendored
7
src/client/interfaces/Model.d.ts
vendored
@ -3,10 +3,17 @@ import { Schema } from './Schema';
|
||||
|
||||
export interface Model extends Schema {
|
||||
name: string;
|
||||
export: 'reference' | 'generic' | 'enum' | 'array' | 'dictionary' | 'interface';
|
||||
type: string;
|
||||
base: string;
|
||||
template: string | null;
|
||||
link: Model | null;
|
||||
description: string | null;
|
||||
isProperty: boolean;
|
||||
isReadOnly: boolean;
|
||||
isRequired: boolean;
|
||||
isNullable: boolean;
|
||||
imports: string[];
|
||||
extends: string[];
|
||||
enum: Enum[];
|
||||
enums: Model[];
|
||||
|
||||
13
src/client/interfaces/OperationParameter.d.ts
vendored
13
src/client/interfaces/OperationParameter.d.ts
vendored
@ -1,12 +1,7 @@
|
||||
import { Enum } from './Enum';
|
||||
import { Schema } from './Schema';
|
||||
import { Model } from './Model';
|
||||
|
||||
export interface OperationParameter extends Schema {
|
||||
prop: string;
|
||||
export interface OperationParameter extends Model {
|
||||
in: 'path' | 'query' | 'header' | 'formData' | 'body';
|
||||
name: string;
|
||||
default: any;
|
||||
isRequired: boolean;
|
||||
isNullable: boolean;
|
||||
enum: Enum[];
|
||||
prop: string;
|
||||
default?: any;
|
||||
}
|
||||
|
||||
4
src/client/interfaces/OperationResponse.d.ts
vendored
4
src/client/interfaces/OperationResponse.d.ts
vendored
@ -1,5 +1,5 @@
|
||||
import { Schema } from './Schema';
|
||||
import { Model } from './Model';
|
||||
|
||||
export interface OperationResponse extends Schema {
|
||||
export interface OperationResponse extends Model {
|
||||
code: number;
|
||||
}
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
import { Model } from './Model';
|
||||
|
||||
export interface Schema {
|
||||
export: 'reference' | 'generic' | 'enum' | 'array' | 'dictionary' | 'interface';
|
||||
type: string;
|
||||
base: string;
|
||||
template: string | null;
|
||||
link: Model | null;
|
||||
description: string | null;
|
||||
imports: string[];
|
||||
}
|
||||
@ -9,6 +9,7 @@ import { getEnum } from './getEnum';
|
||||
import { getEnumType } from './getEnumType';
|
||||
import { getEnumFromDescription } from './getEnumFromDescription';
|
||||
import { getModel } from './getModel';
|
||||
import { getOperationParameterDefault } from './getOperationParameterDefault';
|
||||
|
||||
export function getOperationParameter(openApi: OpenApi, parameter: OpenApiParameter): OperationParameter {
|
||||
const operationParameter: OperationParameter = {
|
||||
@ -21,11 +22,16 @@ export function getOperationParameter(openApi: OpenApi, parameter: OpenApiParame
|
||||
template: null,
|
||||
link: null,
|
||||
description: getComment(parameter.description),
|
||||
default: parameter.default,
|
||||
default: getOperationParameterDefault(parameter.default),
|
||||
isProperty: false,
|
||||
isReadOnly: false,
|
||||
isRequired: parameter.required || false,
|
||||
isNullable: false,
|
||||
imports: [],
|
||||
extends: [],
|
||||
enum: [],
|
||||
enums: [],
|
||||
properties: [],
|
||||
};
|
||||
|
||||
if (parameter.$ref) {
|
||||
@ -77,6 +83,7 @@ export function getOperationParameter(openApi: OpenApi, parameter: OpenApiParame
|
||||
operationParameter.base = items.base;
|
||||
operationParameter.template = items.template;
|
||||
operationParameter.imports.push(...items.imports);
|
||||
operationParameter.imports.push('Dictionary');
|
||||
return operationParameter;
|
||||
}
|
||||
|
||||
@ -91,12 +98,16 @@ export function getOperationParameter(openApi: OpenApi, parameter: OpenApiParame
|
||||
return operationParameter;
|
||||
} else {
|
||||
const model = getModel(openApi, parameter.schema);
|
||||
operationParameter.export = 'interface';
|
||||
operationParameter.export = model.export;
|
||||
operationParameter.type = model.type;
|
||||
operationParameter.base = model.base;
|
||||
operationParameter.template = model.template;
|
||||
operationParameter.link = model.link;
|
||||
operationParameter.imports.push(...model.imports);
|
||||
operationParameter.link = model;
|
||||
operationParameter.extends.push(...model.extends);
|
||||
operationParameter.enum.push(...model.enum);
|
||||
operationParameter.enums.push(...model.enums);
|
||||
operationParameter.properties.push(...model.properties);
|
||||
return operationParameter;
|
||||
}
|
||||
}
|
||||
|
||||
15
src/openApi/v2/parser/getOperationParameterDefault.ts
Normal file
15
src/openApi/v2/parser/getOperationParameterDefault.ts
Normal file
@ -0,0 +1,15 @@
|
||||
export function getOperationParameterDefault(value: any): string | null {
|
||||
if (value === null) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
switch (typeof value) {
|
||||
case 'number':
|
||||
case 'boolean':
|
||||
return JSON.stringify(value);
|
||||
case 'string':
|
||||
return `'${value}'`;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -25,6 +25,7 @@ export function getOperationResponses(openApi: OpenApi, responses: OpenApiRespon
|
||||
// free to do their own casting if needed.
|
||||
if (responseCode) {
|
||||
const operationResponse: OperationResponse = {
|
||||
name: '',
|
||||
code: responseCode,
|
||||
description: getComment(response.description)!,
|
||||
export: 'generic',
|
||||
@ -32,7 +33,15 @@ export function getOperationResponses(openApi: OpenApi, responses: OpenApiRespon
|
||||
base: PrimaryType.OBJECT,
|
||||
template: null,
|
||||
link: null,
|
||||
isProperty: false,
|
||||
isReadOnly: false,
|
||||
isRequired: false,
|
||||
isNullable: false,
|
||||
imports: [],
|
||||
extends: [],
|
||||
enum: [],
|
||||
enums: [],
|
||||
properties: [],
|
||||
};
|
||||
|
||||
// If this response has a schema, then we need to check two things:
|
||||
@ -53,8 +62,12 @@ export function getOperationResponses(openApi: OpenApi, responses: OpenApiRespon
|
||||
operationResponse.type = model.type;
|
||||
operationResponse.base = model.base;
|
||||
operationResponse.template = model.template;
|
||||
operationResponse.link = model.link;
|
||||
operationResponse.imports.push(...model.imports);
|
||||
operationResponse.link = model;
|
||||
operationResponse.extends.push(...model.extends);
|
||||
operationResponse.enum.push(...model.enum);
|
||||
operationResponse.enums.push(...model.enums);
|
||||
operationResponse.properties.push(...model.properties);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
import { PrimaryType } from './constants';
|
||||
import { OperationResponse } from '../../../client/interfaces/OperationResponse';
|
||||
import { Schema } from '../../../client/interfaces/Schema';
|
||||
import { Model } from '../../../client/interfaces/Model';
|
||||
|
||||
function areEqual(a: Schema, b: Schema): boolean {
|
||||
return a.type === b.type && a.base === b.base && a.template === b.template;
|
||||
function areEqual(a: Model, b: Model): boolean {
|
||||
const equal = a.type === b.type && a.base === b.base && a.template === b.template;
|
||||
if (equal && a.link && b.link) {
|
||||
return areEqual(a.link, b.link);
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
|
||||
export function getOperationResults(operationResponses: OperationResponse[]): OperationResponse[] {
|
||||
@ -17,14 +21,23 @@ export function getOperationResults(operationResponses: OperationResponse[]): Op
|
||||
|
||||
if (!operationResults.length) {
|
||||
operationResults.push({
|
||||
name: '',
|
||||
code: 200,
|
||||
description: '',
|
||||
export: 'interface',
|
||||
type: PrimaryType.OBJECT,
|
||||
base: PrimaryType.OBJECT,
|
||||
template: null,
|
||||
imports: [],
|
||||
link: null,
|
||||
isProperty: false,
|
||||
isReadOnly: false,
|
||||
isRequired: false,
|
||||
isNullable: false,
|
||||
imports: [],
|
||||
extends: [],
|
||||
enum: [],
|
||||
enums: [],
|
||||
properties: [],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,8 @@
|
||||
|
||||
export let OpenAPI;
|
||||
(function (OpenAPI) {
|
||||
OpenAPI.BASE = '';
|
||||
OpenAPI.BASE = '{{{server}}}';
|
||||
OpenAPI.VERSION = '{{{version}}}';
|
||||
OpenAPI.CLIENT = '{{{httpClient}}}';
|
||||
OpenAPI.TOKEN = '';
|
||||
OpenAPI.VERSION = '{VERSION}';
|
||||
})(OpenAPI || (OpenAPI = {}));
|
||||
@ -7,5 +7,5 @@
|
||||
* @param status Status code
|
||||
*/
|
||||
export function isSuccess(status) {
|
||||
return (status >= 200 && status < 300);
|
||||
return status >= 200 && status < 300;
|
||||
}
|
||||
|
||||
@ -2,17 +2,18 @@
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
|
||||
import { getFormData } from './getFormData';
|
||||
import { getQueryString } from './getQueryString';
|
||||
import { OpenAPI } from './OpenAPI';
|
||||
import { requestUsingFetch } from './requestUsingFetch';
|
||||
import {getFormData} from './getFormData';
|
||||
import {getQueryString} from './getQueryString';
|
||||
import {OpenAPI} from './OpenAPI';
|
||||
import {requestUsingFetch} from './requestUsingFetch';
|
||||
import {requestUsingXHR} from './requestUsingXHR';
|
||||
|
||||
/**
|
||||
* Create the request.
|
||||
* @param options Request method options.
|
||||
* @returns Result object (see above)
|
||||
*/
|
||||
export async function request<T>(options) {
|
||||
export async function request(options) {
|
||||
|
||||
// Create the request URL
|
||||
let url = `${OpenAPI.BASE}${options.path}`;
|
||||
@ -20,14 +21,14 @@ export async function request<T>(options) {
|
||||
// Create request headers
|
||||
const headers = new Headers({
|
||||
...options.headers,
|
||||
Accept: 'application/json',
|
||||
Accept: 'application/json'
|
||||
});
|
||||
|
||||
// Create request settings
|
||||
const request = {
|
||||
headers,
|
||||
method: options.method,
|
||||
credentials: 'same-origin',
|
||||
credentials: 'same-origin'
|
||||
};
|
||||
|
||||
// If we have a bearer token then we set the authentication header.
|
||||
@ -43,7 +44,6 @@ export async function request<T>(options) {
|
||||
// Append formData as body
|
||||
if (options.formData) {
|
||||
request.body = getFormData(options.formData);
|
||||
|
||||
} else if (options.body) {
|
||||
|
||||
// If this is blob data, then pass it directly to the body and set content type.
|
||||
@ -60,16 +60,19 @@ export async function request<T>(options) {
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
return await requestUsingFetch(url, request);
|
||||
|
||||
switch (OpenAPI.CLIENT) {
|
||||
case 'xhr':
|
||||
return await requestUsingXHR(url, request);
|
||||
default:
|
||||
return await requestUsingFetch(url, request);
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
url,
|
||||
ok: false,
|
||||
status: 0,
|
||||
statusText: '',
|
||||
body: error,
|
||||
body: error
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
* @param url The url to request.
|
||||
* @param request The request object, containing method, headers, body, etc.
|
||||
*/
|
||||
export async function requestUsingFetch<T>(url, request) {
|
||||
export async function requestUsingFetch(url, request) {
|
||||
|
||||
// Fetch response using fetch API.
|
||||
const response = await fetch(url, request);
|
||||
@ -20,7 +20,7 @@ export async function requestUsingFetch<T>(url, request) {
|
||||
ok: response.ok,
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
body: null,
|
||||
body: null
|
||||
};
|
||||
|
||||
// Try to parse the content for any response status code.
|
||||
@ -29,7 +29,6 @@ export async function requestUsingFetch<T>(url, request) {
|
||||
const contentType = response.headers.get('Content-Type');
|
||||
if (contentType) {
|
||||
switch (contentType.toLowerCase()) {
|
||||
|
||||
case 'application/json':
|
||||
case 'application/json; charset=utf-8':
|
||||
result.body = await response.json();
|
||||
|
||||
@ -2,19 +2,18 @@
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
|
||||
import { isSuccess } from "./isSuccess";
|
||||
import { isSuccess } from './isSuccess';
|
||||
|
||||
/**
|
||||
* Request content using the new legacy XMLHttpRequest API. This method is usefull
|
||||
* Request content using the new legacy XMLHttpRequest API. This method is useful
|
||||
* when we want to request UTF-16 content, since it natively supports loading UTF-16.
|
||||
* We could do the same with the Fetch API, but then we will need to conver the
|
||||
* We could do the same with the Fetch API, but then we will need to convert the
|
||||
* content using JavaScript... And that is very very slow.
|
||||
* @param url The url to request.
|
||||
* @param request The request object, containing method, headers, body, etc.
|
||||
*/
|
||||
export async function requestUsingXHR<T>(url, request) {
|
||||
return new Promise(resole => {
|
||||
|
||||
export async function requestUsingXHR(url, request) {
|
||||
return new Promise(resolve => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
|
||||
// Open the request, remember to do this before adding any headers,
|
||||
@ -37,7 +36,7 @@ export async function requestUsingXHR<T>(url, request) {
|
||||
ok: isSuccess(xhr.status),
|
||||
status: xhr.status,
|
||||
statusText: xhr.statusText,
|
||||
body: null,
|
||||
body: null
|
||||
};
|
||||
|
||||
// Try to parse the content for any response status code.
|
||||
@ -46,7 +45,6 @@ export async function requestUsingXHR<T>(url, request) {
|
||||
const contentType = xhr.getResponseHeader('Content-Type');
|
||||
if (contentType) {
|
||||
switch (contentType.toLowerCase()) {
|
||||
|
||||
case 'application/json':
|
||||
case 'application/json; charset=utf-8':
|
||||
result.body = JSON.parse(xhr.responseText);
|
||||
|
||||
@ -3,16 +3,17 @@
|
||||
/* prettier-ignore */
|
||||
|
||||
export { ApiError } from './core/ApiError';
|
||||
export { isSuccess } from './core/isSuccess';
|
||||
export { OpenAPI } from './core/OpenAPI';
|
||||
{{#if models}}
|
||||
|
||||
{{#each models}}
|
||||
export { {{{basename}}} } from './models/{{{basename}}}';
|
||||
{{#notEquals this 'Dictionary'}}export { {{{this}}} } from './models/{{{this}}}';{{/notEquals}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#if services}}
|
||||
|
||||
{{#each services}}
|
||||
export { {{{name}}} } from './services/{{{name}}}';
|
||||
export { {{{this}}} } from './services/{{{this}}}';
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
|
||||
@ -4,38 +4,21 @@
|
||||
|
||||
{{#if imports}}
|
||||
{{#each imports}}
|
||||
import { {{{this}}} } from '../models/{{{this}}}';
|
||||
{{#notEquals this 'Dictionary'}}import { {{{this}}} } from '../models/{{{this}}}';{{/notEquals}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
import * as yup from 'yup';
|
||||
|
||||
export let {{{base}}};
|
||||
(function ({{{base}}}) {
|
||||
|
||||
{{#each enums}}
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
{{{../base}}}.{{{name}}} = {
|
||||
{{#each values}}
|
||||
{{{name}}}: {{{value}}},
|
||||
{{/each}}
|
||||
};
|
||||
|
||||
{{/each}}
|
||||
|
||||
{{{../base}}}.schema = yup.object().shape({
|
||||
// Add properties
|
||||
};
|
||||
|
||||
{{{../base}}}.validate = function(value) {
|
||||
return schema.validate(value, { strict: true });
|
||||
};
|
||||
|
||||
{{{../base}}}.validateSync = function(value) {
|
||||
return schema.validateSync(value, { strict: true });
|
||||
};
|
||||
|
||||
})({{{base}}} || ({{{base}}} = {}));
|
||||
{{#equals export 'reference'}}
|
||||
{{>exportReference}}
|
||||
{{else equals export 'generic'}}
|
||||
{{>exportGeneric}}
|
||||
{{else equals export 'enum'}}
|
||||
{{>exportEnum}}
|
||||
{{else equals export 'array'}}
|
||||
{{>exportArray}}
|
||||
{{else equals export 'dictionary'}}
|
||||
{{>exportDictionary}}
|
||||
{{else equals export 'interface'}}
|
||||
{{>exportInterface}}
|
||||
{{/equals}}
|
||||
|
||||
19
src/templates/javascript/partials/exportArray.hbs
Normal file
19
src/templates/javascript/partials/exportArray.hbs
Normal file
@ -0,0 +1,19 @@
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
export let {{{name}}};
|
||||
(function ({{{name}}}) {
|
||||
|
||||
{{{name}}}.schema = {{>validation}};
|
||||
|
||||
{{{name}}}.validate = async function(value) {
|
||||
return {{{name}}}.schema.validate(value, { strict: true });
|
||||
};
|
||||
|
||||
{{{name}}}.validateSync = function(value) {
|
||||
return {{{name}}}.schema.validateSync(value, { strict: true });
|
||||
};
|
||||
|
||||
})({{{name}}} || ({{{name}}} = {}));
|
||||
19
src/templates/javascript/partials/exportDictionary.hbs
Normal file
19
src/templates/javascript/partials/exportDictionary.hbs
Normal file
@ -0,0 +1,19 @@
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
export let {{{name}}};
|
||||
(function ({{{name}}}) {
|
||||
|
||||
{{{name}}}.schema = {{>validation}};
|
||||
|
||||
{{{name}}}.validate = async function(value) {
|
||||
return {{{name}}}.schema.validate(value, { strict: true });
|
||||
};
|
||||
|
||||
{{{name}}}.validateSync = function(value) {
|
||||
return {{{name}}}.schema.validateSync(value, { strict: true });
|
||||
};
|
||||
|
||||
})({{{name}}} || ({{{name}}} = {}));
|
||||
23
src/templates/javascript/partials/exportEnum.hbs
Normal file
23
src/templates/javascript/partials/exportEnum.hbs
Normal file
@ -0,0 +1,23 @@
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
export let {{{name}}};
|
||||
(function ({{{name}}}) {
|
||||
|
||||
{{#each enum}}
|
||||
{{{../name}}}.{{{name}}} = {{{value}}};
|
||||
{{/each}}
|
||||
|
||||
{{{name}}}.schema = {{>validation}};
|
||||
|
||||
{{{name}}}.validate = async function(value) {
|
||||
return {{{name}}}.schema.validate(value, { strict: true });
|
||||
};
|
||||
|
||||
{{{name}}}.validateSync = function(value) {
|
||||
return {{{name}}}.schema.validateSync(value, { strict: true });
|
||||
};
|
||||
|
||||
})({{{name}}} || ({{{name}}} = {}));
|
||||
19
src/templates/javascript/partials/exportGeneric.hbs
Normal file
19
src/templates/javascript/partials/exportGeneric.hbs
Normal file
@ -0,0 +1,19 @@
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
export let {{{name}}};
|
||||
(function ({{{name}}}) {
|
||||
|
||||
{{{name}}}.schema = {{>validation}};
|
||||
|
||||
{{{name}}}.validate = async function(value) {
|
||||
return {{{name}}}.schema.validate(value, { strict: true });
|
||||
};
|
||||
|
||||
{{{name}}}.validateSync = function(value) {
|
||||
return {{{name}}}.schema.validateSync(value, { strict: true });
|
||||
};
|
||||
|
||||
})({{{name}}} || ({{{name}}} = {}));
|
||||
32
src/templates/javascript/partials/exportInterface.hbs
Normal file
32
src/templates/javascript/partials/exportInterface.hbs
Normal file
@ -0,0 +1,32 @@
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
export let {{{name}}};
|
||||
(function ({{{name}}}) {
|
||||
|
||||
{{#each enums}}
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
{{{../name}}}.{{{name}}} = {
|
||||
{{#each enum}}
|
||||
{{{name}}}: {{{value}}}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
};
|
||||
|
||||
{{/each}}
|
||||
{{{name}}}.schema = {{>validation}};
|
||||
|
||||
{{{name}}}.validate = async function(value) {
|
||||
return {{{name}}}.schema.validate(value, { strict: true });
|
||||
};
|
||||
|
||||
{{{name}}}.validateSync = function(value) {
|
||||
return {{{name}}}.schema.validateSync(value, { strict: true });
|
||||
};
|
||||
|
||||
})({{{name}}} || ({{{name}}} = {}));
|
||||
19
src/templates/javascript/partials/exportReference.hbs
Normal file
19
src/templates/javascript/partials/exportReference.hbs
Normal file
@ -0,0 +1,19 @@
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
export let {{{name}}};
|
||||
(function ({{{name}}}) {
|
||||
|
||||
{{{name}}}.schema = {{>validation}};
|
||||
|
||||
{{{name}}}.validate = async function(value) {
|
||||
return {{{name}}}.schema.validate(value, { strict: true });
|
||||
};
|
||||
|
||||
{{{name}}}.validateSync = function(value) {
|
||||
return {{{name}}}.schema.validateSync(value, { strict: true });
|
||||
};
|
||||
|
||||
})({{{name}}} || ({{{name}}} = {}));
|
||||
13
src/templates/javascript/partials/validation.hbs
Normal file
13
src/templates/javascript/partials/validation.hbs
Normal file
@ -0,0 +1,13 @@
|
||||
{{#equals export 'reference'}}
|
||||
{{>validationReference}}
|
||||
{{else equals export 'generic'}}
|
||||
{{>validationGeneric}}
|
||||
{{else equals export 'enum'}}
|
||||
{{>validationEnum}}
|
||||
{{else equals export 'array'}}
|
||||
{{>validationArray}}
|
||||
{{else equals export 'dictionary'}}
|
||||
{{>validationDictionary}}
|
||||
{{else equals export 'interface'}}
|
||||
{{>validationInterface}}
|
||||
{{/equals}}
|
||||
5
src/templates/javascript/partials/validationArray.hbs
Normal file
5
src/templates/javascript/partials/validationArray.hbs
Normal file
@ -0,0 +1,5 @@
|
||||
{{~#if link~}}
|
||||
yup.array().of({{>validation link}})
|
||||
{{~else~}}
|
||||
yup.array().of({{{base}}}.schema)
|
||||
{{~/if~}}
|
||||
19
src/templates/javascript/partials/validationDictionary.hbs
Normal file
19
src/templates/javascript/partials/validationDictionary.hbs
Normal file
@ -0,0 +1,19 @@
|
||||
{{~#if link~}}
|
||||
yup.lazy(value => {
|
||||
return yup.object().shape(
|
||||
Object.entries(value).reduce((obj, item) => ({
|
||||
...obj,
|
||||
[item[0]]: {{>validation link}}
|
||||
}), {})
|
||||
);
|
||||
})
|
||||
{{~else~}}
|
||||
yup.lazy(value => {
|
||||
return yup.object().shape(
|
||||
Object.entries(value).reduce((obj, item) => ({
|
||||
...obj,
|
||||
[item[0]]: {{{base}}}.schema
|
||||
}), {})
|
||||
);
|
||||
})
|
||||
{{~/if~}}
|
||||
9
src/templates/javascript/partials/validationEnum.hbs
Normal file
9
src/templates/javascript/partials/validationEnum.hbs
Normal file
@ -0,0 +1,9 @@
|
||||
yup.mixed().oneOf([
|
||||
{{#each enum}}
|
||||
{{#equals ../name name}}
|
||||
{{{value}}}{{#unless @last}},{{/unless}}
|
||||
{{else}}
|
||||
{{{../name}}}.{{{name}}}{{#unless @last}},{{/unless}}
|
||||
{{/equals}}
|
||||
{{/each}}
|
||||
])
|
||||
9
src/templates/javascript/partials/validationGeneric.hbs
Normal file
9
src/templates/javascript/partials/validationGeneric.hbs
Normal file
@ -0,0 +1,9 @@
|
||||
{{~#equals type 'boolean'~}}
|
||||
yup.boolean()
|
||||
{{~else equals type 'number'~}}
|
||||
yup.number()
|
||||
{{~else equals type 'string'~}}
|
||||
yup.string()
|
||||
{{~else~}}
|
||||
yup.mixed()
|
||||
{{~/equals~}}
|
||||
21
src/templates/javascript/partials/validationInterface.hbs
Normal file
21
src/templates/javascript/partials/validationInterface.hbs
Normal file
@ -0,0 +1,21 @@
|
||||
(
|
||||
{{#if extends}}
|
||||
{{#each extends}}
|
||||
{{{this}}}.schema.concat(
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#if properties}}
|
||||
yup.object().shape({
|
||||
{{#each properties}}
|
||||
{{{name}}}: yup.lazy(() => {{>validation}}.default(undefined){{#if isNullable}}.isNullable(){{/if}}){{#if isRequired}}.isRequired(){{/if}}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
}).noUnknown()
|
||||
{{else}}
|
||||
yup.object()
|
||||
{{/if}}
|
||||
{{#if extends}}
|
||||
{{#each extends}}
|
||||
)
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
)
|
||||
@ -0,0 +1 @@
|
||||
{{{base}}}.schema
|
||||
@ -24,43 +24,43 @@ export class {{{name}}} {
|
||||
* @param {{{name}}} {{{description}}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#each results}}
|
||||
* @result {{{type}}} {{{description}}}
|
||||
{{/each}}
|
||||
* @throws ApiError
|
||||
*/
|
||||
static async {{{name}}}({{#each parameters}}{{{name}}}{{#unless required}}?{{/unless}}{{#unless @last}}, {{/unless}}{{/each}}) {
|
||||
{{#if parameters}}
|
||||
|
||||
static async {{{name}}}({{#if parameters}}
|
||||
{{#each parameters}}
|
||||
{{#if required}}
|
||||
isValidRequiredParam({{{name}}}, '{{{name}}}');
|
||||
{{/if}}
|
||||
{{{name}}}{{#if default}} = {{{default}}}{{/if}}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{/if}}) {
|
||||
|
||||
const result = await request({
|
||||
method: '{{{method}}}',
|
||||
path: `{{{path}}}`,{{#if parametersHeader}}
|
||||
path: `{{{path}}}`{{#if parametersHeader}},
|
||||
headers: {
|
||||
{{#each parametersHeader}}
|
||||
'{{{prop}}}': {{{name}}},
|
||||
'{{{prop}}}': {{{name}}}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
},{{/if}}{{#if parametersQuery}}
|
||||
}{{/if}}{{#if parametersQuery}},
|
||||
query: {
|
||||
{{#each parametersQuery}}
|
||||
'{{{prop}}}': {{{name}}},
|
||||
'{{{prop}}}': {{{name}}}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
},{{/if}}{{#if parametersForm}}
|
||||
}{{/if}}{{#if parametersForm}},
|
||||
formData: {
|
||||
{{#each parametersForm}}
|
||||
'{{{prop}}}': {{{name}}},
|
||||
'{{{prop}}}': {{{name}}}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
},{{/if}}{{#if parametersBody}}
|
||||
body: {{{parametersBody.name}}},{{/if}}
|
||||
}{{/if}}{{#if parametersBody}},
|
||||
body: {{{parametersBody.name}}}{{/if}}
|
||||
});
|
||||
{{#if errors}}
|
||||
|
||||
if (!result.ok) {
|
||||
switch (result.status) {
|
||||
{{#each errors}}
|
||||
case {{{code}}}: throw new ApiError(result, `{{{text}}}`);
|
||||
case {{{code}}}: throw new ApiError(result, `{{{description}}}`);
|
||||
{{/each}}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
|
||||
export interface Result<T = any> {
|
||||
export interface Result {
|
||||
url: string;
|
||||
ok: boolean;
|
||||
status: number;
|
||||
statusText: string;
|
||||
body: T;
|
||||
body: any;
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ import {Result} from './Result';
|
||||
* @param options Request method options.
|
||||
* @returns Result object (see above)
|
||||
*/
|
||||
export async function request<T = any>(options: Readonly<RequestOptions>): Promise<Result<T>> {
|
||||
export async function request(options: Readonly<RequestOptions>): Promise<Result> {
|
||||
|
||||
// Create the request URL
|
||||
let url = `${OpenAPI.BASE}${options.path}`;
|
||||
@ -65,9 +65,9 @@ export async function request<T = any>(options: Readonly<RequestOptions>): Promi
|
||||
try {
|
||||
switch (OpenAPI.CLIENT) {
|
||||
case 'xhr':
|
||||
return await requestUsingXHR<T>(url, request);
|
||||
return await requestUsingXHR(url, request);
|
||||
default:
|
||||
return await requestUsingFetch<T>(url, request);
|
||||
return await requestUsingFetch(url, request);
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
|
||||
@ -12,7 +12,7 @@ import { Result } from './Result';
|
||||
* @param url The url to request.
|
||||
* @param request The request object, containing method, headers, body, etc.
|
||||
*/
|
||||
export async function requestUsingFetch<T = any>(url: string, request: Readonly<RequestInit>): Promise<Result<T>> {
|
||||
export async function requestUsingFetch(url: string, request: Readonly<RequestInit>): Promise<Result> {
|
||||
|
||||
// Fetch response using fetch API.
|
||||
const response = await fetch(url, request);
|
||||
|
||||
@ -14,7 +14,7 @@ import { isSuccess } from './isSuccess';
|
||||
* @param url The url to request.
|
||||
* @param request The request object, containing method, headers, body, etc.
|
||||
*/
|
||||
export async function requestUsingXHR<T = any>(url: string, request: Readonly<RequestInit>): Promise<Result<T>> {
|
||||
export async function requestUsingXHR(url: string, request: Readonly<RequestInit>): Promise<Result> {
|
||||
return new Promise(resolve => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
|
||||
|
||||
@ -10,16 +10,16 @@ import { {{{this}}} } from '../models/{{{this}}}';
|
||||
{{/if}}
|
||||
import * as yup from 'yup';
|
||||
|
||||
{{#eq export 'reference'}}
|
||||
{{#equals export 'reference'}}
|
||||
{{>exportReference}}
|
||||
{{else eq export 'generic'}}
|
||||
{{else equals export 'generic'}}
|
||||
{{>exportGeneric}}
|
||||
{{else eq export 'enum'}}
|
||||
{{else equals export 'enum'}}
|
||||
{{>exportEnum}}
|
||||
{{else eq export 'array'}}
|
||||
{{else equals export 'array'}}
|
||||
{{>exportArray}}
|
||||
{{else eq export 'dictionary'}}
|
||||
{{else equals export 'dictionary'}}
|
||||
{{>exportDictionary}}
|
||||
{{else eq export 'interface'}}
|
||||
{{else equals export 'interface'}}
|
||||
{{>exportInterface}}
|
||||
{{/eq}}
|
||||
{{/equals}}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
{{#eq export 'reference'}}
|
||||
{{#equals export 'reference'}}
|
||||
{{>typeReference}}
|
||||
{{else eq export 'generic'}}
|
||||
{{else equals export 'generic'}}
|
||||
{{>typeGeneric}}
|
||||
{{else eq export 'enum'}}
|
||||
{{else equals export 'enum'}}
|
||||
{{>typeEnum}}
|
||||
{{else eq export 'array'}}
|
||||
{{else equals export 'array'}}
|
||||
{{>typeArray}}
|
||||
{{else eq export 'dictionary'}}
|
||||
{{else equals export 'dictionary'}}
|
||||
{{>typeDictionary}}
|
||||
{{else eq export 'interface'}}
|
||||
{{else equals export 'interface'}}
|
||||
{{>typeInterface}}
|
||||
{{/eq}}
|
||||
{{/equals}}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
{{#eq export 'reference'}}
|
||||
{{#equals export 'reference'}}
|
||||
{{>validationReference}}
|
||||
{{else eq export 'generic'}}
|
||||
{{else equals export 'generic'}}
|
||||
{{>validationGeneric}}
|
||||
{{else eq export 'enum'}}
|
||||
{{else equals export 'enum'}}
|
||||
{{>validationEnum}}
|
||||
{{else eq export 'array'}}
|
||||
{{else equals export 'array'}}
|
||||
{{>validationArray}}
|
||||
{{else eq export 'dictionary'}}
|
||||
{{else equals export 'dictionary'}}
|
||||
{{>validationDictionary}}
|
||||
{{else eq export 'interface'}}
|
||||
{{else equals export 'interface'}}
|
||||
{{>validationInterface}}
|
||||
{{/eq}}
|
||||
{{/equals}}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
yup.mixed<{{{name}}}>().oneOf([
|
||||
{{#each enum}}
|
||||
{{#eq ../name name}}
|
||||
{{#equals ../name name}}
|
||||
{{{value}}}{{#unless @last}},{{/unless}}
|
||||
{{else}}
|
||||
{{{../name}}}.{{{name}}}{{#unless @last}},{{/unless}}
|
||||
{{/eq}}
|
||||
{{/equals}}
|
||||
{{/each}}
|
||||
])
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
{{~#eq type 'boolean'~}}
|
||||
{{~#equals type 'boolean'~}}
|
||||
yup.boolean()
|
||||
{{~else eq type 'number'~}}
|
||||
{{~else equals type 'number'~}}
|
||||
yup.number()
|
||||
{{~else eq type 'string'~}}
|
||||
{{~else equals type 'string'~}}
|
||||
yup.string()
|
||||
{{~else~}}
|
||||
yup.mixed<{{{type}}}>()
|
||||
{{~/eq~}}
|
||||
{{~/equals~}}
|
||||
|
||||
@ -43,31 +43,23 @@ export class {{{name}}} {
|
||||
|
||||
const result = await request({
|
||||
method: '{{{method}}}',
|
||||
path: `{{{path}}}`
|
||||
{{~#if parametersHeader~}},
|
||||
path: `{{{path}}}`{{#if parametersHeader}},
|
||||
headers: {
|
||||
{{#each parametersHeader}}
|
||||
'{{{prop}}}': {{{name}}}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
}
|
||||
{{~/if~}}
|
||||
{{~#if parametersQuery~}},
|
||||
}{{/if}}{{#if parametersQuery}},
|
||||
query: {
|
||||
{{#each parametersQuery}}
|
||||
'{{{prop}}}': {{{name}}}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
}
|
||||
{{~/if~}}
|
||||
{{~#if parametersForm~}},
|
||||
}{{/if}}{{#if parametersForm}},
|
||||
formData: {
|
||||
{{#each parametersForm}}
|
||||
'{{{prop}}}': {{{name}}}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
}
|
||||
{{~/if~}}
|
||||
{{~#if parametersBody~}},
|
||||
body: {{{parametersBody.name}}}
|
||||
{{/if}}
|
||||
}{{/if}}{{#if parametersBody}},
|
||||
body: {{{parametersBody.name}}}{{/if}}
|
||||
});
|
||||
{{#if errors}}
|
||||
|
||||
|
||||
@ -18,8 +18,8 @@ export function readHandlebarsTemplate(filePath: string): Handlebars.TemplateDel
|
||||
preventIndent: true,
|
||||
knownHelpersOnly: true,
|
||||
knownHelpers: {
|
||||
indent: true,
|
||||
eq: true,
|
||||
equals: true,
|
||||
notEquals: true,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
import * as Handlebars from 'handlebars';
|
||||
|
||||
export function registerHandlebarHelpers(): void {
|
||||
Handlebars.registerHelper('eq', function(a: string, b: string, options: Handlebars.HelperOptions): string {
|
||||
Handlebars.registerHelper('equals', function(a: string, b: string, options: Handlebars.HelperOptions): string {
|
||||
// @ts-ignore
|
||||
return a === b ? options.fn(this) : options.inverse(this);
|
||||
});
|
||||
Handlebars.registerHelper('notEquals', function(a: string, b: string, options: Handlebars.HelperOptions): string {
|
||||
// @ts-ignore
|
||||
return a !== b ? options.fn(this) : options.inverse(this);
|
||||
});
|
||||
}
|
||||
|
||||
@ -29,7 +29,6 @@ export function writeClientIndex(client: Client, language: Language, templates:
|
||||
})
|
||||
);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
throw new Error(`Could not write index: "${fileName}"`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,13 +17,12 @@ import { format } from './format';
|
||||
export function writeClientModels(models: Map<string, Model>, language: Language, templates: Templates, outputPath: string): void {
|
||||
models.forEach(model => {
|
||||
const fileName = getFileName(model.name, language);
|
||||
try {
|
||||
const templateData = exportModel(model);
|
||||
const templateResult = templates.model(templateData);
|
||||
fs.writeFileSync(path.resolve(outputPath, fileName), format(templateResult));
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
throw new Error(`Could not write model: "${fileName}"`);
|
||||
}
|
||||
// try {
|
||||
const templateData = exportModel(model);
|
||||
const templateResult = templates.model(templateData);
|
||||
fs.writeFileSync(path.resolve(outputPath, fileName), format(templateResult));
|
||||
// } catch (e) {
|
||||
// throw new Error(`Could not write model: "${fileName}"`);
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
@ -22,7 +22,6 @@ export function writeClientServices(services: Map<string, Service>, language: La
|
||||
const templateResult = templates.service(templateData);
|
||||
fs.writeFileSync(path.resolve(outputPath, fileName), format(templateResult));
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
throw new Error(`Could not write service: "${fileName}"`);
|
||||
}
|
||||
});
|
||||
|
||||
@ -18,7 +18,6 @@ export function writeClientSettings(client: Client, language: Language, httpClie
|
||||
})
|
||||
);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
throw new Error(`Could not write settings: "${fileName}"`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,75 +5,18 @@
|
||||
const OpenAPI = require('../dist');
|
||||
|
||||
OpenAPI.generate(
|
||||
'./test/mock/v2/spec.json',
|
||||
'./test/tmp/v2/ts/spec',
|
||||
'./test/mock/spec-v2.json',
|
||||
'./test/tmp/v2/ts/',
|
||||
OpenAPI.Language.TYPESCRIPT,
|
||||
OpenAPI.HttpClient.FETCH,
|
||||
);
|
||||
|
||||
// OpenAPI.generate(
|
||||
// './test/mock/v2/test-addon.json',
|
||||
// './test/tmp/v2/ts/test-addon',
|
||||
// OpenAPI.Language.TYPESCRIPT,
|
||||
// OpenAPI.HttpClient.FETCH,
|
||||
// );
|
||||
//
|
||||
// OpenAPI.generate(
|
||||
// './test/mock/v2/test-docs.json',
|
||||
// './test/tmp/v2/ts/test-docs',
|
||||
// OpenAPI.Language.TYPESCRIPT,
|
||||
// OpenAPI.HttpClient.FETCH,
|
||||
// );
|
||||
//
|
||||
// OpenAPI.generate(
|
||||
// './test/mock/v2/test-sites.json',
|
||||
// './test/tmp/v2/ts/test-sites',
|
||||
// OpenAPI.Language.TYPESCRIPT,
|
||||
// OpenAPI.HttpClient.FETCH,
|
||||
// );
|
||||
//
|
||||
// OpenAPI.generate(
|
||||
// './test/mock/v2/test-petstore.yaml',
|
||||
// './test/tmp/v2/ts/test-petstore-yaml',
|
||||
// OpenAPI.Language.TYPESCRIPT,
|
||||
// OpenAPI.HttpClient.FETCH,
|
||||
// );
|
||||
//
|
||||
// OpenAPI.compile('./test/tmp/v2/ts/spec');
|
||||
//
|
||||
// OpenAPI.compile('./test/tmp/v2/ts/test-addon');
|
||||
//
|
||||
// OpenAPI.compile('./test/tmp/v2/ts/test-docs');
|
||||
//
|
||||
// OpenAPI.compile('./test/tmp/v2/ts/test-sites');
|
||||
//
|
||||
// OpenAPI.compile('./test/tmp/v2/ts/test-petstore-yaml');
|
||||
OpenAPI.generate(
|
||||
'./test/mock/spec-v2.json',
|
||||
'./test/tmp/v2/js/',
|
||||
OpenAPI.Language.JAVASCRIPT,
|
||||
OpenAPI.HttpClient.XHR,
|
||||
);
|
||||
|
||||
OpenAPI.compile('./test/tmp/v2/ts/');
|
||||
|
||||
// OpenAPI.generate(
|
||||
// './test/mock/v3/test-petstore.json',
|
||||
// './test/tmp/v3/test-petstore-json',
|
||||
// OpenAPI.Language.TYPESCRIPT,
|
||||
// OpenAPI.HttpClient.FETCH
|
||||
// );
|
||||
//
|
||||
// OpenAPI.generate(
|
||||
// './test/mock/v3/test-petstore.yaml',
|
||||
// './test/tmp/v3/test-petstore-yaml',
|
||||
// OpenAPI.Language.TYPESCRIPT,
|
||||
// OpenAPI.HttpClient.FETCH,
|
||||
// );
|
||||
//
|
||||
// OpenAPI.generate(
|
||||
// './test/mock/v3/test-uspto.json',
|
||||
// './test/tmp/v3/test-uspto',
|
||||
// OpenAPI.Language.TYPESCRIPT,
|
||||
// OpenAPI.HttpClient.FETCH,
|
||||
// );
|
||||
//
|
||||
// OpenAPI.generate(
|
||||
// './test/mock/v3/test-with-examples.json',
|
||||
// './test/tmp/v3/test-with-examples',
|
||||
// OpenAPI.Language.TYPESCRIPT,
|
||||
// OpenAPI.HttpClient.FETCH,
|
||||
// );
|
||||
//
|
||||
|
||||
@ -65,35 +65,35 @@
|
||||
"description": "This is the parameter that goes into the request header",
|
||||
"name": "parameterHeader",
|
||||
"in": "header",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "This is the parameter that goes into the request query params",
|
||||
"name": "parameterQuery",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "This is the parameter that goes into the request form data",
|
||||
"name": "parameterForm",
|
||||
"in": "formData",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "This is the parameter that is send as request body",
|
||||
"name": "parameterBody",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "api-version",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"required": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -202,11 +202,162 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v{api-version}/types": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Types"
|
||||
],
|
||||
"operationId": "Types",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "This is a number parameter",
|
||||
"name": "parameterNumber",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"default": 123,
|
||||
"type": "int"
|
||||
},
|
||||
{
|
||||
"description": "This is a string parameter",
|
||||
"name": "parameterString",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"default": "default",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"description": "This is a boolean parameter",
|
||||
"name": "parameterBoolean",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"default": true,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"description": "This is an object parameter",
|
||||
"name": "parameterObject",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"default": null,
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"description": "This is an array parameter",
|
||||
"name": "parameterArray",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "This is a dictionary parameter",
|
||||
"name": "parameterDictionary",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"type": "object",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "This is a number parameter",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Response is a simple number",
|
||||
"schema": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"201": {
|
||||
"description": "Response is a simple string",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"202": {
|
||||
"description": "Response is a simple boolean",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"203": {
|
||||
"description": "Response is a simple object",
|
||||
"default": null,
|
||||
"schema": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v{api-version}/complex": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Complex"
|
||||
]
|
||||
],
|
||||
"operationId": "ComplexTypes",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Parameter containing object",
|
||||
"name": "parameterObject",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"first": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"second": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"third": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Parameter containing reference",
|
||||
"name": "parameterReference",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful response",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "400 server error"
|
||||
},
|
||||
"500": {
|
||||
"description": "500 server error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -1,361 +0,0 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"version": "v9.0",
|
||||
"title": "swagger"
|
||||
},
|
||||
"host": "localhost:8080",
|
||||
"basePath": "/api",
|
||||
"schemes": [
|
||||
"http"
|
||||
],
|
||||
"paths": {
|
||||
},
|
||||
"definitions": {
|
||||
"SimpleInteger": {
|
||||
"description": "This is a simple number",
|
||||
"type": "integer"
|
||||
},
|
||||
"SimpleBoolean": {
|
||||
"description": "This is a simple boolean",
|
||||
"type": "boolean"
|
||||
},
|
||||
"SimpleString": {
|
||||
"description": "This is a simple string",
|
||||
"type": "string"
|
||||
},
|
||||
"SimpleFile": {
|
||||
"description": "This is a simple file",
|
||||
"type": "File"
|
||||
},
|
||||
"SimpleReference": {
|
||||
"description": "This is a simple reference",
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
},
|
||||
"EnumWithStrings": {
|
||||
"description": "This is a simple enum with strings",
|
||||
"enum": [
|
||||
"Success",
|
||||
"Warning",
|
||||
"Error"
|
||||
]
|
||||
},
|
||||
"EnumWithNumbers": {
|
||||
"description": "This is a simple enum with numbers",
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]
|
||||
},
|
||||
"EnumFromDescription": {
|
||||
"description": "Success=1,Warning=2,Error=3",
|
||||
"type": "int"
|
||||
},
|
||||
"ArrayWithNumbers": {
|
||||
"description": "This is a simple array with numbers",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"ArrayWithBooleans": {
|
||||
"description": "This is a simple array with booleans",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"ArrayWithStrings": {
|
||||
"description": "This is a simple array with strings",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"ArrayWithReferences": {
|
||||
"description": "This is a simple array with references",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
}
|
||||
},
|
||||
"ArrayWithArray": {
|
||||
"description": "This is a simple array containing an array",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ArrayWithProperties": {
|
||||
"description": "This is a simple array with properties",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"foo": {
|
||||
"type": "string"
|
||||
},
|
||||
"bar": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"DictionaryWithString": {
|
||||
"description": "This is a string dictionary",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"DictionaryWithReference": {
|
||||
"description": "This is a string reference",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
}
|
||||
},
|
||||
"DictionaryWithArray": {
|
||||
"description": "This is a complex dictionary",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
}
|
||||
}
|
||||
},
|
||||
"DictionaryWithDictionary": {
|
||||
"description": "This is a string dictionary",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"DictionaryWithProperties": {
|
||||
"description": "This is a complex dictionary",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"foo": {
|
||||
"type": "string"
|
||||
},
|
||||
"bar": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithInteger": {
|
||||
"description": "This is a model with one number property",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prop": {
|
||||
"description": "This is a simple number property",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithBoolean": {
|
||||
"description": "This is a model with one boolean property",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prop": {
|
||||
"description": "This is a simple boolean property",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithString": {
|
||||
"description": "This is a model with one string property",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prop": {
|
||||
"description": "This is a simple string property",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithEnum": {
|
||||
"description": "This is a model with one enum",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prop": {
|
||||
"description": "This is a simple enum with strings",
|
||||
"enum": [
|
||||
"Success",
|
||||
"Warning",
|
||||
"Error"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithEnumFromDescription": {
|
||||
"description": "This is a model with one enum",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prop": {
|
||||
"type": "integer",
|
||||
"description": "Success=1,Warning=2,Error=3"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithReference": {
|
||||
"description": "This is a model with one property containing a reference",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prop": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithArray": {
|
||||
"description": "This is a model with one property containing an array",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prop": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithDictionary": {
|
||||
"description": "This is a model with one property containing a dictionary",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prop": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelLink": {
|
||||
"description": "This is a model that can have a template??",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithLink": {
|
||||
"description": "This is a model that can have a template??",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prop": {
|
||||
"$ref": "#/definitions/ModelLink[ModelWithString]"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithCircularReference": {
|
||||
"description": "This is a model with one property containing a circular reference",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prop": {
|
||||
"$ref": "#/definitions/ModelWithCircularReference"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithNestedProperties": {
|
||||
"description": "This is a model with one nested property",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"first": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"second": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"third": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithDuplicateProperties": {
|
||||
"description": "This is a model with duplicated properties",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"prop": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
},
|
||||
"prop": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
},
|
||||
"prop": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelWithDuplicateImports": {
|
||||
"description": "This is a model with duplicated imports",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"propA": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
},
|
||||
"propB": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
},
|
||||
"propC": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ModelThatExtends": {
|
||||
"description": "This is a model that extends another model",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"propExtendsA": {
|
||||
"type": "string"
|
||||
},
|
||||
"propExtendsB": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"ModelThatExtendsExtends": {
|
||||
"description": "This is a model that extends another model",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ModelThatExtends"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"propExtendsC": {
|
||||
"type": "string"
|
||||
},
|
||||
"propExtendsD": {
|
||||
"$ref": "#/definitions/ModelWithString"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,954 +0,0 @@
|
||||
{
|
||||
"x-generator": "NSwag v12.3.1.0 (NJsonSchema v9.14.1.0 (Newtonsoft.Json v12.0.0.0))",
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "Tridion Add-on Service API",
|
||||
"version": "v1"
|
||||
},
|
||||
"host": "10.91.90.47:83",
|
||||
"schemes": [
|
||||
"http"
|
||||
],
|
||||
"paths": {
|
||||
"/addon/api/v1/addons": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Addons"
|
||||
],
|
||||
"summary": "Gets the list of addons.",
|
||||
"operationId": "GetAll",
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Addon"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"tags": [
|
||||
"Addons"
|
||||
],
|
||||
"summary": "Upload add-ons' zip files. Creates (or updates if exists) add-on.",
|
||||
"operationId": "Upload",
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"type": "file",
|
||||
"name": "file",
|
||||
"in": "formData",
|
||||
"required": true,
|
||||
"description": "FileStream of the uploading file."
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"201": {
|
||||
"x-nullable": true,
|
||||
"description": "UploadResult",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/UploadResult"
|
||||
}
|
||||
},
|
||||
"202": {
|
||||
"x-nullable": true,
|
||||
"description": "UploadResult",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/UploadResult"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/addon/api/v1/addons/{id}": {
|
||||
"put": {
|
||||
"tags": [
|
||||
"Addons"
|
||||
],
|
||||
"summary": "Upload addons' zip files. Updates existing add-on.",
|
||||
"operationId": "Update",
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The add-on id.",
|
||||
"format": "int32",
|
||||
"x-nullable": false
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"name": "file",
|
||||
"in": "formData",
|
||||
"required": true,
|
||||
"description": "FileStream of the uploading file."
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "UploadResult.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/UploadResult"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"get": {
|
||||
"tags": [
|
||||
"Addons"
|
||||
],
|
||||
"summary": "Gets the addon metadata by the specified id.",
|
||||
"operationId": "Get",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The addon id.",
|
||||
"format": "int32",
|
||||
"x-nullable": false
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "The addon metadata.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Addon"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Addons"
|
||||
],
|
||||
"summary": "Deletes the addon with a specified id.",
|
||||
"operationId": "Delete",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The addon id.",
|
||||
"format": "int32",
|
||||
"x-nullable": false
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/addon/api/v1/addons/{id}/status": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Addons"
|
||||
],
|
||||
"summary": "Updates the addon status.",
|
||||
"operationId": "UpdateAddonStatus",
|
||||
"consumes": [
|
||||
"application/json-patch+json",
|
||||
"application/json",
|
||||
"text/json",
|
||||
"application/*+json"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The addon id.",
|
||||
"format": "int32",
|
||||
"x-nullable": false
|
||||
},
|
||||
{
|
||||
"name": "statusReport",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"description": "The status report.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/StatusReport"
|
||||
},
|
||||
"x-nullable": false
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Addons"
|
||||
],
|
||||
"summary": "Deletes the addon status.",
|
||||
"operationId": "DeleteAddonStatus",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The addon id.",
|
||||
"format": "int32",
|
||||
"x-nullable": false
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/addon/api/v1/addons/{id}/download": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Addons"
|
||||
],
|
||||
"summary": "Downloads addon by the specified id.",
|
||||
"description": "When HEAD request is used the method only checks if the addon exists and returns the empty file.",
|
||||
"operationId": "Download",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The addon id.",
|
||||
"format": "int32",
|
||||
"x-nullable": false
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "Binary addon.",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"head": {
|
||||
"tags": [
|
||||
"Addons"
|
||||
],
|
||||
"summary": "Downloads addon by the specified id.",
|
||||
"description": "When HEAD request is used the method only checks if the addon exists and returns the empty file.",
|
||||
"operationId": "Fetch",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The addon id.",
|
||||
"format": "int32",
|
||||
"x-nullable": false
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "Binary addon.",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/addon/api/v1/addons/{id}/downloadicon": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Addons"
|
||||
],
|
||||
"summary": "Downloads Addon Icon by the specified id.",
|
||||
"operationId": "DownloadIcon",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The addon id.",
|
||||
"format": "int32",
|
||||
"x-nullable": false
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "Addon icon stream.",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/addon/api/v1/addons/{id}/configurations": {
|
||||
"put": {
|
||||
"tags": [
|
||||
"Configurations"
|
||||
],
|
||||
"summary": "Upload addon configuration files. Extracts required fields from the containing manifest file.",
|
||||
"operationId": "UploadConfiguration",
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The addon id.",
|
||||
"format": "int32",
|
||||
"x-nullable": false
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"name": "file",
|
||||
"in": "formData",
|
||||
"required": true,
|
||||
"description": "FileStream of the uploading file."
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "The updated addon.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/UploadResult"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Configurations"
|
||||
],
|
||||
"summary": "Deletes the addon configuration with a specified id.",
|
||||
"operationId": "ConfigurationDelete",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The addon id.",
|
||||
"format": "int32",
|
||||
"x-nullable": false
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"get": {
|
||||
"tags": [
|
||||
"Configurations"
|
||||
],
|
||||
"summary": "Downloads addon configuration by the specified id.",
|
||||
"description": "When HEAD request is used the method only checks if the addon exists and returns the empty file.",
|
||||
"operationId": "DownloadAddonConfiguration",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The addon id.",
|
||||
"format": "int32",
|
||||
"x-nullable": false
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "Binary addon configuration.",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/addon/api/v1/extensions/{id}/status": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Extensions"
|
||||
],
|
||||
"summary": "Updates the extension status.",
|
||||
"operationId": "UpdateExtensionStatus",
|
||||
"consumes": [
|
||||
"application/json-patch+json",
|
||||
"application/json",
|
||||
"text/json",
|
||||
"application/*+json"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The extension id.",
|
||||
"format": "int32",
|
||||
"x-nullable": false
|
||||
},
|
||||
{
|
||||
"name": "statusReport",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"description": "The status report.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/StatusReport"
|
||||
},
|
||||
"x-nullable": false
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Extensions"
|
||||
],
|
||||
"summary": "Deletes the extension status.",
|
||||
"operationId": "DeleteExtensionStatus",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The extension id.",
|
||||
"format": "int32",
|
||||
"x-nullable": false
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "clientId",
|
||||
"in": "query",
|
||||
"description": "The client id. If it is specified, extension status for that client will be deleted.\n If not specified then extension status will be deleted for all clients.",
|
||||
"x-nullable": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/addon/api/v1/health": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Health"
|
||||
],
|
||||
"summary": "Checks whether the service is up and running",
|
||||
"operationId": "Health",
|
||||
"responses": {
|
||||
"200": {
|
||||
"x-nullable": true,
|
||||
"description": "Ok - in success case, otherwise return the error description.",
|
||||
"schema": {
|
||||
"type": "file"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/addon/api/v1/report/heartbeat": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Report"
|
||||
],
|
||||
"summary": "Receives heartbeat from all clients.",
|
||||
"description": "This heartbeat is used to calculate the aggregated status of the Addons.\nIf the service does not receive heartbeat for a certain while,\nall reported status are ignored during status calculation.\nAfter a longer period those ignored status reports are cleaned out.\nBoth these values are configurable in the service.",
|
||||
"operationId": "Report_Heartbeat",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "environment",
|
||||
"in": "query",
|
||||
"x-nullable": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "clientIdentity",
|
||||
"in": "query",
|
||||
"x-nullable": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "process",
|
||||
"in": "query",
|
||||
"x-nullable": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"Addon": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"Id",
|
||||
"RequireConfiguration",
|
||||
"Enabled",
|
||||
"Status"
|
||||
],
|
||||
"properties": {
|
||||
"Id": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"ManifestVersion": {
|
||||
"type": "string",
|
||||
"description": "Gets the manifest version."
|
||||
},
|
||||
"PackageId": {
|
||||
"type": "string",
|
||||
"description": "Gets the unique identifier of the add-on."
|
||||
},
|
||||
"Name": {
|
||||
"type": "string",
|
||||
"description": "Gets the descriptive name of add-on."
|
||||
},
|
||||
"Description": {
|
||||
"type": "string",
|
||||
"description": "Gets the description of add-on."
|
||||
},
|
||||
"Author": {
|
||||
"type": "string",
|
||||
"description": "Gets the Author of add-on."
|
||||
},
|
||||
"MinVersion": {
|
||||
"type": "string",
|
||||
"description": "Gets the minimum SDL Tridion Sites version this extension supports."
|
||||
},
|
||||
"MaxVersion": {
|
||||
"type": "string",
|
||||
"description": "Gets the maximum SDL Tridion Sites version this extension supports."
|
||||
},
|
||||
"Version": {
|
||||
"type": "string",
|
||||
"description": "Gets the version of this add-on."
|
||||
},
|
||||
"Icon": {
|
||||
"type": "string",
|
||||
"description": "Gets the add-on icon."
|
||||
},
|
||||
"RequireConfiguration": {
|
||||
"description": "Describes whether the custom configuration can be uploaded for the addon.",
|
||||
"$ref": "#/definitions/RequireConfiguration"
|
||||
},
|
||||
"Dependencies": {
|
||||
"type": "array",
|
||||
"description": "Gets the collection of add-on dependencies.",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Dependency"
|
||||
}
|
||||
},
|
||||
"Extensions": {
|
||||
"type": "array",
|
||||
"description": "Gets the list of extensions this add-on contains.",
|
||||
"items": {
|
||||
"$ref": "#/definitions/Extension"
|
||||
}
|
||||
},
|
||||
"Enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Status": {
|
||||
"$ref": "#/definitions/DeploymentStatus"
|
||||
},
|
||||
"PackageHash": {
|
||||
"type": "string"
|
||||
},
|
||||
"UploadedAt": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"DownloadUri": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"StatusReports": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/StatusReport"
|
||||
}
|
||||
},
|
||||
"DownloadIconUri": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"DownloadConfigurationUri": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"Configuration": {
|
||||
"$ref": "#/definitions/Configuration"
|
||||
}
|
||||
}
|
||||
},
|
||||
"RequireConfiguration": {
|
||||
"type": "string",
|
||||
"description": "Represents whether the Addon requires configuration or not",
|
||||
"x-enumNames": [
|
||||
"Optional",
|
||||
"Yes",
|
||||
"No"
|
||||
],
|
||||
"enum": [
|
||||
"Optional",
|
||||
"Yes",
|
||||
"No"
|
||||
],
|
||||
"x-ms-enum": {
|
||||
"name": "RequireConfiguration",
|
||||
"modelAsString": false
|
||||
}
|
||||
},
|
||||
"Dependency": {
|
||||
"type": "object",
|
||||
"description": "Represents add-on dependencies from the add-on manifest file.",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"Id": {
|
||||
"type": "string",
|
||||
"description": "Gets the name of dependency package"
|
||||
},
|
||||
"Version": {
|
||||
"type": "string",
|
||||
"description": "Gets the version of dependency package"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Extension": {
|
||||
"type": "object",
|
||||
"description": "Represents extension information from the add-on manifest file.",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"Id",
|
||||
"Status"
|
||||
],
|
||||
"properties": {
|
||||
"Id": {
|
||||
"type": "integer",
|
||||
"description": "Add-on service generated ID.",
|
||||
"format": "int32"
|
||||
},
|
||||
"Name": {
|
||||
"type": "string",
|
||||
"description": "Gets the extension name"
|
||||
},
|
||||
"SupportedVersions": {
|
||||
"type": "string",
|
||||
"description": "Gets the SDL Tridion Sites component versions this extension support"
|
||||
},
|
||||
"Type": {
|
||||
"type": "string",
|
||||
"description": "Gets the identifier of the extension point that this extension extends."
|
||||
},
|
||||
"properties": {
|
||||
"description": "Gets the custom properties associated with this extension as raw json."
|
||||
},
|
||||
"StatusReports": {
|
||||
"type": "array",
|
||||
"description": "List of status reports.",
|
||||
"items": {
|
||||
"$ref": "#/definitions/StatusReport"
|
||||
}
|
||||
},
|
||||
"DisabledClients": {
|
||||
"type": "array",
|
||||
"description": "List of the clients where the extension is disabled.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"Status": {
|
||||
"description": "Calculated status for this extension.",
|
||||
"$ref": "#/definitions/DeploymentStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"StatusReport": {
|
||||
"type": "object",
|
||||
"description": "Represents the extension status object to be received from the update addon status REST method.",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"Status"
|
||||
],
|
||||
"properties": {
|
||||
"Environment": {
|
||||
"type": "string",
|
||||
"description": "The free-form unique identifier of the environment of the client reporting the addon and extension status."
|
||||
},
|
||||
"ClientIdentity": {
|
||||
"type": "string",
|
||||
"description": "The free form unique identifier of the client who reporting the addon and extension status.\n\nIs used in order to calculate the addon and extension status based on all the client's reports.\nE.g. at least one reported fail - addon extension gets failed status."
|
||||
},
|
||||
"Process": {
|
||||
"type": "string",
|
||||
"description": "The free-form unique identifier of the process of the client reporting the addon and extension status."
|
||||
},
|
||||
"Status": {
|
||||
"description": "The addon status.",
|
||||
"$ref": "#/definitions/DeploymentStatus"
|
||||
},
|
||||
"Message": {
|
||||
"type": "string",
|
||||
"description": "The exception details for the case of failed status."
|
||||
}
|
||||
}
|
||||
},
|
||||
"DeploymentStatus": {
|
||||
"type": "string",
|
||||
"description": "Represents the status the Addon or Extension is currently in",
|
||||
"x-enumNames": [
|
||||
"Fail",
|
||||
"Pending",
|
||||
"Success",
|
||||
"WaitingConfiguration",
|
||||
"Disabled"
|
||||
],
|
||||
"enum": [
|
||||
"Fail",
|
||||
"Pending",
|
||||
"Success",
|
||||
"WaitingConfiguration",
|
||||
"Disabled"
|
||||
],
|
||||
"x-ms-enum": {
|
||||
"name": "DeploymentStatus",
|
||||
"modelAsString": false
|
||||
}
|
||||
},
|
||||
"Configuration": {
|
||||
"type": "object",
|
||||
"description": "Represents add-on configuration information",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"FileName": {
|
||||
"type": "string",
|
||||
"description": "Gets the configuration file name."
|
||||
},
|
||||
"ContentHash": {
|
||||
"type": "string",
|
||||
"description": "Gets the hash of configuration file content."
|
||||
},
|
||||
"UploadedAt": {
|
||||
"type": "string",
|
||||
"description": "Gets configuration upload date.",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
},
|
||||
"UploadResult": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"Id",
|
||||
"IsModified"
|
||||
],
|
||||
"properties": {
|
||||
"Id": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"IsModified": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"IHeaderDictionary": {
|
||||
"type": "object",
|
||||
"x-abstract": true,
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"Item"
|
||||
],
|
||||
"properties": {
|
||||
"Item": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"ContentLength": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Manifest": {
|
||||
"type": "object",
|
||||
"description": "Represents add-on information from the add-on manifest file.",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"RequireConfiguration"
|
||||
],
|
||||
"properties": {
|
||||
"ManifestVersion": {
|
||||
"type": "string",
|
||||
"description": "Gets the manifest version."
|
||||
},
|
||||
"Id": {
|
||||
"type": "string",
|
||||
"description": "Gets the unique identifier of the add-on."
|
||||
},
|
||||
"Name": {
|
||||
"type": "string",
|
||||
"description": "Gets the descriptive name of add-on."
|
||||
},
|
||||
"Description": {
|
||||
"type": "string",
|
||||
"description": "Gets the description of add-on."
|
||||
},
|
||||
"Author": {
|
||||
"type": "string",
|
||||
"description": "Gets the Author of add-on."
|
||||
},
|
||||
"MinVersion": {
|
||||
"type": "string",
|
||||
"description": "Gets the minimum SDL Tridion Sites version this extension supports."
|
||||
},
|
||||
"MaxVersion": {
|
||||
"type": "string",
|
||||
"description": "Gets the maximum SDL Tridion Sites version this extension supports."
|
||||
},
|
||||
"Version": {
|
||||
"type": "string",
|
||||
"description": "Gets the version of this add-on."
|
||||
},
|
||||
"Icon": {
|
||||
"type": "string",
|
||||
"description": "Gets the add-on icon."
|
||||
},
|
||||
"RequireConfiguration": {
|
||||
"description": "Describes whether the custom configuration can be uploaded for the addon.",
|
||||
"$ref": "#/definitions/RequireConfiguration"
|
||||
},
|
||||
"Dependencies": {
|
||||
"type": "array",
|
||||
"description": "Gets the collection of add-on dependencies.",
|
||||
"items": {
|
||||
"$ref": "#/definitions/DependencyManifest"
|
||||
}
|
||||
},
|
||||
"Extensions": {
|
||||
"type": "array",
|
||||
"description": "Gets the list of extensions this add-on contains.",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ExtensionManifest"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"DependencyManifest": {
|
||||
"type": "object",
|
||||
"description": "Represents add-on dependencies from the add-on manifest file.",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"Id": {
|
||||
"type": "string",
|
||||
"description": "Gets the name of dependency package"
|
||||
},
|
||||
"Version": {
|
||||
"type": "string",
|
||||
"description": "Gets the version of dependency package"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ExtensionManifest": {
|
||||
"type": "object",
|
||||
"description": "Represents extension information from the add-on manifest file.",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"Id"
|
||||
],
|
||||
"properties": {
|
||||
"Id": {
|
||||
"type": "integer",
|
||||
"description": "Add-on service generated ID.",
|
||||
"format": "int32"
|
||||
},
|
||||
"Name": {
|
||||
"type": "string",
|
||||
"description": "Gets the extension name"
|
||||
},
|
||||
"SupportedVersions": {
|
||||
"type": "string",
|
||||
"description": "Gets the SDL Tridion Sites component versions this extension support"
|
||||
},
|
||||
"Type": {
|
||||
"type": "string",
|
||||
"description": "Gets the identifier of the extension point that this extension extends."
|
||||
},
|
||||
"properties": {
|
||||
"description": "Gets the additional properties required to configure the extension."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,103 +0,0 @@
|
||||
swagger: "2.0"
|
||||
info:
|
||||
version: 1.0.0
|
||||
title: Swagger Petstore
|
||||
license:
|
||||
name: MIT
|
||||
host: petstore.swagger.io
|
||||
basePath: /v1
|
||||
schemes:
|
||||
- http
|
||||
consumes:
|
||||
- application/json
|
||||
produces:
|
||||
- application/json
|
||||
paths:
|
||||
/pets:
|
||||
get:
|
||||
summary: List all pets
|
||||
operationId: listPets
|
||||
tags:
|
||||
- pets
|
||||
parameters:
|
||||
- name: limit
|
||||
in: query
|
||||
description: How many items to return at one time (max 100)
|
||||
required: false
|
||||
type: integer
|
||||
format: int32
|
||||
responses:
|
||||
"200":
|
||||
description: A paged array of pets
|
||||
headers:
|
||||
x-next:
|
||||
type: string
|
||||
description: A link to the next page of responses
|
||||
schema:
|
||||
$ref: '#/definitions/Pets'
|
||||
default:
|
||||
description: unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
post:
|
||||
summary: Create a pet
|
||||
operationId: createPets
|
||||
tags:
|
||||
- pets
|
||||
responses:
|
||||
"201":
|
||||
description: Null response
|
||||
default:
|
||||
description: unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
/pets/{petId}:
|
||||
get:
|
||||
summary: Info for a specific pet
|
||||
operationId: showPetById
|
||||
tags:
|
||||
- pets
|
||||
parameters:
|
||||
- name: petId
|
||||
in: path
|
||||
required: true
|
||||
description: The id of the pet to retrieve
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: Expected response to a valid request
|
||||
schema:
|
||||
$ref: '#/definitions/Pets'
|
||||
default:
|
||||
description: unexpected error
|
||||
schema:
|
||||
$ref: '#/definitions/Error'
|
||||
definitions:
|
||||
Pet:
|
||||
type: "object"
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
tag:
|
||||
type: string
|
||||
Pets:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/Pet'
|
||||
Error:
|
||||
type: "object"
|
||||
required:
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,242 +0,0 @@
|
||||
{
|
||||
"openapi": "3.0.0",
|
||||
"info": {
|
||||
"version": "1.0.0",
|
||||
"title": "Swagger Petstore",
|
||||
"description": "A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
"name": "Swagger API Team",
|
||||
"email": "apiteam@swagger.io",
|
||||
"url": "http://swagger.io"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache 2.0",
|
||||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "http://petstore.swagger.io/api"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/pets": {
|
||||
"get": {
|
||||
"description": "Returns all pets from the system that the user has access to\nNam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.\n\nSed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.\n",
|
||||
"operationId": "findPets",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "tags",
|
||||
"in": "query",
|
||||
"description": "tags to filter by",
|
||||
"required": false,
|
||||
"style": "form",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "limit",
|
||||
"in": "query",
|
||||
"description": "maximum number of results to return",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "pet response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "unexpected error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"description": "Creates a new pet in the store. Duplicates are allowed",
|
||||
"operationId": "addPet",
|
||||
"requestBody": {
|
||||
"description": "Pet to add to the store",
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/NewPet"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "pet response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "unexpected error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/pets/{id}": {
|
||||
"get": {
|
||||
"description": "Returns a user based on a single ID, if the user does not have access to the pet",
|
||||
"operationId": "find pet by id",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"description": "ID of pet to fetch",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "pet response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Pet"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "unexpected error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"description": "deletes a single pet based on the ID supplied",
|
||||
"operationId": "deletePet",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"description": "ID of pet to delete",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "pet deleted"
|
||||
},
|
||||
"default": {
|
||||
"description": "unexpected error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"Pet": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/NewPet"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"NewPet": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"tag": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Error": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"code",
|
||||
"message"
|
||||
],
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,252 +0,0 @@
|
||||
{
|
||||
"openapi": "3.0.1",
|
||||
"servers": [
|
||||
{
|
||||
"url": "{scheme}://developer.uspto.gov/ds-api",
|
||||
"variables": {
|
||||
"scheme": {
|
||||
"description": "The Data Set API is accessible via https and http",
|
||||
"enum": [
|
||||
"https",
|
||||
"http"
|
||||
],
|
||||
"default": "https"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"description": "The Data Set API (DSAPI) allows the public users to discover and search USPTO exported data sets. This is a generic API that allows USPTO users to make any CSV based data files searchable through API. With the help of GET call, it returns the list of data fields that are searchable. With the help of POST call, data can be fetched based on the filters on the field names. Please note that POST call is used to search the actual data. The reason for the POST call is that it allows users to specify any complex search criteria without worry about the GET size limitations as well as encoding of the input parameters.",
|
||||
"version": "1.0.0",
|
||||
"title": "USPTO Data Set API",
|
||||
"contact": {
|
||||
"name": "Open Data Portal",
|
||||
"url": "https://developer.uspto.gov",
|
||||
"email": "developer@uspto.gov"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
{
|
||||
"name": "metadata",
|
||||
"description": "Find out about the data sets"
|
||||
},
|
||||
{
|
||||
"name": "search",
|
||||
"description": "Search a data set"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"metadata"
|
||||
],
|
||||
"operationId": "list-data-sets",
|
||||
"summary": "List available data sets",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Returns a list of data sets",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/dataSetList"
|
||||
},
|
||||
"example": {
|
||||
"total": 2,
|
||||
"apis": [
|
||||
{
|
||||
"apiKey": "oa_citations",
|
||||
"apiVersionNumber": "v1",
|
||||
"apiUrl": "https://developer.uspto.gov/ds-api/oa_citations/v1/fields",
|
||||
"apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/oa_citations.json"
|
||||
},
|
||||
{
|
||||
"apiKey": "cancer_moonshot",
|
||||
"apiVersionNumber": "v1",
|
||||
"apiUrl": "https://developer.uspto.gov/ds-api/cancer_moonshot/v1/fields",
|
||||
"apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/cancer_moonshot.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/{dataset}/{version}/fields": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"metadata"
|
||||
],
|
||||
"summary": "Provides the general information about the API and the list of fields that can be used to query the dataset.",
|
||||
"description": "This GET API returns the list of all the searchable field names that are in the oa_citations. Please see the 'fields' attribute which returns an array of field names. Each field or a combination of fields can be searched using the syntax options shown below.",
|
||||
"operationId": "list-searchable-fields",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "dataset",
|
||||
"in": "path",
|
||||
"description": "Name of the dataset.",
|
||||
"required": true,
|
||||
"example": "oa_citations",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "version",
|
||||
"in": "path",
|
||||
"description": "Version of the dataset.",
|
||||
"required": true,
|
||||
"example": "v1",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "The dataset API for the given version is found and it is accessible to consume.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "The combination of dataset name and version is not found in the system or it is not published yet to be consumed by public.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/{dataset}/{version}/records": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"search"
|
||||
],
|
||||
"summary": "Provides search capability for the data set with the given search criteria.",
|
||||
"description": "This API is based on Solr/Lucense Search. The data is indexed using SOLR. This GET API returns the list of all the searchable field names that are in the Solr Index. Please see the 'fields' attribute which returns an array of field names. Each field or a combination of fields can be searched using the Solr/Lucene Syntax. Please refer https://lucene.apache.org/core/3_6_2/queryparsersyntax.html#Overview for the query syntax. List of field names that are searchable can be determined using above GET api.",
|
||||
"operationId": "perform-search",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "version",
|
||||
"in": "path",
|
||||
"description": "Version of the dataset.",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"default": "v1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dataset",
|
||||
"in": "path",
|
||||
"description": "Name of the dataset. In this case, the default value is oa_citations",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"default": "oa_citations"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "No matching record found for the given criteria."
|
||||
}
|
||||
},
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/x-www-form-urlencoded": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"criteria": {
|
||||
"description": "Uses Lucene Query Syntax in the format of propertyName:value, propertyName:[num1 TO num2] and date range format: propertyName:[yyyyMMdd TO yyyyMMdd]. In the response please see the 'docs' element which has the list of record objects. Each record structure would consist of all the fields and their corresponding values.",
|
||||
"type": "string",
|
||||
"default": "*:*"
|
||||
},
|
||||
"start": {
|
||||
"description": "Starting record number. Default value is 0.",
|
||||
"type": "integer",
|
||||
"default": 0
|
||||
},
|
||||
"rows": {
|
||||
"description": "Specify number of rows to be returned. If you run the search with default values, in the response you will see 'numFound' attribute which will tell the number of records available in the dataset.",
|
||||
"type": "integer",
|
||||
"default": 100
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"criteria"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"dataSetList": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"total": {
|
||||
"type": "integer"
|
||||
},
|
||||
"apis": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"apiKey": {
|
||||
"type": "string",
|
||||
"description": "To be used as a dataset parameter value"
|
||||
},
|
||||
"apiVersionNumber": {
|
||||
"type": "string",
|
||||
"description": "To be used as a version parameter value"
|
||||
},
|
||||
"apiUrl": {
|
||||
"type": "string",
|
||||
"format": "uriref",
|
||||
"description": "The URL describing the dataset's fields"
|
||||
},
|
||||
"apiDocumentationUrl": {
|
||||
"type": "string",
|
||||
"format": "uriref",
|
||||
"description": "A URL to the API console for each API"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,167 +0,0 @@
|
||||
{
|
||||
"openapi": "3.0.0",
|
||||
"info": {
|
||||
"title": "Simple API overview",
|
||||
"version": "2.0.0"
|
||||
},
|
||||
"paths": {
|
||||
"/": {
|
||||
"get": {
|
||||
"operationId": "listVersions",
|
||||
"summary": "List API versions",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "200 response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"examples": {
|
||||
"foo": {
|
||||
"value": {
|
||||
"versions": [
|
||||
{
|
||||
"status": "CURRENT",
|
||||
"updated": "2011-01-21T11:33:21Z",
|
||||
"id": "v2.0",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://127.0.0.1:8774/v2/",
|
||||
"rel": "self"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"status": "EXPERIMENTAL",
|
||||
"updated": "2013-07-23T11:33:21Z",
|
||||
"id": "v3.0",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://127.0.0.1:8774/v3/",
|
||||
"rel": "self"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"300": {
|
||||
"description": "300 response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"examples": {
|
||||
"foo": {
|
||||
"value": "{\n \"versions\": [\n {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v2/\",\n \"rel\": \"self\"\n }\n ]\n },\n {\n \"status\": \"EXPERIMENTAL\",\n \"updated\": \"2013-07-23T11:33:21Z\",\n \"id\": \"v3.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v3/\",\n \"rel\": \"self\"\n }\n ]\n }\n ]\n}\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/v2": {
|
||||
"get": {
|
||||
"operationId": "getVersionDetails",
|
||||
"summary": "Show API version details",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "200 response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"examples": {
|
||||
"foo": {
|
||||
"value": {
|
||||
"version": {
|
||||
"status": "CURRENT",
|
||||
"updated": "2011-01-21T11:33:21Z",
|
||||
"media-types": [
|
||||
{
|
||||
"base": "application/xml",
|
||||
"type": "application/vnd.openstack.compute+xml;version=2"
|
||||
},
|
||||
{
|
||||
"base": "application/json",
|
||||
"type": "application/vnd.openstack.compute+json;version=2"
|
||||
}
|
||||
],
|
||||
"id": "v2.0",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://127.0.0.1:8774/v2/",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf",
|
||||
"type": "application/pdf",
|
||||
"rel": "describedby"
|
||||
},
|
||||
{
|
||||
"href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
|
||||
"type": "application/vnd.sun.wadl+xml",
|
||||
"rel": "describedby"
|
||||
},
|
||||
{
|
||||
"href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
|
||||
"type": "application/vnd.sun.wadl+xml",
|
||||
"rel": "describedby"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"203": {
|
||||
"description": "203 response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"examples": {
|
||||
"foo": {
|
||||
"value": {
|
||||
"version": {
|
||||
"status": "CURRENT",
|
||||
"updated": "2011-01-21T11:33:21Z",
|
||||
"media-types": [
|
||||
{
|
||||
"base": "application/xml",
|
||||
"type": "application/vnd.openstack.compute+xml;version=2"
|
||||
},
|
||||
{
|
||||
"base": "application/json",
|
||||
"type": "application/vnd.openstack.compute+json;version=2"
|
||||
}
|
||||
],
|
||||
"id": "v2.0",
|
||||
"links": [
|
||||
{
|
||||
"href": "http://23.253.228.211:8774/v2/",
|
||||
"rel": "self"
|
||||
},
|
||||
{
|
||||
"href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf",
|
||||
"type": "application/pdf",
|
||||
"rel": "describedby"
|
||||
},
|
||||
{
|
||||
"href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
|
||||
"type": "application/vnd.sun.wadl+xml",
|
||||
"rel": "describedby"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user