-
Notifications
You must be signed in to change notification settings - Fork 270
[http-client-js] Improve documentation #6940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
All changed packages have been documented.
|
You can try these changes here
|
return ( | ||
<For each={responses.filter((r) => !$.httpResponse.isErrorResponse(r))}> | ||
{({ statusCode, contentType, responseContent, type }) => { | ||
// Extract the body from the response content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this also auto generated by AI? how did it know which lines to add and which not?
export function HttpResponses(props: HttpResponsesProps) { | ||
// Handle response by status code and content type | ||
// Obtain and flatten the HTTP responses from the operation, filtering by non-error responses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel like this would be more useful if we could add the typekit description to it?
"Get the responses for the given operation. This function will return an array of responses grouped by status code and content type."
* | ||
* @param type - The type object that must have a `name` property of type `string`. | ||
* @param type - The type object whose name is to be transformed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the previous documentation also generated by AI? will it change everytime we use the AI to help us regen the documentation once in a while?
Also, what if the logic has been changed but we forget about improve the documentation?
import { PagingOperation } from "@typespec/compiler"; | ||
import { $ } from "@typespec/compiler/experimental/typekit"; | ||
import { TypeExpression } from "@typespec/emitter-framework/typescript"; | ||
|
||
/** | ||
* Extracts and returns the element type of the page items array from a paging operation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting, AI is writing the right stuff here.
@@ -27,9 +55,15 @@ export function PageResponseDeclaration(props: PageResponseProps) { | |||
"firstLink", | |||
"lastLink", | |||
]; | |||
|
|||
// Array to hold validated paging properties extracted from the defined responses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: i may not say validated
here, no validation.
// Array to hold validated paging properties extracted from the defined responses. | |
// Array to hold paging properties extracted from the defined responses. |
@@ -1,38 +1,82 @@ | |||
/** | |||
* This file defines helper functions and a component to generate TypeScript interface declarations | |||
* for page settings used in HTTP operations. It selectively picks accepted paging properties from a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Page setting declarations used in HTTP operations would lead to misleading.
* for page settings used in HTTP operations. It selectively picks accepted paging properties from a | |
* This file defines helper functions and a component to generate TypeScript interface declarations | |
* for page settings given the HTTP operation and paging details. It selectively picks accepted paging properties from a |
* needed to send requests and process responses. | ||
* | ||
* @param httpOperation - The HTTP operation to handle. | ||
* @returns A list of generated components and function declarations for the operation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the return type is not accurate.
* @returns A list of generated components and function declarations for the operation. | |
* @returns A JSX list element representing paging relevant interfaces and functions. |
@@ -49,12 +73,13 @@ export const PaginatedOperationHandler: OperationHandler = { | |||
const operationRefkey = ay.refkey(httpOperation.operation); | |||
const returnType = ay.code`${getPagedAsyncIterableIteratorRefkey()}<${getPageItemTypeName(pagingOperation)},${getPageResponseTypeRefkey(httpOperation)},${getPageSettingsTypeRefkey(httpOperation)}>`; | |||
const clientContextInterfaceRef = getClientcontextDeclarationRef(client); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hah, AI seems talkative in other places, why is it so solient in this method?
operation: HttpOperation; | ||
pagingOperation: PagingOperation; | ||
operation: HttpOperation; // The HTTP operation for which the page response is defined. | ||
pagingOperation: PagingOperation; // The paging operation containing the output definitions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this manually added? the format seems different.
@@ -13,42 +18,96 @@ import { | |||
getOperationParameters, | |||
} from "../../operation-parameters.jsx"; | |||
|
|||
/** | |||
* Properties for the HttpRequestSend component. | |||
* @param httpOperation The HTTP operation to be performed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the @param
correct here? i notice somewhere else is @property
any difference?
* The following JSX elements embed code generation nodes: | ||
* - HttpRequest.Url generates the code for constructing the URL based on the HTTP operation. | ||
* - HttpRequestOptions configures the request options (headers, query parameters, body, etc.) for the HTTP call. | ||
* - Return statement c and sends the request using the provided client instance: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* - Return statement c and sends the request using the provided client instance: | |
* - A return statement to send the request using the provided client instance: |
* - HttpRequest.Url generates the code for constructing the URL based on the HTTP operation. | ||
* - HttpRequestOptions configures the request options (headers, query parameters, body, etc.) for the HTTP call. | ||
* - Return statement c and sends the request using the provided client instance: | ||
* - client.pathUnchecked() is used to select the path without additional type-checking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting, AI even knows our pathUnchecked without type checking.
export interface HttpResponseDeserializeProps { | ||
httpOperation: HttpOperation; | ||
responseRefkey: Refkey; | ||
children?: Children; | ||
} | ||
|
||
/** | ||
* Component that generates a function declaration for deserializing HTTP responses. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Component that generates a function declaration for deserializing HTTP responses. | |
* Component that generates a function declaration for deserializing HTTP responses for given paging operation. |
const namePolicy = ts.useTSNamePolicy(); | ||
const functionName = namePolicy.getName(httpOperation.operation.name + "Deserialize", "function"); | ||
|
||
const responseRefkey = refkey(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha, is this added by AI?
Improve code documentation to make it more understandable for AI systems or human developers.
This has been mostly generated by AI and reviewed by me. Appreciate another set of eyes