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

[typescript-rxjs] Added support for servers #7771

Merged
merged 2 commits into from
Oct 22, 2020

Conversation

BenICE
Copy link
Contributor

@BenICE BenICE commented Oct 20, 2020

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.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. 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
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

(if somebody could tell me, if typescript-rxjs is still a good idea to use or if the main typescript generator would be a better option (as it seems to use rxjs as well), I would highly appreciate it)

cc @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02)

@auto-labeler
Copy link

auto-labeler bot commented Oct 20, 2020

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@BenICE
Copy link
Contributor Author

BenICE commented Oct 21, 2020

Will resolve the last problem, if PR is deemed okay -> it seems just the line endings are wrong (but if I run the bin/utils/ensure-up-to-date script I get several 100 files, but not the 4 files that are marked by the circleci: build). Probably because I run under windows in git bash.

Copy link
Member

@macjohnny macjohnny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, it would be nice if you could also port this to the new typescript experimental generator

}

{{#servers}}
export const server{{-index}} = new ServerConfiguration<{ {{#variables}} "{{name}}": {{#enumValues}}"{{.}}"{{^-last}} | {{/-last}}{{/enumValues}}{{^enumValues}}string{{/enumValues}}{{^-last}},{{/-last}} {{/variables}} }>("{{url}}", { {{#variables}} "{{name}}": "{{defaultValue}}" {{^-last}},{{/-last}}{{/variables}} }, "{{description}}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better only export the servers variable

Suggested change
export const server{{-index}} = new ServerConfiguration<{ {{#variables}} "{{name}}": {{#enumValues}}"{{.}}"{{^-last}} | {{/-last}}{{/enumValues}}{{^enumValues}}string{{/enumValues}}{{^-last}},{{/-last}} {{/variables}} }>("{{url}}", { {{#variables}} "{{name}}": "{{defaultValue}}" {{^-last}},{{/-last}}{{/variables}} }, "{{description}}")
const server{{-index}} = new ServerConfiguration<{ {{#variables}} "{{name}}": {{#enumValues}}"{{.}}"{{^-last}} | {{/-last}}{{/enumValues}}{{^enumValues}}string{{/enumValues}}{{^-last}},{{/-last}} {{/variables}} }>("{{url}}", { {{#variables}} "{{name}}": "{{defaultValue}}" {{^-last}},{{/-last}}{{/variables}} }, "{{description}}")

and add server to the reserved keywords in

private void addExtraReservedWords() {
this.reservedWords.add("BASE_PATH");
this.reservedWords.add("BaseAPI");
this.reservedWords.add("COLLECTION_FORMATS");
this.reservedWords.add("ConfigurationParameters");
this.reservedWords.add("Configuration");
this.reservedWords.add("HttpMethod");
this.reservedWords.add("HttpHeaders");
this.reservedWords.add("HttpQuery");
this.reservedWords.add("HttpBody");
this.reservedWords.add("RequestArgs");
this.reservedWords.add("RequestOpts");
this.reservedWords.add("ResponseArgs");
this.reservedWords.add("Middleware");
this.reservedWords.add("AjaxRequest");
this.reservedWords.add("AjaxResponse");
}

to avoid naming conflicts with existing parameters

@BenICE
Copy link
Contributor Author

BenICE commented Oct 21, 2020

Is the experimental typescript generator -> this one here: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache

If so, it already has this feature, but slightly adjusted to their use case.

(Other comment will be done.)

@BenICE
Copy link
Contributor Author

BenICE commented Oct 21, 2020

  • Line endings fixed
  • Only servers array exposed
  • servers as resevered word added

Anything else?

(PS: If you have time, can you give me an idea if this generator will "die" and to be exchanged by the expermential one? Or point me to some infos about the idea of the experimental one)

Copy link
Member

@macjohnny macjohnny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@macjohnny macjohnny added this to the 5.0.0 milestone Oct 22, 2020
@macjohnny macjohnny merged commit 9af73d0 into OpenAPITools:master Oct 22, 2020
@BenICE BenICE deleted the typescript-rxjs-servers branch October 22, 2020 11:47
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.

None yet

3 participants