swagger-api / swagger-api/swagger-ui
Improve rendering `oneOf: [string, string]`
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Content & configuration
Swagger/OpenAPI definition:
swagger: "2.0"
host: localhost
basePath: /v1
tags:
- name: subnets
paths:
/subnets:
post:
tags:
- subnets
summary: Create a subnet
parameters:
- in: body
name: body
required: true
schema:
$ref: '#/definitions/Subnet'
definitions:
CIDRv4:
type: string
description: An IPv4 address range in CIDR notation.
pattern: '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(3[0-2]|[1-2][0-9]|[0-9]))$'
example: 10.9.8.0/24
CIDRv6:
type: string
description: An IPv6 address range in CIDR notation.
pattern: '^(?:(?:(?:[a-f0-9]{1,4}:){6}|(?=(?:[a-f0-9]{0,4}:){0,6}(?:[0-9]{1,3}\.){3}[0-9]{1,3}(?![:.\w]))(([0-9a-f]{1,4}:){0,5}|:)((:[0-9a-f]{1,4}){1,5}:|:)|::(?:[a-f0-9]{1,4}:){5})(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}|(?=(?:[a-f0-9]{0,4}:){0,7}[a-f0-9]{0,4}(?![:.\w]))(([0-9a-f]{1,4}:){1,7}|:)((:[0-9a-f]{1,4}){1,7}|:)|(?:[a-f0-9]{1,4}:){7}:|:(:[a-f0-9]{1,4}){7})(?![:.\w])\/(?:12[0-8]|1[01][0-9]|[1-9]?[0-9])$'
example: 2001:DB8:8700:2010::/64
SubnetCIDR:
type: string
oneOf:
- $ref: '#/definitions/CIDRv4'
- $ref: '#/definitions/CIDRv6'
Subnet:
type: object
required:
- cidr
properties:
cidr:
$ref: '#/definitions/SubnetCIDR'
Swagger-UI configuration options:
window.ui = SwaggerUIBundle({
url: "subnet.yaml",
dom_id: '#swagger-ui',
defaultModelRendering: 'model',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
});
Is your feature request related to a problem?
Displays as follows:
Describe the solution you'd like
Display something more like this:
Describe alternatives you've considered
Additional context
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the supplied subnet.yaml definition and SwaggerUIBundle configuration. Trace the model rendering for SubnetCIDR's oneOf references and compare it with the requested compact display; done when the two string alternatives render in the shown form without losing their descriptions or patterns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100