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

[PHP] Escape media type #615

Merged
merged 4 commits into from
Jul 26, 2018
Merged

Conversation

ackintosh
Copy link
Contributor

@ackintosh ackintosh commented Jul 21, 2018

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.1.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

In case of using mediaType in doc comment, */* causes a syntax error.

What this PR did:

@ackintosh ackintosh added Server: PHP WIP Work in Progress labels Jul 21, 2018
@ackintosh
Copy link
Contributor Author

Technical committee: @jebentier @dkarlovi @mandrean @jfastnacht @ybelenko

@ackintosh ackintosh removed the WIP Work in Progress label Jul 21, 2018
@ybelenko
Copy link
Contributor

@ackintosh Maybe we should also put escapeMediaType into postProcessOperationsWithModels within AbstractPhpCodegen? I'm not sure, but I think that abstract generator should be 100% working. Right now without any overrides it produces broken stubs, I presume.

@ybelenko
Copy link
Contributor

@ackintosh Maybe escapeMediaType should accept mediaType, not entire list? Like that:

public String escapeMediaType(String mediaType) {
    // "*/*" causes a syntax error
    if ("*/*".equals(mediaType)) {
        return "*_/_*";
    }
    return mediaType;
}

All other escape functions in AbstractPhpCodegen accepts String and returns String already.

@wing328 wing328 added this to the 3.2.0 milestone Jul 26, 2018
@wing328
Copy link
Member

wing328 commented Jul 26, 2018

@ybelenko let's go with this PR to start with. We can always improve the existing code base with another PR.

Personally, I'm ok with your approach and @ackintosh 's approach.

@wing328
Copy link
Member

wing328 commented Jul 26, 2018

we should also put escapeMediaType into postProcessOperationsWithModels within AbstractPhpCodegen

I think doing it once in postProcessOperations should be enough. (postProcessOperationsWithModels was created to process both operations and models in the same function)

@wing328 wing328 merged commit c9b9341 into OpenAPITools:master Jul 26, 2018
@ybelenko
Copy link
Contributor

@wing328 hmmm... Weird, I rember that saw merged PR where postProcessOperations has been deprecated in favor of postProcessOperationsWithModels. Can't find it now, and no evidence in current codebase. Maybe it just my imagination.

@wing328
Copy link
Member

wing328 commented Jul 26, 2018

@ybelenko yes, I think eventually we want to just have one postProcess method to work on the operations and postProcessOperations should be the chosen one.

We will need a PR to do the cleanup before the major release that removes psotProcessOperations completely.

A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
* Move escapeMediaType() to AbstractPhpCodegen

* Escape media type

* Update samples

- bin/php-lumen-petstore-server.sh

* Refactoring: remove unused 'import'
nilskuhn pushed a commit to nilskuhn/openapi-generator that referenced this pull request Apr 6, 2023
…-16.x

chore(deps): update dependency dotenv to v16
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