Skip to content
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

header parameters are not exposed in go generated code #1720

Closed
rodcloutier opened this issue Jul 6, 2022 · 2 comments
Closed

header parameters are not exposed in go generated code #1720

rodcloutier opened this issue Jul 6, 2022 · 2 comments

Comments

@rodcloutier
Copy link

rodcloutier commented Jul 6, 2022

The following open api spec does not generate code for the parameter define to be in the headers

/v1/clusters:
    get:
      parameters:
        - name: projectid
          in: header
          schema:
            type: string
          description: Project ID 
        - name: provider
          in: query
          schema:
            type: string
          description: Filter by provider (for administrators)

Resulting code

// ClustersRequestBuilder builds and executes requests for operations under \v1\clusters
type ClustersRequestBuilder struct {
    // Path parameters for the request
    pathParameters map[string]string
    // The request adapter to use to execute the requests.
    requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter
    // Url template to use to build the URL for the current request builder
    urlTemplate string
}
// ClustersRequestBuilderGetQueryParameters list clusters
type ClustersRequestBuilderGetQueryParameters struct {
    // Filter by provider (for administrators)
    Provider *string
}
// ClustersRequestBuilderGetRequestConfiguration configuration for the request such as headers, query parameters, and middleware options.
type ClustersRequestBuilderGetRequestConfiguration struct {
    // Request headers
    Headers map[string]string
    // Request options
    Options []i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestOption
    // Request query parameters
    QueryParameters *ClustersRequestBuilderGetQueryParameters
}

I saw that it was requested to is this something that was requested. Not sure it made it to the go implementation

thanks for the update, try out x => x.QueryParameters.Status = new string[] { "pending"} instead. We've made a recent change based on community feedback to group the request configuration (parameters, headers, options) on a single object.
#135 (comment)

@ghost ghost added the Needs: Triage 🔍 label Jul 6, 2022
@baywet baywet self-assigned this Jul 7, 2022
@baywet
Copy link
Member

baywet commented Jul 7, 2022

Salut @rodcloutier,
Thank you for the interest in Kiota, and for reaching out.
This is a design decision: Query parameters get a generated symbol, headers don't.
To set headers, you can use the Headers field on the the request configuration struct, and pass the request configuration value to the get/post/patch/delete/put method.

All languages abide by this design decision, except for the CLI at this point. Some of the reasons why it was designed like that:

  • headers can increase the size of the generated code by a lot (they are often used across APIs, like api version, consistency level etc...)
  • what to do for standard headers that are not described? generate them all?

I hope this clarifies some of the intents, let us know if you have further comments/questions.

@ghost
Copy link

ghost commented Jul 11, 2022

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost ghost closed this as completed Jul 14, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants