Skip to content

Commit

Permalink
Merge branch 'feature/init-cleanup' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
John Carmichael committed Dec 30, 2023
2 parents 3fe0fa6 + ad92c9c commit ba7706f
Show file tree
Hide file tree
Showing 45 changed files with 413 additions and 68 deletions.
20 changes: 10 additions & 10 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
.git
.git*
.git
.git/*
githooks/
src/*
test-build/*
srcASYNC2/*
srcOA2/*
srcOA3/*
docs/*
coverage/*

.github/*
.babelrc
.eslintrc
Expand All @@ -19,6 +10,15 @@ coverage/*
.prettierrc
.project
.settings
githooks/
src/*
test-build/*
srcASYNC2/*
srcOA2/*
srcOA3/*
docs/*
coverage/*
init-files/build
_config.yml
CHANGELOG.md
CODE_OF_CONDUCT.md
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ An AsyncAPI/OpenAPI preprocessor tool with an aim to writer "DRY'er" source yaml
Point boats at an entry index file and let it compile the rest automatically, either AsyncApi, OpenAPI or Swagger

## Changelog
- 2023/12/28 4.10.0: feat: init files now use the own lightweight files over the files used for testing purposes.
- 2023/12/28 4.9.4: fix: readme.md link
- 2023/12/28 4.9.3: fix: https://github.com/j-d-carmichael/boats/issues/86
- 2023/12/28 4.9.2: chore: Dependency dropped, walker package no longer used
Expand Down
1 change: 1 addition & 0 deletions init-files/asyncapi/channels/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ autoChannelIndexer() }}
4 changes: 4 additions & 0 deletions init-files/asyncapi/channels/ms-auth/cache-connection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
publish:
message:
payload:
$ref: ../../components/schemas/ms-auth/cacheConnection.yml
6 changes: 6 additions & 0 deletions init-files/asyncapi/channels/ms-auth/cache-user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
publish:
operationId: {{uniqueOpId('Publish')}}
message:
contentType: application/json
payload:
$ref: ../../components/schemas/ms-auth/cacheUser.yml.njk
1 change: 1 addition & 0 deletions init-files/asyncapi/components/schemas/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ autoComponentIndexer() }}
16 changes: 16 additions & 0 deletions init-files/asyncapi/components/schemas/ms-auth/cacheConnection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type: object
properties:
username:
type: string
connections:
type: array
items:
type: object
properties:
updated:
type: string
format: date
state:
type: string
username:
type: string
6 changes: 6 additions & 0 deletions init-files/asyncapi/components/schemas/ms-auth/cacheUser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: object
properties:
username:
type: string
email:
type: string
33 changes: 33 additions & 0 deletions init-files/asyncapi/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
asyncapi: 2.0.0
info:
title: "{{ packageJson('name') }}"
version: 1.0.1
description: Beautiful Open / Async Template System - Write less yaml with BOATS and Nunjucks.
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0

defaultContentType: application/json

channels:
$ref: ./channels/index.yml

components:
schemas:
$ref: ./components/schemas/index.yml

{{
inject([{
toAllOperations: {
content: {
description: '{{ autoSummary() }}',
publish: {
operationId: "{{ uniqueOpId({firstSegmentSplit: '_'}) }}",
message: {
contentType: 'application/json'
}
}
}
}
}])
}}
8 changes: 8 additions & 0 deletions init-files/oa2/definitions/generic/searchMeta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type: object
properties:
totalResultCount:
type: number
offset:
type: number
limit:
type: number
4 changes: 4 additions & 0 deletions init-files/oa2/definitions/health/model.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type: object
properties:
health:
type: string
1 change: 1 addition & 0 deletions init-files/oa2/definitions/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ autoComponentIndexer({dropBaseName: true}) }}
6 changes: 6 additions & 0 deletions init-files/oa2/definitions/user/model.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: object
required:
- name
properties:
name:
type: string
1 change: 1 addition & 0 deletions init-files/oa2/definitions/user/models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ mixin("../../mixins/pagination.yml", "../generic/searchMeta.yml.njk", "./model.yml.njk", "--skip-auto-indent") }}
60 changes: 60 additions & 0 deletions init-files/oa2/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
swagger: "2.0"
info:
version: 1.0.1
title: "{{ packageJson('name') }}"
description: A sample API
contact:
name: Swagger API Team
email: 'john@boats.io'
url: https://github.com/johndcarmichael/boats/
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html

schemes:
- https
- http
host: api.example.com

securityDefinitions:
jwtToken:
type: apiKey
in: header
name: authorization
apiKey:
type: apiKey
in: header
name: x-api-key

paths:
$ref: paths/index.yml
parameters:
$ref: parameters/index.yml
definitions:
$ref: definitions/index.yml

{{
inject([{
toAllOperations: {
excludePaths: ['/health'],
content: {
security: [{
jwtToken: []
}]
}
}
}, {
toAllOperations: {
content: {
tags: [ '{{ autoTag() }}' ],
summary: '{{ autoSummary() }}',
operationId: '{{ uniqueOpId() }}',
responses: {
'200': {
description: 'OK'
}
}
}
}
}])
}}
8 changes: 8 additions & 0 deletions init-files/oa2/mixins/pagination.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type: object
properties:
meta:
$ref: {{ var1 }}
data:
type: array
items:
$ref: {{ var2 }}
1 change: 1 addition & 0 deletions init-files/oa2/parameters/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ autoComponentIndexer() }}
5 changes: 5 additions & 0 deletions init-files/oa2/parameters/pathId.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
in: path
name: id
type: string
required: true
description: ID of object
5 changes: 5 additions & 0 deletions init-files/oa2/parameters/queryOffset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
in: query
name: offset
required: false
type: integer
description: The number of items to skip before starting to collect the result set.
4 changes: 4 additions & 0 deletions init-files/oa2/paths/health/get.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
responses:
'200':
schema:
$ref: ../../definitions/health/model.yml
1 change: 1 addition & 0 deletions init-files/oa2/paths/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ autoPathIndexer() }}
6 changes: 6 additions & 0 deletions init-files/oa2/paths/user/get.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
- $ref: ../../parameters/queryOffset.yml
responses:
'200':
schema:
$ref: ../../definitions/user/models.yml
6 changes: 6 additions & 0 deletions init-files/oa2/paths/user/{id}/get.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
- $ref: ../../../parameters/pathId.yml
responses:
'200':
schema:
$ref: ../../../definitions/user/model.yml
1 change: 1 addition & 0 deletions init-files/oa3/components/parameters/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ autoComponentIndexer() }}
6 changes: 6 additions & 0 deletions init-files/oa3/components/parameters/pathId.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
in: path
name: id
schema:
type: string
required: true
description: ID of object to fetch
7 changes: 7 additions & 0 deletions init-files/oa3/components/parameters/queryOffset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
in: query
name: offset
required: false
schema:
type: integer
minimum: 0
description: The number of items to skip before starting to collect the result set
8 changes: 8 additions & 0 deletions init-files/oa3/components/schemas/generic/searchMeta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type: object
properties:
totalResultCount:
type: number
offset:
type: number
limit:
type: number
4 changes: 4 additions & 0 deletions init-files/oa3/components/schemas/health/model.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type: object
properties:
http:
type: boolean
Empty file.
6 changes: 6 additions & 0 deletions init-files/oa3/components/schemas/user/model.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: object
required:
- name
properties:
name:
type: string
1 change: 1 addition & 0 deletions init-files/oa3/components/schemas/user/models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ mixin("../../../mixins/pagination.yml", "../generic/searchMeta.yml.njk", "./model.yml.njk", "--skip-auto-indent") }}
1 change: 1 addition & 0 deletions init-files/oa3/components/security/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ autoComponentIndexer() }}
3 changes: 3 additions & 0 deletions init-files/oa3/components/security/jwtToken.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type: apiKey
in: header
name: Authorization
80 changes: 80 additions & 0 deletions init-files/oa3/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
openapi: "3.0.0"
info:
version: "{{ packageJson('version') }}"
title: "{{ packageJson('name') }}"

paths:
$ref: paths/index.yml

components:
parameters:
$ref: components/parameters/index.yml
schemas:
$ref: components/schemas/index.yml
securitySchemes:
$ref: components/security/index.yml

{{
inject([
{
toAllOperations: {
content: {
tags: [ '{{ autoTag() }}' ],
summary: '{{ autoSummary() }}',
operationId: '{{ uniqueOpId() }}',
responses: {
'200': {
description: 'OK'
},
'400': {
description: 'Bad Request'
},
'401': {
description: 'Unauthorized'
},
'403': {
description: 'Forbidden'
},
'406': {
description: 'Not Acceptable'
}
}
}
}
},
{
toAllOperations: {
includeOnlyPaths: [
'/admin/**'
],
content: {
'x-permission': '{{ routePermission() }}'
}
}
},
{
toAllOperations: {
excludePaths: [
'/health'
],
content: {
security: [{
jwtToken: []
}]
}
}
},
{
toAllOperations: {
includeMethods: ['post', 'patch'],
content: {
responses: {
'422': {
description: 'Not Acceptable'
}
}
}
}
}
])
}}
8 changes: 8 additions & 0 deletions init-files/oa3/mixins/pagination.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type: object
properties:
meta:
$ref: {{ var1 }}
data:
type: array
items:
$ref: {{ var2 }}
6 changes: 6 additions & 0 deletions init-files/oa3/paths/health/get.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
responses:
'200':
content:
application/json:
schema:
$ref: ../../components/schemas/health/model.yml
1 change: 1 addition & 0 deletions init-files/oa3/paths/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ autoPathIndexer() }}
8 changes: 8 additions & 0 deletions init-files/oa3/paths/user/get.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
- $ref: ../../components/parameters/queryOffset.yml
responses:
'200':
content:
application/json:
schema:
$ref: ../../components/schemas/user/models.yml
Loading

0 comments on commit ba7706f

Please sign in to comment.