Skip to content

Commit

Permalink
chore(cli): Add write-definition tests for server / environment han…
Browse files Browse the repository at this point in the history
…dling (#6119)

chore(cli): Add `write-definition` tests for server / environment handling.
  • Loading branch information
eyw520 authored Feb 21, 2025
1 parent be07894 commit 7b8eef4
Show file tree
Hide file tree
Showing 54 changed files with 1,377 additions and 6 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
service:
auth: false
base-path: ''
endpoints:
list:
auth: false
examples:
- response:
body: string
method: GET
path: /pets
response:
docs: A response
status-code: 200
type: string
source:
openapi: openapi.yml
source:
openapi: openapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
default-environment: Prod
default-url: Base
display-name: Test API
environments:
Dev:
urls:
Base: http://dev.api.com
websocket: wss://api.async.com
websocket2: wss://api2.async.com
Prod:
urls:
Base: http://prod.api.com
websocket: wss://api.async.com
websocket2: wss://api2.async.com
error-discrimination:
strategy: status-code
name: api
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
types:
TestChannelPublishEvent:
enum: []
source:
openapi: asyncapi.yml
channel:
auth: false
examples:
- messages: []
messages:
publish:
body: TestChannelPublishEvent
origin: client
path: /test
url: websocket
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
types:
TestChannel2PublishEvent:
enum: []
source:
openapi: asyncapi.yml
channel:
auth: false
examples:
- messages: []
messages:
publish:
body: TestChannel2PublishEvent
origin: client
path: /test2
url: websocket2
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
asyncapi: 3.0.0
info:
title: Test AsyncAPI
version: 1.0.0
servers:
websocket:
host: api.async.com
protocol: wss
websocket2:
host: api2.async.com
protocol: wss
channels:
testChannel:
address: '/test'
servers:
- $ref: '#/servers/websocket'
messages:
sendMessage:
$ref: '#/components/messages/sendMessage'
testChannel2:
address: '/test2'
servers:
- $ref: '#/servers/websocket2'
messages:
sendMessage:
$ref: '#/components/messages/sendMessage'
operations:
send:
action: send
channel:
$ref: '#/channels/testChannel'
messages:
- $ref: '#/channels/testChannel/messages/sendMessage'
send2:
action: send
channel:
$ref: '#/channels/testChannel2'
messages:
- $ref: '#/channels/testChannel2/messages/sendMessage'
components:
messages:
sendMessage:
summary: Message with marked data information.
payload:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"organization": "fern",
"version": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
api:
- path: ./openapi.yml
- path: ./asyncapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: Test API
servers:
- url: http://prod.api.com
x-fern-server-name: Prod
- url: http://dev.api.com
x-fern-server-name: Dev
paths:
/pets:
get:
operationId: list
parameters:
- name: limit
schema:
type: integer
responses:
"200":
description: A response
content:
application/json:
schema:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
service:
auth: false
base-path: ''
endpoints:
list:
auth: false
examples:
- response:
body: string
method: GET
path: /pets
response:
docs: A response
status-code: 200
type: string
source:
openapi: openapi.yml
source:
openapi: openapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
default-environment: Prod
display-name: Test API
environments:
Dev: http://dev.api.com
Prod: http://prod.api.com
error-discrimination:
strategy: status-code
name: api
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"organization": "fern",
"version": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
api:
- path: ./openapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: Test API
servers:
- url: http://prod.api.com
x-fern-server-name: Prod
- url: http://dev.api.com
x-fern-server-name: Dev
paths:
/pets:
get:
operationId: list
parameters:
- name: limit
schema:
type: integer
responses:
"200":
description: A response
content:
application/json:
schema:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
service:
auth: false
base-path: ''
endpoints:
list:
auth: false
examples:
- response:
body: string
method: GET
path: /pets
response:
docs: A response
status-code: 200
type: string
source:
openapi: openapi.yml
url: Debug
source:
openapi: openapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
default-environment: Prod
default-url: Base
display-name: Test API
environments:
Dev:
urls:
Base: http://dev.api.com
Debug: http://debug.api.com
websocket: wss://api.async.com
websocket2: wss://api2.async.com
Prod:
urls:
Base: http://prod.api.com
Debug: http://debug.api.com
websocket: wss://api.async.com
websocket2: wss://api2.async.com
error-discrimination:
strategy: status-code
name: api
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
types:
TestChannelPublishEvent:
enum: []
source:
openapi: asyncapi.yml
channel:
auth: false
examples:
- messages: []
messages:
publish:
body: TestChannelPublishEvent
origin: client
path: /test
url: websocket
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
types:
TestChannel2PublishEvent:
enum: []
source:
openapi: asyncapi.yml
channel:
auth: false
examples:
- messages: []
messages:
publish:
body: TestChannel2PublishEvent
origin: client
path: /test2
url: websocket2
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
asyncapi: 3.0.0
info:
title: Test AsyncAPI
version: 1.0.0
servers:
websocket:
host: api.async.com
protocol: wss
websocket2:
host: api2.async.com
protocol: wss
channels:
testChannel:
address: '/test'
servers:
- $ref: '#/servers/websocket'
messages:
sendMessage:
$ref: '#/components/messages/sendMessage'
testChannel2:
address: '/test2'
servers:
- $ref: '#/servers/websocket2'
messages:
sendMessage:
$ref: '#/components/messages/sendMessage'
operations:
send:
action: send
channel:
$ref: '#/channels/testChannel'
messages:
- $ref: '#/channels/testChannel/messages/sendMessage'
send2:
action: send
channel:
$ref: '#/channels/testChannel2'
messages:
- $ref: '#/channels/testChannel2/messages/sendMessage'
components:
messages:
sendMessage:
summary: Message with marked data information.
payload:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"organization": "fern",
"version": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
api:
- path: ./openapi.yml
- path: ./asyncapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: Test API
servers:
- url: http://prod.api.com
x-fern-server-name: Prod
- url: http://dev.api.com
x-fern-server-name: Dev
paths:
/pets:
get:
operationId: list
servers:
- url: http://debug.api.com
x-fern-server-name: Debug
parameters:
- name: limit
schema:
type: integer
responses:
"200":
description: A response
content:
application/json:
schema:
type: string
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
service:
auth: false
base-path: ''
endpoints:
list:
auth: false
examples:
- response:
body: string
method: GET
path: /pets
response:
docs: A response
status-code: 200
type: string
source:
openapi: openapi.yml
url: Debug
source:
openapi: openapi.yml
Loading

0 comments on commit 7b8eef4

Please sign in to comment.