updated specs

This commit is contained in:
Mihaela Mihaljevic 2025-10-15 16:52:10 +02:00
parent fb1f9a4d07
commit ef46f2183c
6 changed files with 39 additions and 4 deletions

View File

@ -303,10 +303,27 @@ Links to external documentation.
```yaml
# __externalDocs.yaml
externalDocs:
# docs.yaml
description: DummyJSON Documentation
url: https://dummyjson.com/docs
```
The `externalDocs` field provides links to additional documentation outside the API spec. It can be used at:
- **Global level** (as shown above) - links to overall API documentation
- **Operation level** - links to specific endpoint guides
Tools like Swagger UI render these links prominently for easy access to tutorials, guides, and examples.
**Try it:**
```bash
# View the external documentation
curl https://dummyjson.com/docs
# Or open in browser
open https://dummyjson.com/docs
```
## Usage
```swift

View File

@ -33,7 +33,14 @@ public struct YAMLMerger {
}
private func cleanedContent(_ text: String) -> String {
let regex = try! NSRegularExpression(pattern: "(\\n\\s*){2,}", options: [])
let pattern = "(\\n\\s*){2,}"
let regex: NSRegularExpression
do {
regex = try NSRegularExpression(pattern: pattern, options: [])
} catch {
// If the regex pattern fails to compile, return the original text unchanged.
return text
}
let range = NSRange(location: 0, length: text.utf16.count)
return regex.stringByReplacingMatches(in: text, options: [], range: range, withTemplate: "\n\n")
}
@ -53,7 +60,7 @@ public struct YAMLMerger {
if !isFirstFile {
output += "\n" // only between files
}
output += content
output += cleanedContent(content)
isFirstFile = false
}
}

View File

@ -482,8 +482,8 @@ webhooks:
description: Webhook received successfully
'400':
description: Bad request
schemas:
components:
schemas:
AuthResponse:

View File

@ -0,0 +1,9 @@
title: OpenAPI Generation Demo
version: 1.0.0
description: Demonstration of OpenAPI specification generation using YAMLMerger
contact:
name: API Support
email: support@example.com
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html

View File

@ -0,0 +1,2 @@
description: DummyJSON Documentation
url: https://dummyjson.com/docs