Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions .github/super-linter.env
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ VALIDATE_TSX=false
VALIDATE_TYPESCRIPT_ES=false
VALIDATE_TYPESCRIPT_PRETTIER=false
VALIDATE_TYPESCRIPT_STANDARD=false

# Skip OPENAPI check for this repo as it contains invalid OAS specs for testing purposes
VALIDATE_OPENAPI=false
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"update-lock-file": "update-lock-file @netcracker"
},
"dependencies": {
"@netcracker/qubership-apihub-api-unifier": "2.4.1",
"@netcracker/qubership-apihub-api-unifier": "bugfix-remove-duplicated-parameters",
"@netcracker/qubership-apihub-json-crawl": "1.0.4",
"fast-equals": "4.0.3"
},
Expand Down
21 changes: 19 additions & 2 deletions test/bugs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ import shouldNotMissRemoveDiffForEnumEntryInOneOfAfter from './helper/resources/
import shouldReportSingleDiffWhenRequiredPropertyIsChangedForTheCombinerBefore from './helper/resources/should-report-single-diff-when-required-property-is-changed-for-the-combiner/before.json'
import shouldReportSingleDiffWhenRequiredPropertyIsChangedForTheCombinerAfter from './helper/resources/should-report-single-diff-when-required-property-is-changed-for-the-combiner/after.json'

import duplicateParametersBefore from './helper/resources/duplicate-parameters/before.json'
import duplicateParametersAfter from './helper/resources/duplicate-parameters/after.json'

import { diffsMatcher } from './helper/matchers'
import { TEST_DIFF_FLAG, TEST_ORIGINS_FLAG } from './helper'
import { JSON_SCHEMA_NODE_SYNTHETIC_TYPE_NOTHING } from '@netcracker/qubership-apihub-api-unifier'
Expand Down Expand Up @@ -115,7 +118,7 @@ describe('Real Data', () => {
const after: any = infinityAfter
const { diffs } = apiDiff(before, after, OPTIONS)
const responseContentPath = ['paths', '/api/v1/dictionaries/dictionary/item', 'get', 'responses', '200', 'content']
expect(diffs).toEqual(diffsMatcher([
expect(diffs).toEqual(diffsMatcher([
expect.objectContaining({
afterDeclarationPaths: [['components', 'schemas', 'DictionaryItem', 'x-entity']],
afterValue: 'DictionaryItem',
Expand Down Expand Up @@ -232,7 +235,7 @@ describe('Real Data', () => {
const before: any = wildcardContentSchemaMediaTypeCombinedWithSpecificMediaTypeBefore
const after: any = wildcardContentSchemaMediaTypeCombinedWithSpecificMediaTypeAfter
const { diffs } = apiDiff(before, after, OPTIONS)

expect(diffs).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.replace,
Expand Down Expand Up @@ -302,4 +305,18 @@ describe('Real Data', () => {
}),
]))
})


it('should not report diffs for duplicated parameters', () => {
const { diffs } = apiDiff(duplicateParametersBefore, duplicateParametersAfter, OPTIONS)

expect(diffs).toHaveLength(1)
expect(diffs).toEqual(diffsMatcher([
expect.objectContaining({
action: DiffAction.add,
afterDeclarationPaths: [['paths', '/api/v1/user-management/user-federations/{id}/mappers/{id}', 'get', 'description']],
type: annotation,
}),
]))
})
})
37 changes: 37 additions & 0 deletions test/helper/resources/duplicate-parameters/after.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"openapi": "3.1.1",
"info": {
"title": "User Management API",
"version": "1.0.0"
},
"paths": {
"/api/v1/user-management/user-federations/{id}/mappers/{id}": {
"get": {
"description": "Retrieve mapper details for a specific federation and mapper ID.",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
}
}
}
36 changes: 36 additions & 0 deletions test/helper/resources/duplicate-parameters/before.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"openapi": "3.1.1",
"info": {
"title": "User Management API",
"version": "1.0.0"
},
"paths": {
"/api/v1/user-management/user-federations/{id}/mappers/{id}": {
"get": {
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
}
}
}
Loading