Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/apitypes/rest/rest.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export const getOperationBasePath = (servers?: OpenAPIV3.ServerObject[]): string
try {
const [firstServer] = servers
let serverUrl = firstServer.url
if(!serverUrl) {
return ''
}

const { variables = {} } = firstServer

for (const param of Object.keys(variables)) {
Expand Down
14 changes: 14 additions & 0 deletions test/bugs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,18 @@ describe('Operation Bugs', () => {

expect(editor.builder.operationList.every(operation => operation.apiKind === API_KIND.NO_BWC)).toBeTruthy()
})

test('should correctly calculate operationId for servers with incorrect URL', async () => {
const editor = await Editor.openProject('bugs', bugsPackage)

const result = await editor.run({
version: 'v1',
files: [
{ fileId: 'should-correctly-calculate-operation-id-for-servers-with-incorrect-url.yaml', publish: true },
],
})

const operationKeys = Array.from(result.operations.keys())
expect(operationKeys[0]).toEqual('paths1-get')
})
})
12 changes: 6 additions & 6 deletions test/projects/bugs/docs/Markdown_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Supports OpenAPI and GraphQL specifications processing.
- Added cycles support during combiners resolve
- Added origins support- it is now possible for any value in the unified JSO to track its origins in the source specification
- Store original ref for the object if the object was resolved from ref
- Gathered various API unification adapters from different libraries in the stack to a single place
- Gathered various API unification adapters from different libraries in the stack to a single place
- Support data structure hash calculation
- Process different phases sequentially (reference resolving, allOf merge, unification)
- Support synthetic `any` and `nothing` type for OAS
Expand All @@ -26,14 +26,14 @@ Supports OpenAPI and GraphQL specifications processing.
- Correctly merge additionalProperties, patternProperties and properties taking into account common validations
- Correctly merge items and additionalItems taking into account common validations
- Supports custom rules to merge other document types and JsonSchema versions
- Supports input with circular references (javaScript references)
- Supports input with circular references (JavaScript references)
- Supports $refs and circular $refs either (internal references only)
- Correctly merge of $refs with sibling content (optionally)
- Correctly merge of combiners (anyOf, oneOf) with sibling content (optionally)
- Typescript syntax support out of the box
- No dependencies (except json-crawl), can be used in NodeJS or browser
- TypeScript syntax support out of the box
- No dependencies (except json-crawl), can be used in Node.js or browser

## Works perfectly with specifications:
## Works perfectly with specifications

- [JsonSchema](https://json-schema.org/draft/2020-12/json-schema-core.html)
- [OpenApi 3.x](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md)
Expand All @@ -43,7 +43,7 @@ Supports OpenAPI and GraphQL specifications processing.
- ~~AsyncApi 3.x~~ (roadmap)

## Other libraries
There are some libraries that can merge schemas combined with allOf. One of the most popular is [mokkabonna/json-schema-merge-allof](https://www.npmjs.com/package/json-schema-merge-allof), but it has some limitatons: Does not support circular $refs and no Typescript syntax out of the box.
There are some libraries that can merge schemas combined with allOf. One of the most popular is [mokkabonna/json-schema-merge-allof](https://npmjs.com/package/json-schema-merge-allof), but it has some limitatons: Does not support circular $refs and no TypeScript syntax out of the box.

## License

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
openapi: 3.0.3
info:
title: test
version: 1.0.0
servers:
- url: []
paths:
/paths1:
get:
description: test
responses:
'200':
description: Success
content:
application/json:
schema:
type: object
Loading