Skip to content

Commit

Permalink
Merge pull request #221 from LiveRamp/release_APIE_FY22Q3S4
Browse files Browse the repository at this point in the history
Release v6.2.3
  • Loading branch information
nhtzr authored Nov 23, 2021
2 parents 7978ae8 + 4fd87fa commit 4a00cec
Show file tree
Hide file tree
Showing 10 changed files with 2,232 additions and 142 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mhart/alpine-node:12.16.1
FROM mhart/alpine-node:16
RUN apk add --update --no-cache bash

WORKDIR /app/reslang
Expand Down
7 changes: 6 additions & 1 deletion docs/releases.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## 6.2.2 11/05/2021
## 6.2.3 11/23/2021

- Include the descriptions from `/events` syntax in the generated description for operations in asyncapi spec.
- Fix error when running `--events --open` flags: `The programmatic API was removed in npm v8.0.0`

## 6.2.2 11/15/2021

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

Expand Down
1 change: 1 addition & 0 deletions models/eventing/events.reslang
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ resource v2/TestResource {
/operations
POST GET
/events
"expected event subscribe comment"
POST GET completed
}

Expand Down
1 change: 1 addition & 0 deletions models/eventing/testdata/asyncapi.expected
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ channels:
description: A test REST resource
subscribe:
summary: 'REST: v2/TestResource'
description: expected event subscribe comment
operationId: v2/TestResource
message:
$ref: '#/components/messages/v2TestResource'
Expand Down
1 change: 1 addition & 0 deletions models/eventing/testdata/parsed.expected
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
],
"events": [
{
"comment": "expected event subscribe comment",
"operation": "POST"
},
{
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@liveramp/reslang",
"version": "6.2.2",
"version": "6.2.3",
"main": "index.js",
"license": "Apache-2.0",
"engines": {
Expand All @@ -24,7 +24,7 @@
"typescript": "^3.4.5"
},
"dependencies": {
"@asyncapi/generator": "^0.34.3",
"@asyncapi/generator": "^1.8.23",
"@types/pluralize": "^0.0.29",
"@types/tmp": "^0.1.0",
"clipboardy": "^2.0.0",
Expand Down
10 changes: 2 additions & 8 deletions show-asyncapi
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

rm -rf /tmp/asyncapi
mkdir /tmp/asyncapi
open_site(){
sleep 3
open /tmp/asyncapi/index.html
}

pbpaste > /tmp/asyncapi-spec.yaml

open_site &
./node_modules/.bin/ag /tmp/asyncapi-spec.yaml html --output /tmp/asyncapi
npx -p @asyncapi/generator ag /tmp/asyncapi-spec.yaml @asyncapi/html-template --output /tmp/asyncapi
open /tmp/asyncapi/index.html
77 changes: 46 additions & 31 deletions src/genevents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,8 @@ export default class EventsGen extends BaseGen {
const unique = camelCase(this.formSingleUniqueName(el))
if (isResourceLike(el) && !el.future && el.events) {
const topic = this.topicOfRestResource(el);
channels[topic] = {
description:
this.translateDoc(el.comment) || "no documentation",
subscribe: {
summary: "REST: " + el.name,
operationId: el.name,
message: {
$ref: `#/components/messages/${unique}`
}
}
}
const channel = this.eventChannelForRestResource(el, unique);
channels[topic] = channel
}
if (isProduces(el)) {
produces.add(el.event.name)
Expand All @@ -143,26 +134,8 @@ export default class EventsGen extends BaseGen {
all.forEach((name) => {
const def = this.extractDefinition(name)
const topic = this.topicOfAdhocEvent(def);
const unq = camelCase(this.formSingleUniqueName(def))
const details: any = {
description:
this.translateDoc(def.comment) || "no documentation"
}
const msg = {
summary: "Adhoc: " + def.name,
operationId: def.name,
message: {
$ref: `#/components/messages/${unq}`
}
}
if (produces.has(name)) {
details.publish = msg
}
if (consumes.has(name)) {
details.subscribe = msg
}

channels[topic] = details
const channel = this.eventChannelForAdhocDefinition(def, name, produces, consumes);
channels[topic] = channel
})
}

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

private eventChannelForAdhocDefinition(def: AnyKind, name: string, produces: Set<string>, consumes: Set<string>) {
const unq = camelCase(this.formSingleUniqueName(def))
const channel: any = {
description:
this.translateDoc(def.comment) || "no documentation"
}
const operationBody = {
summary: "Adhoc: " + def.name,
operationId: def.name,
message: {
$ref: `#/components/messages/${unq}`
}
}
if (produces.has(name)) {
channel.publish = operationBody
}
if (consumes.has(name)) {
channel.subscribe = operationBody
}
return channel;
}

private topicOfRestResource(el: IReference) {
let ns = kebabCase(this.getSpace());
let version = getVersion(el.name);
let name = kebabCase(el.name);
return this.toEventTopic(ns, version, name);
}

private eventChannelForRestResource(el: IResourceLike, unique: string) {
const channelDescription = this.translateDoc(el.comment) || "no documentation";
const subscribeOpDescription = el.events
?.map(e => this.translateDoc(e.comment))
.filter(d => !!d)
.join("\n\n") ?? ""
let channelForRestResource = {
description: channelDescription,
subscribe: {
summary: "REST: " + el.name,
description: subscribeOpDescription != "" ? subscribeOpDescription : null,
operationId: el.name,
message: {
$ref: `#/components/messages/${unique}`
}
}
};
return channelForRestResource;
}

private toEventTopic(ns: string, version: string, name: string) {
const basic = `${ns}_${version}-${name}`;
const escaped = basic.replace(/[^a-zA-Z0-9_-]/, "_");
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import JsonSchemaGen from "./genjsonschema"
const RULES = "rules.json"
const LOCAL_RULES = lpath.join(__dirname, "library", RULES)

export const VERSION = "v6.2.2"
export const VERSION = "v6.2.3"

// parse the cmd line
const args = yargs
Expand Down
Loading

0 comments on commit 4a00cec

Please sign in to comment.