Skip to content

Commit

Permalink
Remove docs from inlined request in migration (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachkirsch authored Dec 13, 2022
1 parent ccd1911 commit a3e4b96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ exports[`add-inline-requests simple 1`] = `
body:
properties:
foo: string
docs: i'm a request
types:
StringAlias: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ function convertEndpoint({ document, endpoint }: { document: YAML.Document.Parse
const objectExtends = maybeTypeDeclarationForRequest.get("extends");
const objectProperties = maybeTypeDeclarationForRequest.get("properties");
if (objectExtends != null || objectProperties != null) {
newRequest.set("name", requestBodyType);

// it's an object, so move to be the request body
newBody = maybeTypeDeclarationForRequest;
// prefer request docs to type declaration's docs
newBody.set("docs", originalRequestDocs ?? maybeTypeDeclarationForRequest.get("docs"));
// inline requests can't have docs
newBody.delete("docs");

// set request wrapper name to be the old name
newRequest.set("name", requestBodyType);

// remove the old request body type
documentTypes.delete(requestBodyType);
}
}
Expand Down

0 comments on commit a3e4b96

Please sign in to comment.