Transfer to Swagger3. Update workflow (#8)

This commit is contained in:
Baikov Dmitrii 2022-03-03 04:25:21 -08:00 committed by GitHub
parent fd284aa0b0
commit ec920cea3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 6487 additions and 15489 deletions

10
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,10 @@
name: Maven Build Artifact
on:
pull_request:
branches:
- '*'
jobs:
build:
uses: valitydev/base-workflow/.github/workflows/maven-swag-build.yml@v1

17
.github/workflows/deploy.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: Maven Deploy Artifact
on:
push:
branches:
- 'master'
- 'main'
jobs:
deploy:
uses: valitydev/base-workflow/.github/workflows/maven-swag-deploy.yml@v1
secrets:
server-username: ${{ secrets.OSSRH_USERNAME }}
server-password: ${{ secrets.OSSRH_TOKEN }}
deploy-secret-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
deploy-secret-key-password: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,12 +1,13 @@
name: build
name: gh-pages
on:
- pull_request
push:
branches: [master]
env:
NODEJS_VERSION: '16'
jobs:
bundle:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
@ -19,5 +20,8 @@ jobs:
- run: npm install
- name: Bundle specification
run: npm run build
- name: Validate specification
run: npm run test
- name: Publish ReDoc on Github Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist

14
.redocly.yaml Normal file
View File

@ -0,0 +1,14 @@
# See https://docs.redoc.ly/cli/configuration/ for more information.
apiDefinitions:
core: 'openapi/openapi.yaml'
lint:
extends:
- recommended
rules:
tag-description: off
referenceDocs:
showConsole: true
layout:
scope: section
routingStrategy: browser
htmlTemplate: ./web/index.html

View File

@ -1,58 +0,0 @@
var gulp = require('gulp');
var util = require('gulp-util')
var gulpConnect = require('gulp-connect');
var connect = require('connect');
var cors = require('cors');
var path = require('path');
var exec = require('child_process').exec;
var portfinder = require('portfinder');
var swaggerRepo = require('swagger-repo');
var DIST_DIR = 'dist';
gulp.task('edit', gulp.series(
function (cb) {
exec('npm run bundle-swagger-ui', function (err, stdout, stderr) {
console.log(stderr);
cb(err);
});
},
function () {
portfinder.getPort({ port: 5000 }, function (err, port) {
var app = connect();
app.use(swaggerRepo.swaggerEditorMiddleware());
app.listen(port);
util.log(util.colors.green('swagger-editor started http://localhost:' + port));
});
}
));
gulp.task('build', function (cb) {
exec('npm run build', function (err, stdout, stderr) {
console.log(stderr);
cb(err);
});
});
gulp.task('reload', gulp.parallel('build', function () {
gulp.src(DIST_DIR).pipe(gulpConnect.reload())
}));
gulp.task('watch', function () {
gulp.watch(['spec/**/*', 'web/**/*'], gulp.series(['reload']));
});
gulp.task('serve', gulp.parallel('build', 'watch', 'edit', function () {
portfinder.getPort({ port: 3000 }, function (err, port) {
gulpConnect.server({
root: [DIST_DIR],
livereload: true,
port: port,
middleware: function (gulpConnect, opt) {
return [
cors()
]
}
});
});
}));

View File

@ -0,0 +1,7 @@
name: Content-Signature
in: header
description: >
Подпись сообщения, сформированная согласно указанным выше правилам
required: true
schema:
type: string

View File

@ -1,5 +1,5 @@
description: |
Объём денежных средств
Объём средств, которые необходимо вывести
type: object
required:
- amount
@ -12,5 +12,4 @@ properties:
format: int64
example: 1430000
currency:
x-rebillyMerge:
- $ref: '#/definitions/CurrencyID'
$ref: '../schemas/CurrencyID.yaml'

View File

@ -1,6 +1,6 @@
description: Данные банковской карты
allOf:
- $ref: '#/definitions/DestinationResource'
- $ref: '../schemas/DestinationResource.yaml'
- type: object
required:
- cardNumberMask
@ -19,8 +19,6 @@ allOf:
type: string
pattern: '^\d{2,4}$'
paymentSystem:
x-rebillyMerge:
- $ref: '#/definitions/BankCardPaymentSystem'
$ref: '../schemas/BankCardPaymentSystem.yaml'
tokenProvider:
x-rebillyMerge:
- $ref: '#/definitions/BankCardTokenProvider'
$ref: '../schemas/BankCardTokenProvider.yaml'

View File

@ -1,6 +1,6 @@
description: Данные криптовалютного кошелька
allOf:
- $ref: '#/definitions/DestinationResource'
- $ref: '../schemas/DestinationResource.yaml'
- type: object
required:
- cryptoWalletId
@ -13,5 +13,4 @@ allOf:
maxLength: 256
example: zu3TcwGI71Bpaaw2XkLWZXlhMdn4zpVzMQ
currency:
x-rebillyMerge:
- $ref: '#/definitions/CryptoCurrency'
$ref: '../schemas/CryptoCurrency.yaml'

View File

@ -7,22 +7,18 @@ required:
- resource
properties:
id:
x-rebillyMerge:
- $ref: '#/definitions/DestinationID'
- readOnly: true
$ref: '../schemas/DestinationID.yaml'
name:
description: |
Человекочитаемое название приёмника средств, по которому его легко узнать
type: string
example: Squarey plastic thingy
identity:
x-rebillyMerge:
- $ref: '#/definitions/IdentityID'
$ref: '../schemas/IdentityID.yaml'
currency:
x-rebillyMerge:
- $ref: '#/definitions/CurrencyID'
$ref: '../schemas/CurrencyID.yaml'
resource:
$ref: '#/definitions/DestinationResource'
$ref: '../schemas/DestinationResource.yaml'
metadata:
description: |
Произвольный, специфичный для клиента API и непрозрачный для системы набор данных, ассоциированных с
@ -31,5 +27,4 @@ properties:
example:
color_hint: olive-green
externalID:
x-rebillyMerge:
- $ref: '#/definitions/ExternalID'
$ref: '../schemas/ExternalID.yaml'

View File

@ -1,13 +1,11 @@
description: Смена статуса приемника на авторизованный
allOf:
- $ref: '#/definitions/Event'
- $ref: '../schemas/Event.yaml'
- type: object
required:
- destinationID
properties:
destinationID:
x-rebillyMerge:
- $ref: '#/definitions/DestinationID'
$ref: '../schemas/DestinationID.yaml'
externalID:
x-rebillyMerge:
- $ref: '#/definitions/ExternalID'
$ref: '../schemas/ExternalID.yaml'

View File

@ -1,9 +1,9 @@
description: Событие создания приемника денежных средств
allOf:
- $ref: '#/definitions/Event'
- $ref: '../schemas/Event.yaml'
- type: object
required:
- destination
properties:
destination:
$ref: '#/definitions/Destination'
$ref: '../schemas/Destination.yaml'

View File

@ -1,6 +1,5 @@
description: Ресурс приёмника денежных средств, используемый для осуществления выводов
type: object
discriminator: type
required:
- type
properties:
@ -12,3 +11,10 @@ properties:
- BankCard
- CryptoWallet
- DigitalWallet
discriminator:
propertyName: type
mapping:
'BankCard': '../schemas/BankCard.yaml'
'CryptoWallet': '../schemas/CryptoWallet.yaml'
'DigitalWallet': '../schemas/DigitalWallet.yaml'

View File

@ -1,13 +1,11 @@
description: Смена статуса приемника на не авторизованный
allOf:
- $ref: '#/definitions/Event'
- $ref: '../schemas/Event.yaml'
- type: object
required:
- destinationID
properties:
destinationID:
x-rebillyMerge:
- $ref: '#/definitions/DestinationID'
$ref: '../schemas/DestinationID.yaml'
externalID:
x-rebillyMerge:
- $ref: '#/definitions/ExternalID'
$ref: '../schemas/ExternalID.yaml'

View File

@ -1,6 +1,6 @@
description: Данные криптовалютного кошелька
allOf:
- $ref: '#/definitions/DestinationResource'
- $ref: '../schemas/DestinationResource.yaml'
- type: object
required:
- digitalWalletId

View File

@ -1,6 +1,5 @@
description: Данные события
type: object
discriminator: eventType
required:
- occuredAt
- topic
@ -29,3 +28,13 @@ properties:
- DestinationCreated
- DestinationAuthorized
- DestinationUnauthorized
discriminator:
propertyName: eventType
mapping:
'WithdrawalStarted': '../schemas/WithdrawalStarted.yaml'
'WithdrawalSucceeded': '../schemas/WithdrawalSucceeded.yaml'
'WithdrawalFailed': '../schemas/WithdrawalFailed.yaml'
'DestinationCreated': '../schemas/DestinationCreated.yaml'
'DestinationAuthorized': '../schemas/DestinationAuthorized.yaml'
'DestinationUnauthorized': '../schemas/DestinationUnauthorized.yaml'

View File

@ -0,0 +1,6 @@
type: object
required:
- message
properties:
message:
type: string

View File

@ -6,26 +6,20 @@ required:
- body
properties:
id:
x-rebillyMerge:
- $ref: '#/definitions/WithdrawalID'
$ref: '../schemas/WithdrawalID.yaml'
createdAt:
description: Дата и время запуска вывода
type: string
format: date-time
destination:
x-rebillyMerge:
- $ref: '#/definitions/DestinationID'
$ref: '../schemas/DestinationID.yaml'
body:
x-rebillyMerge:
- description: Объём средств, которые необходимо вывести
- $ref: '#/definitions/Asset'
$ref: '../schemas/Asset.yaml'
metadata:
description: |
Произвольный, специфичный для клиента API и непрозрачный для системы набор данных, ассоциированных с
данным выводом
wallet:
x-rebillyMerge:
- $ref: '#/definitions/WalletID'
$ref: '../schemas/WalletID.yaml'
externalID:
x-rebillyMerge:
- $ref: '#/definitions/ExternalID'
$ref: '../schemas/ExternalID.yaml'

View File

@ -1,13 +1,11 @@
description: Событие о неуспешном осуществлении вывода средств
allOf:
- $ref: '#/definitions/Event'
- $ref: '../schemas/Event.yaml'
- type: object
required:
- withdrawalID
properties:
withdrawalID:
x-rebillyMerge:
- $ref: '#/definitions/WithdrawalID'
$ref: '../schemas/WithdrawalID.yaml'
externalID:
x-rebillyMerge:
- $ref: '#/definitions/ExternalID'
$ref: '../schemas/ExternalID.yaml'

View File

@ -1,9 +1,9 @@
description: Событие о начале осуществления вывода средств
allOf:
- $ref: '#/definitions/Event'
- $ref: '../schemas/Event.yaml'
- type: object
required:
- withdrawal
properties:
withdrawal:
$ref: '#/definitions/Withdrawal'
$ref: '../schemas/Withdrawal.yaml'

View File

@ -1,13 +1,11 @@
description: Событие об успешном осуществлении вывода средств
allOf:
- $ref: '#/definitions/Event'
- $ref: '../schemas/Event.yaml'
- type: object
required:
- withdrawalID
properties:
withdrawalID:
x-rebillyMerge:
- $ref: '#/definitions/WithdrawalID'
$ref: '../schemas/WithdrawalID.yaml'
externalID:
x-rebillyMerge:
- $ref: '#/definitions/ExternalID'
$ref: '../schemas/ExternalID.yaml'

View File

@ -1,8 +1,11 @@
swagger: '2.0'
openapi: 3.0.0
info:
version: '0.1.0'
title: Vality Wallets · Webhook Events API
termsOfService: 'https://vality.dev/'
version: 0.1.0
title: Vality Wallets. Webhooks Events API
termsOfService: https://vality.dev/
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
description: |
## Wallet Webhook Events API
@ -75,22 +78,12 @@ info:
Набор атрибутов заголовка и список возможных алгоритмов формирования подписи
в дальнейшем могут быть расширены.
schemes:
- https
consumes:
- application/json; charset=utf-8
produces:
- application/json; charset=utf-8
parameters:
signature:
name: Content-Signature
in: header
description: >
Подпись сообщения, сформированная согласно указанным выше правилам
required: true
type: string
servers:
- url: 'https://merchant.site'
tags:
- name: Event Notifications
x-displayName: Оповещения
description: Доставка оповещений о событиях системы.
paths:
'/webhook':
$ref: './paths/webhook-url.yaml'

View File

@ -0,0 +1,17 @@
post:
tags:
- Event Notifications
summary: Оповестить о событии
operationId: notifyWebhookEvent
parameters:
- $ref: '../components/parameters/signature.yaml'
requestBody:
description: Данные произошедшего в платформе события
required: true
content:
application/json:
schema:
$ref: '../components/schemas/Event.yaml'
responses:
'200':
description: Оповещение обработано

21251
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,15 @@
{
"name": "swag-wallets-webhook-openapi-spec",
"version": "0.0.1",
"dependencies": {
"bower": "^1.7.7",
"connect": "^3.4.1",
"cors": "^2.7.1",
"gulp-connect": "^4.2.0",
"gulp-util": "^3.0.8",
"json-merge-patch": "^0.2.3",
"npm": "^8.1.3",
"portfinder": "^1.0.3",
"shelljs": "^0.8.5",
"swagger-repo": "^1.5.1",
"swagger-ui": "^2.1.4"
},
"name": "swag-webhook-events",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "node ./scripts/build.js",
"bundle-swagger-ui": "node ./scripts/bundle-swagger-ui.js",
"swagger": "swagger-repo",
"test": "swagger-repo validate",
"start": "gulp serve"
"dependencies": {
"@redocly/openapi-cli": "1.0.0-beta.81",
"json-merge-patch": "1.0.2",
"redoc-cli": "0.13.7"
},
"devDependencies": {
"gulp": "github:gulpjs/gulp"
"scripts": {
"start": "openapi preview-docs",
"build": "openapi bundle -o web_deploy/openapi.yaml && openapi bundle -o web_deploy/openapi.json",
"validate": "openapi lint"
}
}
}

197
pom.xml
View File

@ -6,8 +6,8 @@
<parent>
<groupId>dev.vality</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
<artifactId>library-parent-pom</artifactId>
<version>1.0.2</version>
</parent>
<artifactId>swag-wallets-webhook-events</artifactId>
@ -21,20 +21,19 @@
<properties>
<default.package>dev.vality.swag.wallets.webhook.events</default.package>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<swagger-annotations-version>1.5.21</swagger-annotations-version>
<jodatime-version>2.7</jodatime-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<java.version>1.8</java.version>
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<jetty-version>9.2.15.v20160210</jetty-version>
<slf4j-version>1.7.21</slf4j-version>
<junit-version>4.13.1</junit-version>
<slf4j-version>1.7.33</slf4j-version>
<junit-version>4.13.2</junit-version>
<servlet-api-version>2.5</servlet-api-version>
<jackson-version>2.13.1</jackson-version>
<spring-version>2.6.1</spring-version>
<springfox-version>3.0.0</springfox-version>
<jackson-version>2.11.3</jackson-version>
<jackson-threetenbp-version>2.6.4</jackson-threetenbp-version>
<spring-version>5.3.14</spring-version>
<javax-annotation-api-version>1.3.2</javax-annotation-api-version>
<jaxb-version>2.3.1</jaxb-version>
<openapi-generator-version>5.3.1</openapi-generator-version>
</properties>
<dependencies>
@ -47,20 +46,26 @@
<!--Spring dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>${spring-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>${spring-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>${spring-version}</version>
<scope>provided</scope>
</dependency>
@ -70,23 +75,21 @@
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-version}</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</exclusion>
</exclusions>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
@ -94,12 +97,6 @@
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
@ -109,57 +106,107 @@
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
<version>${javax-annotation-api-version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<version>2.0.1.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-version}</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>web_deploy/swagger.yaml</inputSpec>
<configOptions>
<dateLibrary>java8</dateLibrary>
</configOptions>
<language>spring</language>
<library>spring-mvc</library>
<apiPackage>${default.package}.api</apiPackage>
<modelPackage>${default.package}.model</modelPackage>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>server</id>
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-version}</version>
<executions>
<execution>
<id>spring-server</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>web_deploy/openapi.yaml</inputSpec>
<generatorName>spring</generatorName>
<generateModels>true</generateModels>
<generateApis>true</generateApis>
<generateApiDocumentation>true</generateApiDocumentation>
<generateSupportingFiles>true</generateSupportingFiles>
<apiPackage>${default.package}.api</apiPackage>
<modelPackage>${default.package}.model</modelPackage>
<supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
<configOptions>
<dateLibrary>java8</dateLibrary>
<delegatePattern>true</delegatePattern>
<useBeanValidation>true</useBeanValidation>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>client</id>
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-version}</version>
<executions>
<execution>
<id>remote</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>web_deploy/openapi.yaml</inputSpec>
<generatorName>java</generatorName>
<configOptions>
<dateLibrary>java8</dateLibrary>
</configOptions>
<library>resttemplate</library>
<apiPackage>${default.package}.api</apiPackage>
<modelPackage>${default.package}.model</modelPackage>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

4
renovate.json Normal file
View File

@ -0,0 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["local>valitydev/.github:renovate-config"]
}

View File

@ -1,17 +0,0 @@
#!/usr/bin/env node
'use strict';
var TARGET_DIR = 'dist'
if (process.argv[2]) {
TARGET_DIR = process.argv[2]
}
require('shelljs/global');
set('-e');
mkdir('-p', TARGET_DIR);
cp('-R', 'web/*', TARGET_DIR + '/');
exec('npm run swagger bundle -- -o ' + TARGET_DIR + '/swagger.json');
exec('npm run swagger bundle -- --yaml -o ' + TARGET_DIR + '/swagger.yaml');

View File

@ -1,18 +0,0 @@
#!/usr/bin/env node
'use strict';
var Path = require('path');
var TARGET_DIR = 'dist'
if (process.argv[2]) {
TARGET_DIR = process.argv[2]
}
require('shelljs/global');
set('-e');
mkdir('-p', TARGET_DIR);
var SWAGGER_UI_DIST = Path.dirname(require.resolve('swagger-ui'));
rm('-rf', TARGET_DIR + '/swagger-ui/')
cp('-R', SWAGGER_UI_DIST, TARGET_DIR + '/swagger-ui/')
sed('-i', 'http://petstore.swagger.io/v2/swagger.json', '../swagger.json', TARGET_DIR + '/swagger-ui/index.html')

View File

@ -1,31 +0,0 @@
var jpointer = require('json-pointer');
var mergePatch = require('json-merge-patch');
module.exports = {
pathExpression: '$..["x-merge-properties"]',
init: function(swagger) {
console.log('* x-merge-properties plugin');
},
process: function(parent, name, jsonpath, swagger) {
var value = parent[name];
if (!Array.isArray(value)) {
throw Error('x-merge-properties argument should be array at ' + jsonpath);
}
let required = [];
let properties = {};
value.forEach(function(obj) {
if (obj.$ref && (typeof obj.$ref === 'string')) {
obj = jpointer.get(swagger, obj.$ref.substring(1));
}
if (typeof obj !== 'object') throw Error('Can\'t merge non-object values at ' + jsonpath);
required = required.concat(obj.required || []);
properties = mergePatch.apply(properties, obj.properties || {});
});
delete parent[name];
parent.required = required;
parent.properties = properties;
},
finish: function(swagger) {
// TODO: cleanup unused $refs
},
}

View File

@ -1,28 +0,0 @@
var jpointer = require('json-pointer');
var mergePatch = require('json-merge-patch');
module.exports = {
pathExpression: '$..["x-rebillyMerge"]',
init: function(swagger) {
console.log('* x-rebillyMerge plugin');
},
process: function(parent, name, jsonpath, swagger) {
var value = parent[name];
if (!Array.isArray(value)) {
throw Error('x-rebillyMerge argument should be array at ' + jsonpath);
}
let res = null;
value.forEach(function(obj) {
if (typeof obj !== 'object') throw Error('Can\'t merge non-object values at ' + jsonpath);
if (obj.$ref && (typeof obj.$ref === 'string')) {
obj = jpointer.get(swagger, obj.$ref.substring(1));
}
res = mergePatch.apply(res, obj);
});
delete parent[name];
Object.assign(parent, res);
},
finish: function(swagger) {
// TODO: cleanup unused $refs
},
}

View File

@ -1,24 +0,0 @@
## Global headers
In order to minimize duplications you can use `headers` global object (similar to `definitions`, `responses`).
During build process all references to global `headers` will be inlined and `headers` will be removed form resulting spec so spec will be valid (global `headers` is not allowed by Swagger spec):
Example:
```yaml
...
headers:
Rate-Limit-Limit:
description: The number of allowed requests in the current period
type: integer
...
paths:
/api-keys:
get:
summary: Retrieve a list of api keys
responses:
200:
description: A list of api keys was retrieved successfully
headers:
Rate-Limit-Limit:
$ref: "#/headers/Rate-Limit-Limit"
```

View File

@ -1,24 +0,0 @@
description: Данные счета
type: object
required:
- currency
- identity
properties:
id:
x-rebillyMerge:
- $ref: '#/definitions/AccountID'
createdAt:
description: Дата и время создания счета
type: string
format: date-time
currency:
x-rebillyMerge:
- $ref: '#/definitions/CurrencyID'
identity:
x-rebillyMerge:
- $ref: '#/definitions/IdentityID'
accountNumber:
x-rebillyMerge:
- $ref: '#/definitions/AccountNumber'

View File

@ -1,16 +0,0 @@
post:
tags:
- Event Notifications
summary: Оповестить о событии
operationId: notifyWebhookEvent
parameters:
- $ref: '#/parameters/signature'
- in: body
name: event
description: Данные произошедшего в системе события
required: true
schema:
$ref: '#/definitions/Event'
responses:
'200':
description: Оповещение обработано

View File

@ -1,35 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<head>
<title>Vality Wallets · Webhook Events API</title>
<!-- Needed for adaptive design -->
<meta charset="utf-8" />
<!-- needed for adaptive design -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js">
</script>
<!-- ReDoc doesn't change outer page styles -->
<link rel="icon" type="image/png" href="favicon.png">
<!--
ReDoc uses font options from the parent element
So override default browser styles
-->
<style>
body {
margin: 0;
padding: 0;
}
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id='redoc'></div>
<script type="text/javascript">
Redoc.init(
"./swagger.json",
{
theme: {
breakpoints: {
// 3-panel view fix
medium: '75rem'
}
}
},
document.getElementById('redoc')
);
</script>
</body>
</html>
{{{redocHead}}}
</head>
<body>
{{{redocHTML}}}
</body>
</html>