Skip to content

Commit 4a00cec

Browse files
authored
Merge pull request #221 from LiveRamp/release_APIE_FY22Q3S4
Release v6.2.3
2 parents 7978ae8 + 4fd87fa commit 4a00cec

File tree

10 files changed

+2232
-142
lines changed

10 files changed

+2232
-142
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mhart/alpine-node:12.16.1
1+
FROM mhart/alpine-node:16
22
RUN apk add --update --no-cache bash
33

44
WORKDIR /app/reslang

docs/releases.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
## 6.2.2 11/05/2021
1+
## 6.2.3 11/23/2021
2+
3+
- Include the descriptions from `/events` syntax in the generated description for operations in asyncapi spec.
4+
- Fix error when running `--events --open` flags: `The programmatic API was removed in npm v8.0.0`
5+
6+
## 6.2.2 11/15/2021
27

38
- Fix `SyntaxError: Error resolving $ref pointer` when generating swagger/asyncapi using resourcelike attributes.
49

models/eventing/events.reslang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ resource v2/TestResource {
2222
/operations
2323
POST GET
2424
/events
25+
"expected event subscribe comment"
2526
POST GET completed
2627
}
2728

models/eventing/testdata/asyncapi.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ channels:
2121
description: A test REST resource
2222
subscribe:
2323
summary: 'REST: v2/TestResource'
24+
description: expected event subscribe comment
2425
operationId: v2/TestResource
2526
message:
2627
$ref: '#/components/messages/v2TestResource'

models/eventing/testdata/parsed.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@
257257
],
258258
"events": [
259259
{
260+
"comment": "expected event subscribe comment",
260261
"operation": "POST"
261262
},
262263
{

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@liveramp/reslang",
3-
"version": "6.2.2",
3+
"version": "6.2.3",
44
"main": "index.js",
55
"license": "Apache-2.0",
66
"engines": {
@@ -24,7 +24,7 @@
2424
"typescript": "^3.4.5"
2525
},
2626
"dependencies": {
27-
"@asyncapi/generator": "^0.34.3",
27+
"@asyncapi/generator": "^1.8.23",
2828
"@types/pluralize": "^0.0.29",
2929
"@types/tmp": "^0.1.0",
3030
"clipboardy": "^2.0.0",

show-asyncapi

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
rm -rf /tmp/asyncapi
44
mkdir /tmp/asyncapi
5-
open_site(){
6-
sleep 3
7-
open /tmp/asyncapi/index.html
8-
}
9-
105
pbpaste > /tmp/asyncapi-spec.yaml
11-
12-
open_site &
13-
./node_modules/.bin/ag /tmp/asyncapi-spec.yaml html --output /tmp/asyncapi
6+
npx -p @asyncapi/generator ag /tmp/asyncapi-spec.yaml @asyncapi/html-template --output /tmp/asyncapi
7+
open /tmp/asyncapi/index.html

src/genevents.ts

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,8 @@ export default class EventsGen extends BaseGen {
118118
const unique = camelCase(this.formSingleUniqueName(el))
119119
if (isResourceLike(el) && !el.future && el.events) {
120120
const topic = this.topicOfRestResource(el);
121-
channels[topic] = {
122-
description:
123-
this.translateDoc(el.comment) || "no documentation",
124-
subscribe: {
125-
summary: "REST: " + el.name,
126-
operationId: el.name,
127-
message: {
128-
$ref: `#/components/messages/${unique}`
129-
}
130-
}
131-
}
121+
const channel = this.eventChannelForRestResource(el, unique);
122+
channels[topic] = channel
132123
}
133124
if (isProduces(el)) {
134125
produces.add(el.event.name)
@@ -143,26 +134,8 @@ export default class EventsGen extends BaseGen {
143134
all.forEach((name) => {
144135
const def = this.extractDefinition(name)
145136
const topic = this.topicOfAdhocEvent(def);
146-
const unq = camelCase(this.formSingleUniqueName(def))
147-
const details: any = {
148-
description:
149-
this.translateDoc(def.comment) || "no documentation"
150-
}
151-
const msg = {
152-
summary: "Adhoc: " + def.name,
153-
operationId: def.name,
154-
message: {
155-
$ref: `#/components/messages/${unq}`
156-
}
157-
}
158-
if (produces.has(name)) {
159-
details.publish = msg
160-
}
161-
if (consumes.has(name)) {
162-
details.subscribe = msg
163-
}
164-
165-
channels[topic] = details
137+
const channel = this.eventChannelForAdhocDefinition(def, name, produces, consumes);
138+
channels[topic] = channel
166139
})
167140
}
168141

@@ -173,13 +146,55 @@ export default class EventsGen extends BaseGen {
173146
return this.toEventTopic(ns, version, name);
174147
}
175148

149+
private eventChannelForAdhocDefinition(def: AnyKind, name: string, produces: Set<string>, consumes: Set<string>) {
150+
const unq = camelCase(this.formSingleUniqueName(def))
151+
const channel: any = {
152+
description:
153+
this.translateDoc(def.comment) || "no documentation"
154+
}
155+
const operationBody = {
156+
summary: "Adhoc: " + def.name,
157+
operationId: def.name,
158+
message: {
159+
$ref: `#/components/messages/${unq}`
160+
}
161+
}
162+
if (produces.has(name)) {
163+
channel.publish = operationBody
164+
}
165+
if (consumes.has(name)) {
166+
channel.subscribe = operationBody
167+
}
168+
return channel;
169+
}
170+
176171
private topicOfRestResource(el: IReference) {
177172
let ns = kebabCase(this.getSpace());
178173
let version = getVersion(el.name);
179174
let name = kebabCase(el.name);
180175
return this.toEventTopic(ns, version, name);
181176
}
182177

178+
private eventChannelForRestResource(el: IResourceLike, unique: string) {
179+
const channelDescription = this.translateDoc(el.comment) || "no documentation";
180+
const subscribeOpDescription = el.events
181+
?.map(e => this.translateDoc(e.comment))
182+
.filter(d => !!d)
183+
.join("\n\n") ?? ""
184+
let channelForRestResource = {
185+
description: channelDescription,
186+
subscribe: {
187+
summary: "REST: " + el.name,
188+
description: subscribeOpDescription != "" ? subscribeOpDescription : null,
189+
operationId: el.name,
190+
message: {
191+
$ref: `#/components/messages/${unique}`
192+
}
193+
}
194+
};
195+
return channelForRestResource;
196+
}
197+
183198
private toEventTopic(ns: string, version: string, name: string) {
184199
const basic = `${ns}_${version}-${name}`;
185200
const escaped = basic.replace(/[^a-zA-Z0-9_-]/, "_");

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import JsonSchemaGen from "./genjsonschema"
1818
const RULES = "rules.json"
1919
const LOCAL_RULES = lpath.join(__dirname, "library", RULES)
2020

21-
export const VERSION = "v6.2.2"
21+
export const VERSION = "v6.2.3"
2222

2323
// parse the cmd line
2424
const args = yargs

0 commit comments

Comments
 (0)