How to save schema to environment and reuse it after

Hey @alzarka, this looks quite similar to How to save schema to environment and reuse it after. You can reuse schema definitions across requests as follows:

  1. Save pictureSchema into an environment variable as follows:
pm.environment.set('picture_schema', JSON.stringify(schemaPicture));
  1. In the script where commentSchema is defined, refer pictureSchema as follows:
const commentSchema = {
   .
   .
   .
   "picture": JSON.parse(pm.environment.get('picture_schema'))
   .
   .
   .
}

In this manner, you can include the common reference wherever needed.

1 Like