Star

Created With

linkYaml Anchors & Pointers

Yaml itself has powerful features built-in to allow re-use of defined data.

The & defines a named anchor and * references it.

See also: Yaml Anchors Explained

1linkmeta:

2link name: star wars api using yaml anchors

3linkconfiguration:

4link scheme: http

5link host: swapi.dev

6linkspecs:

7link - name: fetch person 1

8link request: &starwars_person_request

9link path: /api/people/{personId}/

10link method: get

11link response: &starwars_person_response

12link status_code: 200

13link json_schema:

14link type: inline

15link $ref: >

16link {

17link "type": "object",

18link "properties": {

19link "films": {

20link "type": "array",

21link "items": {

22link "type": "string"

23link }

24link }

25link },

26link "required": ["films"]

27link }

28link before_test:

29link run_type: inline

30link inline:

31link function: !!js/function >

32link function() {

33link this.test.path_params = { personId: 1};

34link }

35link after_test: &log_body

36link run_type: inline

37link inline:

38link function: !!js/function >

39link function() {

40link console.log(this.response.body);

41link }

42link

43link - name: fetch person 2

44link request: *starwars_person_request

45link response: *starwars_person_response

46link before_test:

47link run_type: inline

48link inline:

49link function: !!js/function >

50link function() {

51link this.test.path_params = { personId: 2};

52link }

53link after_test: *log_body

54link

Yaml Anchors & Pointers

Home

Getting Startedchevron_right
Basicschevron_right
Requestchevron_right

Request Basics Headers Cookies Query Parameters Path Parameters

Payload Bodychevron_right

File Uploads Auto-Retry Additional Options

Response Validationchevron_right

Overview

Assertionschevron_right

Status Code Headers & Cookies

Bodychevron_right
Hooks & JSchevron_right

Overview

Function Typeschevron_right
Suite-Level Hookschevron_right
Spec-Level Hookschevron_right
Contextchevron_right
DRY & Reusing Specschevron_right
Command Line Interface (CLI)chevron_right