GeneratePRInfoSchema generates a JSON schema for the PR/MR info data.
(version string)
| 34 | |
| 35 | // GeneratePRInfoSchema generates a JSON schema for the PR/MR info data. |
| 36 | func (g *Generator) GeneratePRInfoSchema(version string) *jsonschema.Schema { |
| 37 | r := &jsonschema.Reflector{ |
| 38 | DoNotReference: true, |
| 39 | ExpandedStruct: true, |
| 40 | RequiredFromJSONSchemaTags: true, |
| 41 | // Set to false to allow additional properties by default |
| 42 | AllowAdditionalProperties: false, |
| 43 | } |
| 44 | |
| 45 | schema := r.Reflect(&Data{}) |
| 46 | |
| 47 | schema.ID = jsonschema.ID(fmt.Sprintf("https://schemas.chainloop.dev/prinfo/%s/pr-info.schema.json", version)) |
| 48 | schema.Title = "Pull Request / Merge Request Information" |
| 49 | schema.Description = "Schema for Pull Request or Merge Request metadata collected during attestation" |
| 50 | // we want to have a specific version of the schema to avoid compatibility issues |
| 51 | schema.Version = "http://json-schema.org/draft-07/schema#" |
| 52 | |
| 53 | return schema |
| 54 | } |
| 55 | |
| 56 | // Save writes the schema to a file |
| 57 | func (g *Generator) Save(schema *jsonschema.Schema, outputDir, version string) error { |