-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: parse & stringify comments (#69)
- Loading branch information
Showing
10 changed files
with
611 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# my openapi document | ||
openapi: 3.0.0 # Specifies the OpenAPI Specification version | ||
info: # Metadata about the API | ||
title: Bookstore Inventory API # The name of your API | ||
description: API for managing a bookstore's inventory. | ||
version: 1.0.0 # API version | ||
servers: # Defines the API server and base URL | ||
- url: 'https://api.bookstore.com/v1' # Base URL for the API endpoints | ||
# Paths section describes the endpoints available in the API | ||
paths: | ||
/books: | ||
get: # Retrieves a list of books from the inventory | ||
summary: List all books | ||
# A more detailed description of the operation | ||
description: Retrieve a list of books available in the bookstore inventory. | ||
responses: # Describes the possible responses | ||
'200': # HTTP status code for a successful response | ||
description: A JSON array of book objects. | ||
content: | ||
application/json: # Media type | ||
schema: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/Book' # References the Book schema | ||
# Endpoint to create a new book entry | ||
post: | ||
summary: Add a new book | ||
description: Add a new book to the bookstore inventory. | ||
requestBody: # Describes the request body | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/NewBook' # Schema for the new book data | ||
responses: | ||
'201': # Status code for a successful creation | ||
description: Book created successfully. | ||
# Components section for reusable schemas | ||
components: | ||
schemas: | ||
# Schema definition for a book | ||
Book: | ||
type: object | ||
properties: | ||
id: | ||
type: string # Unique identifier for the book | ||
description: The book's unique identifier. | ||
title: | ||
type: string # The title of the book | ||
description: The title of the book. | ||
author: | ||
type: string # The author's name | ||
description: The author of the book. | ||
isbn: | ||
type: string # The ISBN number | ||
description: The International Standard Book Number. | ||
# Indicates if the book is currently available | ||
available: | ||
type: boolean | ||
description: Whether the book is currently available for sale. | ||
# Schema for creating a new book entry | ||
NewBook: # Below the schema definition | ||
type: object | ||
properties: | ||
title: | ||
type: string | ||
description: The title of the book. # Inline comment for |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import { load as loadAST } from '@stoplight/yaml-ast-parser'; | ||
import { walkAST } from './parseWithPointers'; | ||
import { YAMLNode } from './types'; | ||
import { parseWithPointers } from './parseWithPointers'; | ||
|
||
export const parse = <T>(value: string): T => walkAST(loadAST(value) as YAMLNode, void 0, [], []) as T; | ||
export const parse = <T>(value: string): T => parseWithPointers(value).data as T; |
Oops, something went wrong.