# sashi-u/swagger-spec architecture

> Architecture diagram of the GitHub repository sashi-u/swagger-spec, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sashi-u/swagger-spec
- Repository: https://github.com/sashi-u/swagger-spec

## Overview

##### Project type and purpose
- This is an open-source specification repository for the OpenAPI Specification (OAS). Its “runtime” is purely in document form: Markdown sources of the spec, schema files (JSON/YAML), proposal documents, build and validation scripts, and CI/CD pipelines. There is no user-facing application; the primary function is to produce published, machine-readable API descriptions and human-readable HTML documentation, validate schema conformance, and manage versioned/specification proposals.

##### File structure
- Top-level directories and files:
- versions/: Markdown source of each released spec version
- proposals/: feature‐and‐extension proposals structured by topic
- _archive_/: historical schema files (JSON/YAML) for older spec versions
- scripts/: shell, PowerShell, Node (mjs) scripts for generating HTML, testing schemas, publishing, version management
- tests/: automated tests for the md2html toolchain
- .github/workflows/: CI/CD pipelines (validate markdown, schema tests, publishing, sync branches)
- package.json / package-lock.json: Node dependencies (Vitest, YAML parsers, etc.)
- README.md, CONTRIBUTING.md, IMPLEMENTATIONS.md, style-guide.md, etc.: core project documentation

##### README for additional insights
- The README confirms the repository’s role in hosting Markdown sources of the specification and directing readers to the HTML render site. It mentions use cases (interactive documentation, code generation, test automation) and points at IMPLEMENTATIONS.md for tooling by others.

a. Main components
- GitHub Repository (source of truth)
- Contributors & TSC (people pushing PRs against versions/, proposals/, scripts/)
- CI/CD (GitHub Actions workflows)
- Build/Validation Scripts (scripts/md2html/, schema-publish.sh, schema-test-coverage.mjs, validate.mjs)
- Markdown Sources (versions/*.md, proposals/*)
- Schema Files (_archive_/schemas, schemas generated in-pack)
- Test Runner (Vitest, markdownlint)
- Output Artifacts (HTML docs via md2html, published schemas via schema-publish)
- External Services (Respec for HTML, npm registry, GitHub Pages or spec.openapis.org)

b. Relationships and data flow
1. Contributors push commits to branches →
2. GitHub Actions trigger workflows:
- validate-markdown: runs markdownlint on versions/, proposals/
- schema-tests: runs schema-test-coverage scripts against _archive_/schemas/**
- respec: builds HTML using md2html and Respec templates
- schema-publish: publishes updated schemas to a registry or spec site
- sync-dev-to-vX.Y-dev / sync-main-to-dev: automates branch synchronization
3. Scripts read Markdown sources and schema definitions, run tests, and generate outputs
4. Test runner (Vitest) executes unit tests for md2html and schema coverage
5. Successful builds deploy HTML and schema artifacts to spec.openapis.org or GitHub Pages

c. Architectural patterns and principles
- Static documentation pipeline (input = Markdown + schemas → processing → HTML / JSON outputs)
- CI/CD as the orchestration layer
- Single repository monorepo for spec, proposals, tooling, and tests
- Clear separation between source (versions/, proposals/) and build outputs (deployed docs)
- Extensibility via proposals folder and modular scripts

d. Key technologies and frameworks
- GitHub Actions for CI/CD
- Node.js scripts (ESM .mjs) for md2html conversion and schema coverage
- Bash / PowerShell helpers for release branching and porting (scripts/*.sh, *.ps1)
- Vitest for JavaScript testing
- markdownlint for enforcing style
- Respec (via md2html) to generate HTML from OpenAPI Markdown

##### Detailed, essential elements to capture
- Repository structure: versions/, proposals/, _archive_/, scripts/, tests/, .github/workflows
- CI workflows and their triggers (validate-markdown, schema-tests, respec, schema-publish, sync)
- Script functions: md2html conversion, schema coverage, branch management
- Test suite: markdownlint, Vitest tests under tests/md2html
- Output artifacts and destinations: HTML docs, published JSON/YAML schema files

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Contributors
    subgraph "Contributors & TSC" 
        direction TB
        Contributors["Contributors & TSC"]:::people
    end

    %% Repository
    subgraph "GitHub Repository" 
        direction TB
        Repo["OpenAPI Spec Monorepo"]:::repo
        README["README.md"]:::doc
        CONTRIB["CONTRIBUTING.md"]:::doc
        IMPLEMENT["IMPLEMENTATIONS.md"]:::doc
        STYLE["style-guide.md"]:::doc
        GOVERN["GOVERNANCE.md"]:::doc
        SECURITY["SECURITY_CONSIDERATIONS.md"]:::doc
        EDITORS["EDITORS.md"]:::doc
        MAINTAIN["MAINTAINERS.md"]:::doc
        SIG["SPECIAL_INTEREST_GROUPS.md"]:::doc
        TOB["TOB.md"]:::doc
    end

    %% Source Files
    subgraph "Source Files" 
        direction TB
        Versions["versions/"]:::source
        Proposals["proposals/"]:::source
        ArchiveSchemas["_archive_/schemas/"]:::storage
    end

    %% Scripts & Tools
    subgraph "Build & Validation Scripts" 
        direction TB
        MD2HTML["md2html/"]:::script
        SchemaPubSh["schema-publish.sh"]:::script
        SchemaCovMJS["schema-test-coverage.mjs"]:::script
        SchemaCovSH["schema-test-coverage.sh"]:::script
        ValidateMJS["validate.mjs"]:::script
        BranchHelpers["branch-helpers (.sh/.ps1)"]:::script
    end

    %% CI/CD Workflows
    subgraph "CI/CD Workflows" 
        direction TB
        ValidateMD["validate-markdown.yaml"]:::cicd
        SchemaTests["schema-tests.yaml"]:::cicd
        Respec["respec.yaml"]:::cicd
        PubSchemaWF["schema-publish.yaml"]:::cicd
        SyncDev["sync-dev-to-vX.Y-dev.yaml"]:::cicd
        SyncMain["sync-main-to-dev.yaml"]:::cicd
    end

    %% Tests & Linters
    subgraph "Test Runner & Linters" 
        direction TB
        MDTests["tests/md2html/"]:::test
        VitestCfg["vitest.config.mjs"]:::test
        MDLint[".markdownlint.yaml"]:::test
        SpecLint["spec.markdownlint.yaml"]:::test
    end

    %% Package Config
    subgraph "Package Configuration" 
        direction TB
        PackageJSON["package.json"]:::config
        PackageLock["package-lock.json"]:::config
    end

    %% Artifacts
    subgraph "Output Artifacts" 
        direction TB
        HTMLDocs["HTML Documentation"]:::artifact
        JSONSchemas["Published JSON/YAML Schemas"]:::artifact
    end

    %% External Services
    subgraph "External Services" 
        direction TB
        RespecService["Respec Templates"]:::external
        NPMRegistry["npm Registry"]:::external
        GitHubPages["GitHub Pages / spec.openapis.org"]:::external
    end

    %% Connections
    Contributors -->|push PRs| Repo
    Repo -->|triggers| ValidateMD
    Repo -->|triggers| SchemaTests
    Repo -->|triggers| Respec
    Repo -->|triggers| PubSchemaWF
    Repo -->|triggers| SyncDev
    Repo -->|triggers| SyncMain

    ValidateMD -->|reads| Versions
    ValidateMD -->|reads| Proposals
    SchemaTests -->|reads| ArchiveSchemas
    Respec -->|uses| MD2HTML
    Respec -->|reads| Versions
    Respec -->|reads| Proposals
    Respec -->|outputs| HTMLDocs
    PubSchemaWF -->|runs| SchemaPubSh
    PubSchemaWF -->|outputs| JSONSchemas

    MD2HTML -->|convert| HTMLDocs
    SchemaPubSh -->|publish| NPMRegistry
    SchemaPubSh -->|publish| GitHubPages

    MDTests -->|test| MD2HTML
    MDTests -->|fixtures| Versions
    MDTests -->|run on| SchemaCovMJS

    SchemaCovMJS -->|report| SchemaTests
    ValidateMJS -->|validate| ArchiveSchemas

    Repo -->|contains| PackageJSON
    Repo -->|contains| PackageLock
    Repo -->|contains| README
    Repo -->|contains| CONTRIB
    Repo -->|contains| IMPLEMENT
    Repo -->|contains| STYLE
    Repo -->|contains| GOVERN
    Repo -->|contains| SECURITY
    Repo -->|contains| EDITORS
    Repo -->|contains| MAINTAIN
    Repo -->|contains| SIG
    Repo -->|contains| TOB

    PubSchemaWF -->|deploy| GitHubPages

    %% Click Events
    click ValidateMD "https://github.com/sashi-u/swagger-spec/blob/master/.github/workflows/validate-markdown.yaml"
    click SchemaTests "https://github.com/sashi-u/swagger-spec/blob/master/.github/workflows/schema-tests.yaml"
    click Respec "https://github.com/sashi-u/swagger-spec/blob/master/.github/workflows/respec.yaml"
    click PubSchemaWF "https://github.com/sashi-u/swagger-spec/blob/master/.github/workflows/schema-publish.yaml"
    click SyncDev "https://github.com/sashi-u/swagger-spec/blob/master/.github/workflows/sync-dev-to-vX.Y-dev.yaml"
    click SyncMain "https://github.com/sashi-u/swagger-spec/blob/master/.github/workflows/sync-main-to-dev.yaml"

    click MD2HTML "https://github.com/sashi-u/swagger-spec/tree/master/scripts/md2html/"
    click SchemaPubSh "https://github.com/sashi-u/swagger-spec/blob/master/scripts/schema-publish.sh"
    click SchemaCovMJS "https://github.com/sashi-u/swagger-spec/blob/master/scripts/schema-test-coverage.mjs"
    click SchemaCovSH "https://github.com/sashi-u/swagger-spec/blob/master/scripts/schema-test-coverage.sh"
    click ValidateMJS "https://github.com/sashi-u/swagger-spec/blob/master/scripts/validate.mjs"
    click BranchHelpers "https://github.com/sashi-u/swagger-spec/tree/master/scripts/"

    click Versions "https://github.com/sashi-u/swagger-spec/tree/master/versions/"
    click Proposals "https://github.com/sashi-u/swagger-spec/tree/master/proposals/"
    click ArchiveSchemas "https://github.com/sashi-u/swagger-spec/tree/master/_archive_/schemas/"

    click MDTests "https://github.com/sashi-u/swagger-spec/tree/master/tests/md2html/"
    click VitestCfg "https://github.com/sashi-u/swagger-spec/blob/master/vitest.config.mjs"
    click MDLint "https://github.com/sashi-u/swagger-spec/blob/master/.markdownlint.yaml"
    click SpecLint "https://github.com/sashi-u/swagger-spec/blob/master/spec.markdownlint.yaml"

    click PackageJSON "https://github.com/sashi-u/swagger-spec/blob/master/package.json"
    click PackageLock "https://github.com/sashi-u/swagger-spec/blob/master/package-lock.json"

    click README "https://github.com/sashi-u/swagger-spec/blob/master/README.md"
    click CONTRIB "https://github.com/sashi-u/swagger-spec/blob/master/CONTRIBUTING.md"
    click IMPLEMENT "https://github.com/sashi-u/swagger-spec/blob/master/IMPLEMENTATIONS.md"
    click STYLE "https://github.com/sashi-u/swagger-spec/blob/master/style-guide.md"
    click GOVERN "https://github.com/sashi-u/swagger-spec/blob/master/GOVERNANCE.md"
    click SECURITY "https://github.com/sashi-u/swagger-spec/blob/master/SECURITY_CONSIDERATIONS.md"
    click EDITORS "https://github.com/sashi-u/swagger-spec/blob/master/EDITORS.md"
    click MAINTAIN "https://github.com/sashi-u/swagger-spec/blob/master/MAINTAINERS.md"
    click SIG "https://github.com/sashi-u/swagger-spec/blob/master/SPECIAL_INTEREST_GROUPS.md"
    click TOB "https://github.com/sashi-u/swagger-spec/blob/master/TOB.md"

    %% Styles
    classDef people fill:#FFD699,stroke:#E69A00;
    classDef repo fill:#D0E6A5,stroke:#7FAF3C;
    classDef source fill:#A0C4FF,stroke:#4B7BEC;
    classDef storage fill:#BDB2FF,stroke:#6746C3;
    classDef script fill:#FFB2E6,stroke:#E33E8B;
    classDef cicd fill:#FFE066,stroke:#E6B800;
    classDef test fill:#FFADAD,stroke:#D93636;
    classDef config fill:#C0C0C0,stroke:#888888;
    classDef doc fill:#FFECB3,stroke:#E6AC00;
    classDef artifact fill:#B2FF9E,stroke:#36B249;
    classDef external fill:#CCCCFF,stroke:#7777CC;
```
