Skip to content

Commit

Permalink
add targeted sample spec to demonstrate duplicated equivalent refs
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreatma committed Aug 8, 2024
1 parent 0ab2e8a commit 32dd655
Show file tree
Hide file tree
Showing 215 changed files with 5,026 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,21 @@ public void testRelativePath2() {
Assert.assertEquals(readResult.getOpenAPI().getPaths().get("/pet/findByTags").getGet().getResponses().get("default").getContent().get("application/json").getSchema().get$ref(), "#/components/schemas/ErrorModel");
}

@Test
public void testExternalRefsNormalization() throws Exception {
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult result = new OpenAPIV3Parser()
.readLocation("src/test/resources/oas3.fetched/openapi3.yaml", null, options);

OpenAPI openAPI = result.getOpenAPI();
Schema originalModel = openAPI.getComponents().getSchemas().get("Event");
Schema duplicateModel = openAPI.getComponents().getSchemas().get("Event_1");
System.out.println("component schemas found: " + openAPI.getComponents().getSchemas().keySet());
assertNull(duplicateModel);
assertNotNull(originalModel);
}

private OpenAPI doRelativeFileTest(String location) {
OpenAPIV3Parser parser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
Expand Down Expand Up @@ -3298,4 +3313,4 @@ public void testIssue2081() {
assertEquals(openAPI.getComponents().getSchemas().get("PetCreate").getRequired().size(), 1);
assertEquals(openAPI.getComponents().getSchemas().get("PetCreate").getProperties().size(), 2);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
properties:
address:
type: string
address2:
type: string
city:
type: string
coordinates:
$ref: './Coordinates.yaml'
country:
type: string
state:
type: string
zip_code:
type: string
required:
- address
- zip_code
- country
type: object
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
properties:
namespace:
readOnly: true
type: string
description: Attribute namespace
created_at:
readOnly: true
type: string
format: date-time
description: Datetime when the block was created.
updated_at:
readOnly: true
type: string
format: date-time
description: Datetime when the block was updated.
data:
$ref: "./AttributeData.yaml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
properties:
latest:
readOnly: true
type: boolean
description: Boolean flag to know if the firmware set is the latest for the model and vendor
model:
readOnly: true
type: string
description: Model on which this firmware set can be applied
vendor:
readOnly: true
type: string
description: Vendor on which this firmware set can be applied
plan:
readOnly: true
type: string
description: Plan where the firmware set can be applied
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
properties:
created_at:
format: date-time
type: string
description:
description: Available only for API keys
type: string
id:
format: uuid
type: string
project:
allOf:
- $ref: './Project.yaml'
- description: Available only for project tokens
read_only:
type: boolean
token:
type: string
updated_at:
format: date-time
type: string
user:
allOf:
- $ref: './User.yaml'
- description: Available only for user tokens
type: object
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
properties:
description:
type: string
read_only:
type: boolean
type: object
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
properties:
api_keys:
items:
$ref: './AuthToken.yaml'
type: array
type: object
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
properties:
address_family:
description: Address family for BGP session.
enum:
- ipv4
- ipv6
example: ipv4
type: string
default_route:
default: false
description: Set the default route policy.
type: boolean
type: object
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
properties:
created_at:
format: date-time
type: string
devices:
items:
$ref: './Href.yaml'
type: array
error_messages:
items:
type: string
type: array
id:
format: uuid
type: string
project:
$ref: './Href.yaml'
quantity:
type: integer
state:
type: string
updated_at:
format: date-time
type: string
type: object
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
properties:
batches:
items:
$ref: './Batch.yaml'
type: array
type: object
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
properties:
asn:
description: Autonomous System Number. ASN is required with Global BGP. With Local
BGP the private ASN, 65000, is assigned.
example: 65000
format: int32
type: integer
created_at:
format: date-time
type: string
deployment_type:
description: |
In a Local BGP deployment, a customer uses an internal ASN to control routes within a single Equinix Metal datacenter. This means that the routes are never advertised to the global Internet. Global BGP, on the other hand, requires a customer to have a registered ASN and IP space.
enum:
- global
- local
example: local
type: string
href:
type: string
id:
format: uuid
type: string
max_prefix:
default: 10
description: The maximum number of route filters allowed per server
type: integer
md5:
description: (Optional) Password for BGP session in plaintext (not a checksum)
nullable: true
type: string
project:
$ref: './Href.yaml'
ranges:
description: The IP block ranges associated to the ASN (Populated in Global BGP
only)
items:
$ref: './GlobalBgpRange.yaml'
type: array
requested_at:
format: date-time
type: string
route_object:
description: Specifies AS-MACRO (aka AS-SET) to use when building client route
filters
type: string
sessions:
description: The direct connections between neighboring routers that want to exchange
routing information.
items:
$ref: './BgpSession.yaml'
type: array
status:
description: Status of the BGP Config. Status "requested" is valid only with the
"global" deployment_type.
enum:
- requested
- enabled
- disabled
type: string
type: object
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
properties:
asn:
type: integer
minimum: 0
maximum: 4294967295
description: Autonomous System Number for local BGP deployment.
example: 65000
deployment_type:
description: Wether the BGP deployment is local or global. Local deployments are configured immediately. Global deployments will need to be reviewed by Equinix Metal engineers.
type: string
example: local
enum:
- local
- global
md5:
type: string
description: |
The plaintext password to share between BGP neighbors as an MD5 checksum:
* must be 10-20 characters long
* may not include punctuation
* must be a combination of numbers and letters
* must contain at least one lowercase, uppercase, and digit character
pattern: '^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{10,20}$'
use_case:
description: A use case explanation (necessary for global BGP request review).
type: string
required:
- deployment_type
- asn
type: object
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
properties:
id:
description: The unique identifier for the resource
format: uuid
readOnly: true
type: string
example: aea82f16-57ec-412c-9523-b7f2b27635b2
bgp_neighbor_asn:
description: The ASN of the dynamic BGP neighbor
type: integer
example: 12345
bgp_neighbor_range:
description: Network range of the dynamic BGP neighbor in CIDR format
type: string
example: 192.168.1.0/25
metal_gateway:
$ref: './VrfMetalGateway.yaml'
state:
readOnly: true
type: string
enum:
- active
- deleting
- pending
- ready
href:
type: string
readOnly: true
example: /bgp-dynamic-neighbors/aea82f16-57ec-412c-9523-b7f2b27635b2
created_at:
format: date-time
readOnly: true
type: string
created_by:
$ref: './UserLimited.yaml'
updated_at:
format: date-time
readOnly: true
type: string
tags:
items:
type: string
type: array
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
properties:
bgp_neighbor_range:
description: Network range of the dynamic BGP neighbor in CIDR format
type: string
example: 192.168.1.0/25
bgp_neighbor_asn:
description: The ASN of the dynamic BGP neighbor
type: integer
example: 12345
tags:
items:
type: string
type: array
required:
- bgp_neighbor_range
- bgp_neighbor_asn
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
properties:
bgp_dynamic_neighbors:
items:
$ref: './BgpDynamicNeighbor.yaml'
type: array
meta:
$ref: './Meta.yaml'
type: object
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
properties:
address_family:
description: Address Family for IP Address. Accepted values are 4 or 6
example: 4
format: int32
type: integer
customer_as:
description: The customer's ASN. In a local BGP deployment, this will be an internal
ASN used to route within the data center. For a global BGP deployment, this
will be the your own ASN, configured when you set up BGP for your project.
example: 65000
format: int32
type: integer
customer_ip:
description: The device's IP address. For an IPv4 BGP session, this is typically
the private bond0 address for the device.
example: 10.32.16.1 (IPv4) or 2604:1380:4111:2700::1 (IPv6)
type: string
md5_enabled:
description: True if an MD5 password is configured for the project.
type: boolean
md5_password:
description: The MD5 password configured for the project, if set.
type: string
multihop:
description: True when the BGP session should be configured as multihop.
type: boolean
peer_as:
description: The Peer ASN to use when configuring BGP on your device.
example: 65530
format: int32
type: integer
peer_ips:
description: A list of one or more IP addresses to use for the Peer IP section
of your BGP configuration. For non-multihop sessions, this will typically be
a single gateway address for the device. For multihop sessions, it will be a
list of IPs.
example:
- 169.254.255.1
- 169.254.255.2
items:
type: string
type: array
routes_in:
description: A list of project subnets
example:
- exact: true
route: 10.32.16.0/31
items:
$ref: "./BgpRoute.yaml"
type: array
routes_out:
description: A list of outgoing routes. Only populated if the BGP session has
default route enabled.
example:
- exact: true
route: 0.0.0.0/0
items:
$ref: "./BgpRoute.yaml"
type: array
type: object
Loading

0 comments on commit 32dd655

Please sign in to comment.