Skip to content

Commit a427788

Browse files
Refactor: Organize project structure and fix build issues
1 parent af0f21b commit a427788

File tree

16 files changed

+666
-1512
lines changed

16 files changed

+666
-1512
lines changed

Package.swift

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,54 @@ let package = Package(
1717
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.0"),
1818
],
1919
targets: [
20+
// Core functionality
2021
.target(
2122
name: "Core",
2223
dependencies: [
2324
.product(name: "OpenAPIKit", package: "OpenAPIKit"),
2425
.product(name: "SymbolKit", package: "swift-docc-symbolkit")
2526
],
26-
path: "Sources/Core"
27+
path: "Sources/Core",
28+
exclude: ["README.md"]
2729
),
30+
31+
// CLI executable
2832
.executableTarget(
2933
name: "CLI",
3034
dependencies: [
3135
"Core",
36+
"OpenAPItoSymbolGraph",
3237
.product(name: "ArgumentParser", package: "swift-argument-parser"),
3338
.product(name: "Yams", package: "Yams"),
3439
.product(name: "OpenAPIKit", package: "OpenAPIKit"),
3540
.product(name: "SymbolKit", package: "swift-docc-symbolkit")
3641
],
37-
path: "Sources/CLI"
42+
path: "Sources/CLI",
43+
exclude: ["README.md"]
3844
),
45+
46+
// OpenAPItoSymbolGraph main framework
47+
.target(
48+
name: "OpenAPItoSymbolGraph",
49+
dependencies: [
50+
"Core",
51+
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
52+
.product(name: "OpenAPIKit", package: "OpenAPIKit"),
53+
.product(name: "Yams", package: "Yams")
54+
],
55+
path: "Sources/OpenAPItoSymbolGraph",
56+
exclude: [
57+
"README.md",
58+
"Utils/README.md",
59+
"Utils/DocC/README.md",
60+
"Mapping/README.md"
61+
]
62+
),
63+
64+
// Tests
3965
.testTarget(
4066
name: "OpenAPItoSymbolGraphTests",
41-
dependencies: ["Core", "CLI"],
67+
dependencies: ["Core", "CLI", "OpenAPItoSymbolGraph"],
4268
path: "Tests"
4369
)
4470
]

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ OpenAPI is the industry standard for documenting HTTP services, but Swift develo
1313
- Provide a consistent documentation experience for Swift developers
1414
- Support for documenting endpoints, schemas, parameters, and more
1515

16+
## Project Structure
17+
18+
The project is organized into several modules:
19+
20+
- `Sources/Core` - Core functionality and data models
21+
- `Sources/CLI` - Command-line interface
22+
- `Sources/OpenAPItoSymbolGraph` - Main implementation with submodules:
23+
- `Mapping` - Mappers between OpenAPI and SymbolGraph
24+
- `Utils/DocC` - DocC integration utilities
25+
1626
## Getting Started
1727

1828
### Prerequisites
@@ -34,7 +44,20 @@ swift build
3444
1. Convert your OpenAPI specification to a SymbolGraph:
3545

3646
```bash
37-
swift run openapi-to-symbolgraph path/to/your/api.yaml --output-path api.symbolgraph.json
47+
# Example using one of the provided files
48+
swift run openapi-to-symbolgraph Examples/api.yaml --output-path api.symbolgraph.json
49+
```
50+
51+
### Example with Pet Store API
52+
53+
The tool has also been tested with the standard Swagger Pet Store OpenAPI definition:
54+
55+
```bash
56+
# Download the Pet Store spec (if you haven't already)
57+
# curl -o Examples/petstore.yaml https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml
58+
59+
# Convert the Pet Store spec
60+
swift run openapi-to-symbolgraph Examples/petstore.yaml --output-path petstore.symbolgraph.json
3861
```
3962

4063
2. Create a DocC documentation catalog (see `API.docc` as an example)
@@ -47,6 +70,8 @@ xcrun docc convert YourAPI.docc --fallback-display-name YourAPI --fallback-bundl
4770

4871
## Viewing the Documentation
4972

73+
The `docs/` directory in this repository contains the pre-generated DocC documentation website output for the **Swagger Pet Store API**, which was built using the `petstore.symbolgraph.json` generated by this tool and the `API.docc` catalog.
74+
5075
### Online Documentation
5176

5277
The latest documentation is automatically deployed to GitHub Pages and can be viewed at:
@@ -55,7 +80,7 @@ The latest documentation is automatically deployed to GitHub Pages and can be vi
5580

5681
### Local Documentation Server
5782

58-
You can serve the documentation locally using one of these methods:
83+
You can serve the included Pet Store documentation locally using one of these methods:
5984

6085
#### Using the helper script:
6186

0 commit comments

Comments
 (0)