|
| 1 | +package main |
| 2 | + |
| 3 | +// GenerateInput is what the host passes to the exported `generate` function. |
| 4 | +type GenerateInput struct { |
| 5 | + SourceURL string `json:"source_url,omitempty"` // http://localhost/swagger.json |
| 6 | + SourcePath string `json:"source_path,omitempty"` // local file path |
| 7 | + OutputDir string `json:"output_dir"` // where to write generated test files |
| 8 | + Format string `json:"format,omitempty"` // full, compact, oneliner |
| 9 | +} |
| 10 | + |
| 11 | +// GenerateOutput is what `generate` returns. |
| 12 | +type GenerateOutput struct { |
| 13 | + FilesCreated []string `json:"files_created"` |
| 14 | + TestsCount int `json:"tests_count"` |
| 15 | + Warnings []string `json:"warnings,omitempty"` |
| 16 | + Error string `json:"error,omitempty"` |
| 17 | +} |
| 18 | + |
| 19 | +// generate reads an OpenAPI spec and produces qube test files. |
| 20 | +// This is the main function of the generator plugin. |
| 21 | +func generate(in *GenerateInput) *GenerateOutput { |
| 22 | + // TODO: implementation |
| 23 | + // |
| 24 | + // 1. Fetch spec: |
| 25 | + // - From URL via host_http_request |
| 26 | + // - Or from file via host_read_file |
| 27 | + // 2. Parse OpenAPI JSON/YAML (use kin-openapi compatible structure) |
| 28 | + // 3. Walk paths, group by tag (or by resource prefix) |
| 29 | + // 4. Detect CRUD patterns per resource: |
| 30 | + // POST /users → creates, extract id from response |
| 31 | + // GET /users/{id} → uses saved id |
| 32 | + // PUT /users/{id} → uses saved id, body from schema |
| 33 | + // DELETE /users/{id} → uses saved id |
| 34 | + // → emit as a scenario file |
| 35 | + // 5. For standalone endpoints: emit as independent tests |
| 36 | + // 6. For each schema property: use fake.* generator |
| 37 | + // 7. For each response code: emit expect.status assertion |
| 38 | + // 8. Write files to OutputDir |
| 39 | + // 9. Return GenerateOutput with file list and counts |
| 40 | + return &GenerateOutput{Error: "not implemented"} |
| 41 | +} |
0 commit comments