Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-openapi-documenter",
"version": "0.0.111",
"version": "0.0.112",
"description": "Generate OpenAPI v3 documentation and Postman Collections from your Serverless Config",
"main": "index.js",
"keywords": [
Expand Down Expand Up @@ -50,7 +50,6 @@
"chalk": "^4.1.2",
"js-yaml": "^4.1.0",
"json-schema-for-openapi": "^0.5.0",
"lodash.isequal": "^4.5.0",
"openapi-to-postmanv2": "^5.0.0",
"uuid": "^11.1.0"
},
Expand Down
8 changes: 6 additions & 2 deletions src/definitionGenerator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";

const isEqual = require("node:util").isDeepStrictEqual;
const path = require("path");

const {
Expand All @@ -8,7 +9,6 @@ const {
stringifyYaml,
createConfig,
} = require("@redocly/openapi-core");
const isEqual = require("lodash.isequal");
const { v4: uuid } = require("uuid");

const SchemaHandler = require("./schemaHandler");
Expand Down Expand Up @@ -39,7 +39,11 @@ class DefinitionGenerator {
},
};

this.schemaHandler = new SchemaHandler(serverless, this.openAPI);
this.schemaHandler = new SchemaHandler(
serverless,
this.openAPI,
this.logger
);

this.operationIdMap = {};
this.functionMap = {};
Expand Down
14 changes: 12 additions & 2 deletions src/schemaHandler.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"use strict";

const isEqual = require("node:util").isDeepStrictEqual;
const path = require("path");

const $RefParser = require("@apidevtools/json-schema-ref-parser");
const SchemaConvertor = require("json-schema-for-openapi");
const isEqual = require("lodash.isequal");
const { v4: uuid } = require("uuid");

class SchemaHandler {
constructor(serverless, openAPI) {
constructor(serverless, openAPI, logger) {
this.logger = logger;

this.apiGatewayModels =
serverless.service?.provider?.apiGateway?.request?.schemas || {};
this.documentation = serverless.service.custom.documentation;
Expand All @@ -19,6 +21,12 @@ class SchemaHandler {
this.__standardiseModels();

try {
this.logger.verbose(
`Trying to resolve Ref-Parser config from: ${path.resolve(
"options",
"ref-parser.js"
)}`
);
this.refParserOptions = require(path.resolve("options", "ref-parser.js"));
} catch (err) {
this.refParserOptions = {};
Expand Down Expand Up @@ -63,6 +71,7 @@ class SchemaHandler {
const modelName = model.name;
const modelSchema = model.schema;

this.logger.verbose(`dereferencing model: ${model.name}`);
const dereferencedSchema = await this.__dereferenceSchema(
modelSchema
).catch((err) => {
Expand All @@ -76,6 +85,7 @@ class SchemaHandler {
return modelSchema;
});

this.logger.verbose(`convering model: ${model.name}`);
const convertedSchemas = SchemaConvertor.convert(
dereferencedSchema,
modelName
Expand Down
1 change: 1 addition & 0 deletions test/unit/openAPIGenerator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ describe("OpenAPIGenerator", () => {
notice: (str) => {},
error: (str) => {},
success: (str) => {},
verbose: (str) => {},
},
};
});
Expand Down
Loading