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

Add getters for private default Headers and authentications #8509

Merged
merged 3 commits into from
Jan 29, 2021

Conversation

NANASHI0X74
Copy link
Contributor

@NANASHI0X74 NANASHI0X74 commented Jan 22, 2021

Rationale for this is: At the moment I'm in a situation where code generation (or rather the scheme generation for our backend code) doesn't generate code that works with our backend, so I need to do one specific request by hand. I'd like to still use the same default headers and authentications that the Apiclient uses though.

This is a really minor change, so I thought I'd show you the code before talking. Submitting this as draft so I can do the build and sample generation later

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@kuhnroyal
Copy link
Contributor

Makes sense, follow the PR check list and regenerate the samples. Otherwise it won't build.

I would recommend returning immutable copies of the collections in the getters to avoid the problems that you added as documentation.

@NANASHI0X74
Copy link
Contributor Author

returning an immutable list for the authentications sounds like a good idea.
If I were to add entries to the default header map, those would get picked up though, right? I think it would have benefits to leave that mutable, for example I could use addAll() to add multiple headers at once and the like

@kuhnroyal
Copy link
Contributor

Hmm are you sure this is the correct template? The dart template folder is unmaintained.

@NANASHI0X74
Copy link
Contributor Author

so, I finally got round to doing this stuff. Thanks btw, I did mistakenly use the wrong template folder.
I took the liberty btw to also make the shebangs in two of the scripts portable (i.e. use /usr/bin/env bash) because the hardcoded /bin/bash actually caused problems on my nixOS machine.
Now, to mention the rest of the technical committee...
@swipesight @jaumard @josh-burton @amondnet @sbu-WBT @agilob

@NANASHI0X74 NANASHI0X74 marked this pull request as ready for review January 25, 2021 21:13
@agilob
Copy link
Contributor

agilob commented Jan 25, 2021

I confirmed it with other generators and they wrap headers and authenticators in immutable maps too.

@NANASHI0X74
Copy link
Contributor Author

I would actually advocate for leaving the returned headermap mutable. For the Authentications it definitely makes sense to return them immutably since the authentications are defined in the spec and the generated code sort of enforces those by only respecting authentications on certain keys in the map from what I understand, but leaving the headermap mutable has the benefit that you can use the full dart collection api to mutate it if you want and not be constrained to only adding one header at a time via a function call. I don't really see any downside to that either...

@kuhnroyal
Copy link
Contributor

Fine by me

@wing328 wing328 changed the title add getters for private default Headers and authentications Add getters for private default Headers and authentications Jan 28, 2021
@wing328 wing328 added this to the 5.0.1 milestone Jan 28, 2021
@wing328
Copy link
Member

wing328 commented Jan 29, 2021

CircleCI failure not related to this change.

@wing328 wing328 merged commit 57126a1 into OpenAPITools:master Jan 29, 2021
@kuhnroyal
Copy link
Contributor

Broken master build fixed in #8581

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants