Skip to content

Commit

Permalink
(fix): fixes trailing slash parsing in openapi-parser, updates tests (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinharvey authored Apr 21, 2024
1 parent e10d2ea commit 50374c9
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 120 deletions.
216 changes: 108 additions & 108 deletions packages/cli/openapi-parser/src/__test__/__snapshots__/belvo.test.ts.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16896,7 +16896,7 @@ exports[`open api parser deel parse open api 1`] = `
"internal": null,
"method": "GET",
"operationId": "getEorClientTimeOffs",
"path": "/time-offs",
"path": "/time-offs/",
"pathParameters": [],
"queryParameters": [],
"request": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`path parsing path parse open api 1`] = `
{
"channel": [],
"description": null,
"endpoints": [
{
"audiences": [],
"authed": false,
"availability": null,
"description": null,
"errorStatusCode": [],
"examples": [
{
"codeSamples": [],
"description": null,
"headers": [],
"name": null,
"pathParameters": [],
"queryParameters": [],
"request": null,
"response": null,
"type": "full",
},
],
"generatedRequestName": "GetExampleWithoutTrailingSlashRequest",
"headers": [],
"internal": null,
"method": "GET",
"operationId": null,
"path": "/example-without-trailing-slash",
"pathParameters": [],
"queryParameters": [],
"request": null,
"requestNameOverride": null,
"response": null,
"sdkName": null,
"server": [],
"summary": "Get Example",
"tags": [],
},
{
"audiences": [],
"authed": false,
"availability": null,
"description": null,
"errorStatusCode": [],
"examples": [
{
"codeSamples": [],
"description": null,
"headers": [],
"name": null,
"pathParameters": [],
"queryParameters": [],
"request": null,
"response": null,
"type": "full",
},
],
"generatedRequestName": "GetExampleWithTrailingSlashRequest",
"headers": [],
"internal": null,
"method": "GET",
"operationId": null,
"path": "/example-with-trailing-slash/",
"pathParameters": [],
"queryParameters": [],
"request": null,
"requestNameOverride": null,
"response": null,
"sdkName": null,
"server": [],
"summary": "Get Example with trailing",
"tags": [],
},
],
"errors": {},
"globalHeaders": [],
"groups": {},
"hasEndpointsMarkedInternal": false,
"nonRequestReferencedSchemas": [],
"schemas": {},
"securitySchemes": {},
"servers": [],
"tags": {
"orderedTagIds": null,
"tagsById": {},
},
"title": "Sample Path Parsing API",
"variables": {},
"webhooks": [],
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -21591,7 +21591,7 @@ e.g.:
"internal": null,
"method": "GET",
"operationId": "getHelloOnRootPath",
"path": "",
"path": "/",
"pathParameters": [],
"queryParameters": [],
"request": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Log.d("TAG", file.toString())
"internal": null,
"method": "POST",
"operationId": "baseUpload",
"path": "/base",
"path": "/base/",
"pathParameters": [],
"queryParameters": [],
"request": {
Expand Down Expand Up @@ -610,7 +610,7 @@ Log.d("TAG", file.toString())
"internal": null,
"method": "POST",
"operationId": "multipartFileUploadStart",
"path": "/multipart/start",
"path": "/multipart/start/",
"pathParameters": [],
"queryParameters": [],
"request": {
Expand Down Expand Up @@ -1725,7 +1725,7 @@ Log.d("TAG", file.toString())
"internal": null,
"method": "POST",
"operationId": "multipartFileUploadComplete",
"path": "/multipart/complete",
"path": "/multipart/complete/",
"pathParameters": [],
"queryParameters": [],
"request": {
Expand Down Expand Up @@ -2663,7 +2663,7 @@ Log.d("TAG", file.toString())
"internal": null,
"method": "POST",
"operationId": "fromURLUpload",
"path": "/from_url",
"path": "/from_url/",
"pathParameters": [],
"queryParameters": [],
"request": {
Expand Down Expand Up @@ -4166,7 +4166,7 @@ Log.d("TAG", status.toString())
"internal": null,
"method": "GET",
"operationId": "fromURLUploadStatus",
"path": "/from_url/status",
"path": "/from_url/status/",
"pathParameters": [],
"queryParameters": [
{
Expand Down Expand Up @@ -4932,7 +4932,7 @@ Log.d("TAG", file.toString())
"internal": null,
"method": "GET",
"operationId": "fileUploadInfo",
"path": "/info",
"path": "/info/",
"pathParameters": [],
"queryParameters": [
{
Expand Down Expand Up @@ -5809,7 +5809,7 @@ Log.d("TAG", group.toString())
"internal": null,
"method": "POST",
"operationId": "createFilesGroup",
"path": "/group",
"path": "/group/",
"pathParameters": [],
"queryParameters": [],
"request": {
Expand Down Expand Up @@ -6731,7 +6731,7 @@ Log.d("TAG", group.toString())
"internal": null,
"method": "GET",
"operationId": "filesGroupInfo",
"path": "/group/info",
"path": "/group/info/",
"pathParameters": [],
"queryParameters": [
{
Expand Down
11 changes: 11 additions & 0 deletions packages/cli/openapi-parser/src/__test__/fixtures/path/openapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
openapi: 3.0.0
info:
title: Sample Path Parsing API
version: 1.0.0
paths:
/example-without-trailing-slash:
get:
summary: Get Example
/example-with-trailing-slash/:
get:
summary: Get Example with trailing
5 changes: 5 additions & 0 deletions packages/cli/openapi-parser/src/__test__/path.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { testParseOpenAPI } from "./testParseOpenApi";

describe("path parsing", () => {
testParseOpenAPI("path", "openapi.yml");
});
3 changes: 1 addition & 2 deletions packages/cli/openapi-parser/src/openapi/v3/generateIr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ export function generateIr({
return;
}
taskContext.logger.debug(`Converting path ${path}`);
const pathWithoutTrailingSlash = path.replace(/\/$/, "");
const convertedOperations = convertPathItem(pathWithoutTrailingSlash, pathItem, openApi, context);
const convertedOperations = convertPathItem(path, pathItem, openApi, context);

for (const operation of convertedOperations) {
switch (operation.type) {
Expand Down

0 comments on commit 50374c9

Please sign in to comment.