Skip to content

Commit

Permalink
feature added special type(color) of x-badge > 'none'
Browse files Browse the repository at this point in the history
  • Loading branch information
mrin9 committed Sep 24, 2024
1 parent 42e5d96 commit d882857
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
39 changes: 36 additions & 3 deletions docs/specs/badges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ info:
summary: ...
description: ...
x-badges: # <<< Extension
- color: red # <<< Allowed values (red, green, orange, blue, primary-color)
- color: red # <<< Allowed values (none, red, green, orange, blue, primary-color)
label: 'Will be Deprecated'
- color: blue
label: 'Popular: false'
- color: none
label: 'Is used for assiging a badge to the operation without showing on the ui'
...
...
```
Expand All @@ -31,15 +33,15 @@ paths:
summary: Endpoint with red and blue badge
x-badges:
- color: red
label: 'Beta'
label: Beta
- color: blue
label: 'Popular: true'
/badge-2-path:
get:
summary: Endpoint with primary-color
x-badges:
- color: primary-color
label: 'CORE API'
label: CORE API
/badge-3-path:
get:
summary: Endpoint with green and orange badge
Expand All @@ -48,6 +50,37 @@ paths:
label: 'Easy: Yes'
- color: orange
label: 'Slow'
/badge-none-1:
get:
summary: Endpoint1 with 'none' badge. (badge wont show)
description: |
This Endpoint has a **badge-label** of `internal-use-only` assigned to it but the badge is not shown in the UI<br/>
`badge` can also be used for removing an Endpoint from the documention
x-badges:
- color: none
label: internal-use-only
/badge-none-2:
get:
summary: Endpoint2 with 'none' badge. (badge wont show)
description: |
This Endpoint has a **badge-label** of `admin-use-only` assigned to it but the badge is not shown in the UI<br/>
`badge` can also be used for removing an Endpoint from the documention
x-badges:
- color: none
label: admin-use-only
/badge-none-3:
get:
summary: Endpoint3 with 'none' badge. (badge wont show)
description: |
This Endpoint has a **badge-label** of `internal-use-only` and `admin-use-only` assigned, but the badge is not shown in the UI<br/>
`badge` can also be used for removing an Endpoint from the documention
x-badges:
- color: none
label: admin-use-only
- color: none
label: internal-use-only

/no-badges-path:
get:
summary: Endpoint with No badges
description: This Endpoint has ano badges
4 changes: 3 additions & 1 deletion src/templates/endpoint-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ function endpointBodyTemplate(path) {
? html`
<div style="display:flex; flex-wrap:wrap;font-size: var(--font-size-small);">
${path.xBadges.map((v) => (
html`<span part="endpoint-badge" style="margin:1px; margin-right:5px; padding:1px 8px; font-weight:bold; border-radius:12px; background-color: var(--light-${v.color}, var(--input-bg)); color:var(--${v.color}); border:1px solid var(--${v.color})">${v.label}</span>`
v.color === 'none'
? ''
: html`<span part="endpoint-badge" style="margin:1px; margin-right:5px; padding:1px 8px; font-weight:bold; border-radius:12px; background-color: var(--light-${v.color}, var(--input-bg)); color:var(--${v.color}); border:1px solid var(--${v.color})">${v.label}</span>`
))
}
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/templates/expanded-endpoint-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export function expandedEndpointBodyTemplate(path, tagName = '', tagDescription
? html`
<div style="display:flex; flex-wrap:wrap; margin-bottom: -24px; font-size: var(--font-size-small);">
${path.xBadges.map((v) => (
html`<span style="margin:1px; margin-right:5px; padding:1px 8px; font-weight:bold; border-radius:12px; background-color: var(--light-${v.color}, var(--input-bg)); color:var(--${v.color}); border:1px solid var(--${v.color})">${v.label}</span>`
v.color === 'none'
? ''
: html`<span style="margin:1px; margin-right:5px; padding:1px 8px; font-weight:bold; border-radius:12px; background-color: var(--light-${v.color}, var(--input-bg)); color:var(--${v.color}); border:1px solid var(--${v.color})">${v.label}</span>`
))
}
</div>
Expand Down

0 comments on commit d882857

Please sign in to comment.