Save writes the schema to a file
(schema *jsonschema.Schema, outputDir, version string)
| 55 | |
| 56 | // Save writes the schema to a file |
| 57 | func (g *Generator) Save(schema *jsonschema.Schema, outputDir, version string) error { |
| 58 | schemaJSON, err := json.MarshalIndent(schema, "", " ") |
| 59 | if err != nil { |
| 60 | return fmt.Errorf("failed to marshal schema to JSON: %w", err) |
| 61 | } |
| 62 | |
| 63 | outputFile := fmt.Sprintf("%s/pr-info-%s.schema.json", outputDir, version) |
| 64 | if err := os.WriteFile(outputFile, schemaJSON, 0600); err != nil { |
| 65 | return fmt.Errorf("failed to write schema to file: %w", err) |
| 66 | } |
| 67 | |
| 68 | return nil |
| 69 | } |