Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Andre klang feat/publish verification #66

Merged
merged 4 commits into from
Oct 8, 2024
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
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ pact broker and the provider name should be passed using the --provider option.
automatically find the latest versions of the consumer pact file(s) uploaded to the broker for
the specified provider name. The <swagger> argument should be the path or url to the swagger
json file. Optionally, pass a --tag option alongside a --provider option to filter the retrieved
pacts from the broker by Pact Broker version tags.
pacts from the broker by Pact Broker version tags. Pass the --publish flag together with
--providerApplicationVersion to publish the result to the pact broker.

If the pact broker has basic auth enabled, pass a --user option with username and password joined by a colon
(i.e. THE_USERNAME:THE_PASSWORD) to access the pact broker resources.
Expand All @@ -101,7 +102,13 @@ Options:
-o, --outputDepth [integer] Specifies the number of times to recurse while formatting the output objects. This is useful in case of large complicated objects or schemas. (default: 4)
-A, --additionalPropertiesInResponse [boolean] allow additional properties in response bodies, default false
-R, --requiredPropertiesInResponse [boolean] allows required properties in response bodies, default false
--publish Allows publication of verification result to pact broker, default false
--providerApplicationVersion [string] Version of provider, used when publishing result to broker, required if --publish is set
--buildUrl [string] Url to build/pipeline, used when publishing result to broker
--providerBranch [string] Branch of provider, used when publishing result to broker
--providerTags [string] Tags of provider, used when publishing result to broker, comma separated
-h, --help display help for command

```


Expand Down
15 changes: 13 additions & 2 deletions lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ program
'This is useful in case of large complicated objects or schemas.', parseInt, 4)
.option('-A, --additionalPropertiesInResponse [boolean]', 'allow additional properties in response bodies, default false')
.option('-R, --requiredPropertiesInResponse [boolean]', 'allows required properties in response bodies, default false')
.option('--publish', 'Allows publication of verification result to pact broker, default false')
.option('--providerApplicationVersion [string]', 'Version of provider, used when publishing result to broker')
.option('--providerBranch [string]', 'Branch of provider, used when publishing result to broker')
.option('--providerTags [string]', 'Tags of provider, used when publishing result to broker, comma seperated')
.option('--buildUrl [string]', 'Url to build/pipeline, used when publishing result to broker')
.description(
`Confirms the swagger spec and mock are compatible with each other.

Expand All @@ -70,7 +75,8 @@ pact broker and the provider name should be passed using the --provider option.
automatically find the latest versions of the consumer pact file(s) uploaded to the broker for
the specified provider name. The <swagger> argument should be the path or url to the swagger
json file. Optionally, pass a --tag option alongside a --provider option to filter the retrieved
pacts from the broker by Pact Broker version tags.
pacts from the broker by Pact Broker version tags. Pass the --publish flag together with
--providerApplicationVersion to publish the result to the pact broker.

If the pact broker has basic auth enabled, pass a --user option with username and password joined by a colon
(i.e. THE_USERNAME:THE_PASSWORD) to access the pact broker resources.
Expand Down Expand Up @@ -108,7 +114,12 @@ Note: command line options will take precedence over environment variables.
specPathOrUrl: swagger,
tag: options.tag,
additionalPropertiesInResponse: options.additionalPropertiesInResponse,
requiredPropertiesInResponse: options.requiredPropertiesInResponse
requiredPropertiesInResponse: options.requiredPropertiesInResponse,
providerApplicationVersion: options.providerApplicationVersion,
providerBranch: options.providerBranch,
providerTags: options.providerTags,
buildUrl: options.buildUrl,
publish: options.publish
});

displaySummary(result, options.outputDepth);
Expand Down
7 changes: 6 additions & 1 deletion lib/swagger-mock-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
? false // default to false - existing behaviour
: userOptions.requiredPropertiesInResponse === 'true'
? true
: false
: false,
publish: typeof userOptions.publish !== 'undefined'
});

const combineValidationResults = (
Expand Down Expand Up @@ -228,6 +229,10 @@
result.parsedMock,
result.validationOutcome
);

if (options.publish) {
await this.pactBroker.publishVerificationResult(options, result.parsedMock, result.validationOutcome);
}
}

return result.validationOutcome;
Expand All @@ -250,7 +255,7 @@
specSource: options.specSource,
validationOutcome
});
} catch (error) {

Check warning on line 258 in lib/swagger-mock-validator.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (22.x)

'error' is defined but never used

Check warning on line 258 in lib/swagger-mock-validator.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (18.x)

'error' is defined but never used

Check warning on line 258 in lib/swagger-mock-validator.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (20.x)

'error' is defined but never used

Check warning on line 258 in lib/swagger-mock-validator.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (22.x)

'error' is defined but never used

Check warning on line 258 in lib/swagger-mock-validator.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (20.x)

'error' is defined but never used

Check warning on line 258 in lib/swagger-mock-validator.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (20.x)

'error' is defined but never used

Check warning on line 258 in lib/swagger-mock-validator.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (22.x)

'error' is defined but never used

Check warning on line 258 in lib/swagger-mock-validator.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (22.x)

'error' is defined but never used

Check warning on line 258 in lib/swagger-mock-validator.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (18.x)

'error' is defined but never used

Check warning on line 258 in lib/swagger-mock-validator.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (18.x)

'error' is defined but never used

Check warning on line 258 in lib/swagger-mock-validator.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (20.x)

'error' is defined but never used

Check warning on line 258 in lib/swagger-mock-validator.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (18.x)

'error' is defined but never used
// do not fail tool on analytics errors
}
}
Expand Down
34 changes: 33 additions & 1 deletion lib/swagger-mock-validator/clients/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,40 @@
return response.data;
}

public async post(url: string, body: any): Promise<void> {
public async post(url: string, body: any, auth?: string): Promise<void> {

Check warning on line 26 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (22.x)

Unexpected any. Specify a different type

Check warning on line 26 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (18.x)

Unexpected any. Specify a different type

Check warning on line 26 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (20.x)

Unexpected any. Specify a different type

Check warning on line 26 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (22.x)

Unexpected any. Specify a different type

Check warning on line 26 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (20.x)

Unexpected any. Specify a different type

Check warning on line 26 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (20.x)

Unexpected any. Specify a different type

Check warning on line 26 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (22.x)

Unexpected any. Specify a different type

Check warning on line 26 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (22.x)

Unexpected any. Specify a different type

Check warning on line 26 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (18.x)

Unexpected any. Specify a different type

Check warning on line 26 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (18.x)

Unexpected any. Specify a different type

Check warning on line 26 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (20.x)

Unexpected any. Specify a different type

Check warning on line 26 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (18.x)

Unexpected any. Specify a different type
let authHeader: string | undefined;

if (auth) {
if (auth.includes(':')) {
authHeader = 'Basic ' + Buffer.from(auth).toString('base64');
} else {
authHeader = 'Bearer ' + auth;
}
}

await axios.post(url, body, {
headers: {
...(authHeader ? { Authorization: authHeader } : {})
},
timeout: 5000,
validateStatus: (status) => status >= 200 && status <= 299
});
}
public async put(url: string, body: any, auth?: string): Promise<void> {

Check warning on line 45 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (22.x)

Unexpected any. Specify a different type

Check warning on line 45 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (18.x)

Unexpected any. Specify a different type

Check warning on line 45 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (20.x)

Unexpected any. Specify a different type

Check warning on line 45 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (22.x)

Unexpected any. Specify a different type

Check warning on line 45 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (20.x)

Unexpected any. Specify a different type

Check warning on line 45 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (20.x)

Unexpected any. Specify a different type

Check warning on line 45 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (22.x)

Unexpected any. Specify a different type

Check warning on line 45 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (22.x)

Unexpected any. Specify a different type

Check warning on line 45 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (18.x)

Unexpected any. Specify a different type

Check warning on line 45 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (18.x)

Unexpected any. Specify a different type

Check warning on line 45 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (20.x)

Unexpected any. Specify a different type

Check warning on line 45 in lib/swagger-mock-validator/clients/http-client.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (18.x)

Unexpected any. Specify a different type
let authHeader: string | undefined;

if (auth) {
if (auth.includes(':')) {
authHeader = 'Basic ' + Buffer.from(auth).toString('base64');
} else {
authHeader = 'Bearer ' + auth;
}
}

await axios.put(url, body, {
headers: {
...(auth ? {Authorization: authHeader} : {})
},
timeout: 5000,
validateStatus: (status) => status >= 200 && status <= 299
});
Expand Down
19 changes: 19 additions & 0 deletions lib/swagger-mock-validator/clients/pact-broker-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,23 @@ export class PactBrokerClient {
);
}
}

public async post(url: string, body: object): Promise<void> {
try {
await this.httpClient.post(url, body, this.auth);
} catch (error) {
throw new SwaggerMockValidatorErrorImpl(
'SWAGGER_MOCK_VALIDATOR_READ_ERROR', `Unable to post "${url}"`, error
);
}
}
public async put(url: string, body: object): Promise<void> {
try {
await this.httpClient.put(url, body, this.auth);
} catch (error) {
throw new SwaggerMockValidatorErrorImpl(
'SWAGGER_MOCK_VALIDATOR_READ_ERROR', `Unable to put "${url}"`, error
);
}
}
}
1 change: 1 addition & 0 deletions lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
);
};

const parseHeaders = (headers: any | undefined, location: string, parentInteraction: ParsedMockInteraction) => {

Check warning on line 36 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (22.x)

Unexpected any. Specify a different type

Check warning on line 36 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (18.x)

Unexpected any. Specify a different type

Check warning on line 36 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (20.x)

Unexpected any. Specify a different type

Check warning on line 36 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (22.x)

Unexpected any. Specify a different type

Check warning on line 36 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (20.x)

Unexpected any. Specify a different type

Check warning on line 36 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (20.x)

Unexpected any. Specify a different type

Check warning on line 36 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (22.x)

Unexpected any. Specify a different type

Check warning on line 36 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (22.x)

Unexpected any. Specify a different type

Check warning on line 36 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (18.x)

Unexpected any. Specify a different type

Check warning on line 36 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (18.x)

Unexpected any. Specify a different type

Check warning on line 36 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (20.x)

Unexpected any. Specify a different type

Check warning on line 36 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (18.x)

Unexpected any. Specify a different type
for (const key in headers) {
if (typeof headers[key] !== 'string') {
headers[key] = headers[key].toString();
Expand Down Expand Up @@ -78,7 +78,7 @@
: parseAsPactV3RequestQuery(requestQuery);
};

const parseAsPactV4Body = (body: any) => {

Check warning on line 81 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (22.x)

Unexpected any. Specify a different type

Check warning on line 81 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (18.x)

Unexpected any. Specify a different type

Check warning on line 81 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (20.x)

Unexpected any. Specify a different type

Check warning on line 81 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (22.x)

Unexpected any. Specify a different type

Check warning on line 81 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (20.x)

Unexpected any. Specify a different type

Check warning on line 81 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (20.x)

Unexpected any. Specify a different type

Check warning on line 81 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (22.x)

Unexpected any. Specify a different type

Check warning on line 81 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (22.x)

Unexpected any. Specify a different type

Check warning on line 81 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (18.x)

Unexpected any. Specify a different type

Check warning on line 81 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (18.x)

Unexpected any. Specify a different type

Check warning on line 81 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (20.x)

Unexpected any. Specify a different type

Check warning on line 81 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (18.x)

Unexpected any. Specify a different type
if (!body) {
return undefined;
}
Expand All @@ -100,7 +100,7 @@
}
};

const passThrough = (x: any) => x;

Check warning on line 103 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (22.x)

Unexpected any. Specify a different type

Check warning on line 103 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (18.x)

Unexpected any. Specify a different type

Check warning on line 103 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (20.x)

Unexpected any. Specify a different type

Check warning on line 103 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (22.x)

Unexpected any. Specify a different type

Check warning on line 103 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (20.x)

Unexpected any. Specify a different type

Check warning on line 103 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (20.x)

Unexpected any. Specify a different type

Check warning on line 103 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (22.x)

Unexpected any. Specify a different type

Check warning on line 103 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (22.x)

Unexpected any. Specify a different type

Check warning on line 103 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (18.x)

Unexpected any. Specify a different type

Check warning on line 103 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (18.x)

Unexpected any. Specify a different type

Check warning on line 103 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (20.x)

Unexpected any. Specify a different type

Check warning on line 103 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (18.x)

Unexpected any. Specify a different type

const parseInteractionFor = (mockPathOrUrl: string, version: number) => {
const parseBody = version >= 4 ? parseAsPactV4Body : passThrough;
Expand All @@ -114,7 +114,7 @@
value: interaction,
} as ParsedMockInteraction;

const getBodyPath = (bodyValue: any, bodyLocation: string, path: string) => {

Check warning on line 117 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (22.x)

Unexpected any. Specify a different type

Check warning on line 117 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (18.x)

Unexpected any. Specify a different type

Check warning on line 117 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (20.x)

Unexpected any. Specify a different type

Check warning on line 117 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (22.x)

Unexpected any. Specify a different type

Check warning on line 117 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (20.x)

Unexpected any. Specify a different type

Check warning on line 117 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (20.x)

Unexpected any. Specify a different type

Check warning on line 117 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (22.x)

Unexpected any. Specify a different type

Check warning on line 117 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (22.x)

Unexpected any. Specify a different type

Check warning on line 117 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (18.x)

Unexpected any. Specify a different type

Check warning on line 117 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (18.x)

Unexpected any. Specify a different type

Check warning on line 117 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu (20.x)

Unexpected any. Specify a different type

Check warning on line 117 in lib/swagger-mock-validator/mock-parser/pact/pact-parser.ts

View workflow job for this annotation

GitHub Actions / build-and-test-osx (18.x)

Unexpected any. Specify a different type
let location = bodyLocation;
let value = bodyValue;

Expand Down Expand Up @@ -214,6 +214,7 @@
interactions: pactJson.interactions.filter(filterUnsupportedTypes).map(parseInteraction),
pathOrUrl: mockPathOrUrl,
provider: pactJson.provider.name,
verificationUrl: pactJson._links?.['pb:publish-verification-results']?.href
};
},
};
5 changes: 5 additions & 0 deletions lib/swagger-mock-validator/mock-parser/pact/pact.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export interface Pact {
metadata?: PactMetadata;
metaData?: PactMetadata;
provider: { name: string };
_links?: {
'pb:publish-verification-results'?: {
href: string;
}
};
}

export interface PactInteraction {
Expand Down
3 changes: 3 additions & 0 deletions lib/swagger-mock-validator/mock-parser/parsed-mock.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ export interface ParsedMock {
interactions: ParsedMockInteraction[];
pathOrUrl: string;
provider: string;
verificationUrl?: string;
verificationBranchVersionUrl?: string;
verificationTagVersionUrl?: string;
}

export interface ParsedMockInteraction extends ParsedMockValue<any> {
Expand Down
Loading
Loading