parser

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CodegenHeader = "// Code generated by jamf-cli generator. DO NOT EDIT."

CodegenHeader is the marker line at the top of every modern API generated file. Must match the first line of resourceTemplate and registryTemplate.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator generates Go code from parsed resources

func NewGenerator

func NewGenerator(outputDir string) *Generator

NewGenerator creates a new code generator

func (*Generator) Generate

func (g *Generator) Generate(resource *Resource) (string, error)

Generate generates a Go command file for a resource

func (*Generator) GenerateRegistry

func (g *Generator) GenerateRegistry(resources []*Resource) (string, error)

GenerateRegistry generates the registry file that registers all commands

type Operation

type Operation struct {
	Name          string // e.g., "list", "get", "create"
	Method        string // HTTP method
	Path          string // API path
	Summary       string
	Description   string
	Parameters    []*Parameter
	RequestBody   *RequestBody
	Responses     map[string]*Response
	IsAction      bool     // x-action: true
	IsDestructive bool     // Requires confirmation (delete, erase, etc.)
	IsList        bool     // List operation with pagination support
	APIVersion    string   // v1, v2, preview, etc.
	Privileges    []string // x-required-privileges
}

Operation represents an API operation (endpoint)

type Parameter

type Parameter struct {
	Name        string
	In          string // "query", "path"
	Description string
	Required    bool
	Type        string
	Default     any
	IsArray     bool
}

Parameter represents a query/path parameter

type Property

type Property struct {
	Name        string
	Type        string
	Description string
	Example     any
	Nullable    bool
	ReadOnly    bool
}

Property represents a schema property

type RequestBody

type RequestBody struct {
	Description string
	Required    bool
	Schema      *Schema
}

RequestBody represents a request body

type Resource

type Resource struct {
	Name         string // e.g., "buildings"
	NameSingular string // e.g., "building"
	GoName       string // e.g., "Buildings"
	Description  string
	Operations   []*Operation
	Schemas      map[string]*Schema
	NameField    string // Filter field for name lookups (default "name", some use "displayName")
}

Resource represents a parsed API resource (e.g., buildings, computers)

func ParseSpec

func ParseSpec(specPath string) (*Resource, error)

ParseSpec parses an OpenAPI spec file and returns a Resource

type Response

type Response struct {
	StatusCode  string
	Description string
	Schema      *Schema
}

Response represents an API response

type Schema

type Schema struct {
	Name       string
	Type       string
	Properties map[string]*Property
	Required   []string
}

Schema represents a JSON schema

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL