Skip to content

Commit

Permalink
Don't emit parameters at all if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
akheron committed Jan 10, 2021
1 parent 2a8e3f7 commit 683f370
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const getRouteDeclaration = (
pathTemplate,
{
[method]: {
parameters: parameters.length > 0 ? parameters : undefined,
...(parameters.length > 0 ? { parameters } : undefined),
...operationRequestBody(requestBody),
responses,
},
Expand Down Expand Up @@ -395,7 +395,7 @@ const typeToSchema = (
type: ts.Type,
optional = false
): OpenAPIV3.SchemaObject | undefined => {
let nullable: { nullable?: true } = {}
let nullable: { nullable: true } | undefined

if (type.isUnion()) {
let elems = type.types
Expand Down
8 changes: 0 additions & 8 deletions tests/__snapshots__/generate.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Array [
"paths": Object {
"/branded-request-body": Object {
"post": Object {
"parameters": undefined,
"requestBody": Object {
"content": Object {
"application/json": Object {
Expand Down Expand Up @@ -51,7 +50,6 @@ Array [
},
"/constant": Object {
"get": Object {
"parameters": undefined,
"responses": Object {
"200": Object {
"content": Object {
Expand All @@ -68,7 +66,6 @@ Array [
},
"/direct-route-call": Object {
"get": Object {
"parameters": undefined,
"responses": Object {
"200": Object {
"content": Object {
Expand All @@ -85,7 +82,6 @@ Array [
},
"/interface-response": Object {
"get": Object {
"parameters": undefined,
"responses": Object {
"200": Object {
"content": Object {
Expand Down Expand Up @@ -115,7 +111,6 @@ Array [
},
"/no-explicit-route-type": Object {
"get": Object {
"parameters": undefined,
"responses": Object {
"200": Object {
"content": Object {
Expand Down Expand Up @@ -170,7 +165,6 @@ Array [
},
"/request-body": Object {
"post": Object {
"parameters": undefined,
"requestBody": Object {
"content": Object {
"application/json": Object {
Expand Down Expand Up @@ -272,7 +266,6 @@ Array [
},
"/response-headers": Object {
"get": Object {
"parameters": undefined,
"responses": Object {
"200": Object {
"content": Object {
Expand All @@ -297,7 +290,6 @@ Array [
},
"/unused-request": Object {
"get": Object {
"parameters": undefined,
"responses": Object {
"200": Object {
"content": Object {
Expand Down

0 comments on commit 683f370

Please sign in to comment.