monolith

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package monolith splits a single consolidated Jamf Pro OpenAPI document (e.g. the one served at /api/schema/) into per-resource spec files that match the layout expected by the rest of the generator pipeline.

Routing strategy: for each path in the monolith, look up the spec filename that currently owns it in specsDir. If found, route the path into that bucket. Otherwise fall back to a filename derived from the operation's first tag (with manual overrides in overrides.go).

Output: a shared library file (_MonolithLibrary.yaml) plus one file per bucket. For each component referenced by the monolith, the splitter counts how many buckets reach it transitively:

  • Exclusive (1 bucket): inlined into that bucket's components block so the parser's resource.Schemas map contains it. Heuristics that scan declared schemas (e.g. detectNameField) see the same field set an upstream per-file spec would expose.
  • Shared (2+ buckets): emitted to the library file; bucket refs to it are rewritten to external `_MonolithLibrary.yaml#/...` form.

This replicates the original per-file + shared-library layout used upstream, where each resource spec declared its own primary schemas locally and imported cross-resource definitions via external $refs.

Index

Constants

View Source
const LibraryFilename = "_MonolithLibrary.yaml"

LibraryFilename is the shared components file emitted by Split. Contains "Library" so the parser's non-resource file skip logic ignores it during resource extraction.

Variables

View Source
var DroppedTags = map[string]bool{

	"mobile-device-extension-attributes-preview": true,

	"devices": true,

	"user-session-preview": true,
}

DroppedTags lists tags whose paths must never be emitted, even if present in the monolith. Used for legacy/preview endpoints that would collide with canonical resources.

View Source
var PreservedSpecs = map[string]bool{

	"AppInstallerDeployments.yaml": true,
	"AppInstallerTitles.yaml":      true,
}

PreservedSpecs lists spec filenames (relative to specs/) that the splitter must not touch. Their paths are also treated as invisible to the splitter: any matching path in the monolith is dropped in favour of the preserved file's hand-maintained definition.

Use this for specs sourced outside the public monolith (e.g. private or preview endpoints that only ship in internal documentation).

View Source
var TagFilenameOverrides = map[string]string{}

TagFilenameOverrides maps an OpenAPI tag to the spec filename that should be produced for it when a matching path is NOT already present in the existing specs/ layout. This only fires for **new** tags/paths that the path-based layout cannot place automatically.

Keyed by tag name (kebab form, as it appears in the monolith spec). Value is the basename (with .yaml extension) that the splitter should write.

Leave empty until an upstream rename or genuinely new tag requires an explicit mapping. Most tags map cleanly to a PascalCase-singular filename derived from the tag itself.

Functions

func Split

func Split(monolithSource, specsDir string) ([]string, []string, error)

Split reads an OpenAPI monolith (JSON or YAML) from monolithSource and writes per-resource spec files into specsDir. monolithSource may be a local file path OR an http(s):// URL; URLs are fetched anonymously. Existing *.yaml files at the root of specsDir are removed; subdirectories (classic/, blueprint-components/) are left untouched. Files listed in PreservedSpecs (and any library files they depend on) are also left in place.

Returns the list of written file paths (sorted) and any routing warnings encountered (e.g. new paths that did not match the existing layout).

Types

This section is empty.

Jump to

Keyboard shortcuts

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