diff --git a/.github/workflows/generate-release.yml b/.github/workflows/generate-release.yml index b44a3e8..dd1c76c 100644 --- a/.github/workflows/generate-release.yml +++ b/.github/workflows/generate-release.yml @@ -72,6 +72,12 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + if [ ! -s release-description.md ]; then + echo "Release summary is empty, skipping release creation" + exit 0 + fi + + # Create GitHub Release gh release create ${{ steps.version.outputs.new_version }} \ --title "${{ steps.version.outputs.new_version }}" \ --notes-file final-release-description.md diff --git a/scripts/api-diff.js b/scripts/api-diff.js index 4bbc40c..7907744 100644 --- a/scripts/api-diff.js +++ b/scripts/api-diff.js @@ -93,12 +93,15 @@ function comparePaths() { if (!previousMethods[method]) { if (!changes.added[path]) changes.added[path] = new Set(); changes.added[path].add(method.toUpperCase()); - } else if (JSON.stringify(previousMethods[method]) !== JSON.stringify(details)) { - if (!changes.modified[path]) changes.modified[path] = []; - changes.modified[path].push({ - method: method.toUpperCase(), - changes: getChanges(previousMethods[method], details) - }); + } else { + const changedFields = getChanges(previousMethods[method], details); + if (changedFields.length > 0) { // Only add if there are meaningful changes + if (!changes.modified[path]) changes.modified[path] = []; + changes.modified[path].push({ + method: method.toUpperCase(), + changes: changedFields + }); + } } }); }); @@ -116,7 +119,7 @@ function comparePaths() { function getChanges(previous, current) { const changes = []; - const fields = ['summary', 'description', 'operationId', 'parameters', 'requestBody', 'responses']; + const fields = ['operationId', 'parameters', 'requestBody', 'responses']; fields.forEach(field => { if (JSON.stringify(previous[field]) !== JSON.stringify(current[field])) { diff --git a/tests/fixtures/modified-route-and-method/expected.md b/tests/fixtures/modified-route-and-method/expected.md index 5d37e55..e455c47 100644 --- a/tests/fixtures/modified-route-and-method/expected.md +++ b/tests/fixtures/modified-route-and-method/expected.md @@ -1,4 +1,3 @@ ## Modified - [POST] `/user` - responses - - summary diff --git a/tests/fixtures/modified-summary/current.json b/tests/fixtures/modified-summary/current.json new file mode 100644 index 0000000..3e3dc11 --- /dev/null +++ b/tests/fixtures/modified-summary/current.json @@ -0,0 +1,75 @@ +{ + "openapi": "3.0.3", + "info": { + "title": "Test API", + "description": "A sample API to for testing", + "version": "1.0.0" + }, + "servers": [ + { + "url": "https://api.example.com/v1" + } + ], + "paths": { + "/user": { + "post": { + "summary": "Creates a new user profile", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NewUser" + } + } + } + }, + "responses": { + "201": { + "description": "User created successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "email": { + "type": "string" + } + } + }, + "NewUser": { + "type": "object", + "required": [ + "name", + "email" + ], + "properties": { + "name": { + "type": "string" + }, + "email": { + "type": "string" + } + } + } + } + } +} diff --git a/tests/fixtures/modified-summary/expected.md b/tests/fixtures/modified-summary/expected.md new file mode 100644 index 0000000..e69de29 diff --git a/tests/fixtures/modified-summary/previous.json b/tests/fixtures/modified-summary/previous.json new file mode 100644 index 0000000..149a68d --- /dev/null +++ b/tests/fixtures/modified-summary/previous.json @@ -0,0 +1,75 @@ +{ + "openapi": "3.0.3", + "info": { + "title": "Test API", + "description": "A sample API to for testing", + "version": "1.0.0" + }, + "servers": [ + { + "url": "https://api.example.com/v1" + } + ], + "paths": { + "/user": { + "post": { + "summary": "Create a new user profile", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NewUser" + } + } + } + }, + "responses": { + "201": { + "description": "User created successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "email": { + "type": "string" + } + } + }, + "NewUser": { + "type": "object", + "required": [ + "name", + "email" + ], + "properties": { + "name": { + "type": "string" + }, + "email": { + "type": "string" + } + } + } + } + } +}