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

Fix #852 - Process Qute templates in a strict manner #864

Merged
merged 4 commits into from
Nov 25, 2024

Conversation

ricardozanini
Copy link
Member

Many thanks for submitting your Pull Request ❤️!

Please make sure that your PR meets the following requirements:

  • You have read the contributors guide
  • Your code is properly formatted according to our code style
  • Pull Request title contains the target branch if not targeting main: [0.9.x] Subject
  • Pull Request contains link to the issue
  • Pull Request contains link to any dependent or related Pull Request
  • Pull Request contains description of the issue
  • Pull Request does not include fixes for issues other than the main ticket

In this PR:

I'm surprised a few of these features were working - at all—with many parsing logic and errors.

Fix #852

How to backport a pull request to a different branch?

In order to automatically create a backporting pull request please add one or more labels having the following format backport-<branch-name>, where <branch-name> is the name of the branch where the pull request must be backported to (e.g., backport-quarkus2 to backport the original PR to the quarkus2 branch).

NOTE: backporting is an action aiming to move a change (usually a commit) from a branch (usually the main one) to another one, which is generally referring to a still maintained release branch. Keeping it simple: it is about to move a specific change or a set of them from one branch to another.

Once the original pull request is successfully merged, the automated action will create one backporting pull request per each label (with the previous format) that has been added.

If something goes wrong, the author will be notified and at this point a manual backporting is needed.

NOTE: this automated backporting is triggered whenever a pull request on main branch is labeled or closed, but both conditions must be satisfied to get the new PR created.

@ricardozanini ricardozanini requested a review from a team as a code owner November 21, 2024 23:06
@ricardozanini
Copy link
Member Author

@david-cabillic can you take a look and try it on your end?

@ricardozanini
Copy link
Member Author

@mcruzdev @hbelmiro please carefully review it.

@david-cabillic
Copy link

@ricardozanini I have a Maven build issue:

[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:3.16.4:generate-code (default) on project quarkus-document-api-client: Quarkus code generation phase has failed: InvocationTargetException: Could not generate model 'PostIndexingModifier_request': TemplateException: Rendering error: Property "classname" not found on the base object "null" in expression {child.model.classname} -> [Help 1]

@ricardozanini
Copy link
Member Author

Are you using the same openapi you sent to us in the issue? Because this file is here in the PR and I can't see this error.

If no, please send me the file.

@david-cabillic
Copy link

@ricardozanini I have 2 files in my project.

@ricardozanini
Copy link
Member Author

@ricardozanini I have 2 files in my project.

Can you please share?

@ricardozanini
Copy link
Member Author

@david-cabillic I figured it out.

Given this openapi excerpt:

    CheckpointStatistics:
      required:
        - className
      type: object
      properties:
        className:
          type: string
      discriminator:
        propertyName: className
        mapping:
          completed: '#/components/schemas/CompletedCheckpointStatistics'
          failed: '#/components/schemas/FailedCheckpointStatistics'
          in_progress: '#/components/schemas/PendingCheckpointStatistics'

It will generate annotations like this:

@com.fasterxml.jackson.annotation.JsonIgnoreProperties(
  value = "className", // ignore manually set className, it will be automatically generated by Jackson during serialization
  allowSetters = true // allows the className to be set during deserialization
)
@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include = com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY, property = "className", visible = true)
@com.fasterxml.jackson.annotation.JsonSubTypes({
    @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = CompletedCheckpointStatistics.class, name = "completed"),
    @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = FailedCheckpointStatistics.class, name = "failed"),
    @com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = PendingCheckpointStatistics.class, name = "in_progress"),
})
public class CheckpointStatistics  { }

It wasn't working - at all - in previous versions.

Can you try again my new commit? Please make sure that your discriminator field in your spec file is correct.

@ricardozanini
Copy link
Member Author

Actually I need to fix the import first.

@david-cabillic
Copy link

david-cabillic commented Nov 22, 2024

administration.json
document.json
This 2 documents I'm using.

`
quarkus.openapi-generator.codegen.spec.administration_json.base-package=ch.tcs.onbase.administration
quarkus.openapi-generator.codegen.spec.administration_json.config-key=obadministration
quarkus.openapi-generator.codegen.spec.administration_json.model-name-prefix=OB

quarkus.openapi-generator.codegen.spec.document_json.base-package=ch.tcs.onbase.document
quarkus.openapi-generator.codegen.spec.document_json.config-key=obdocument
quarkus.openapi-generator.codegen.spec.document_json.model-name-prefix=OB
quarkus.openapi-generator.codegen.spec.document_json.type-mappings.File=byte[]
`

@ricardozanini
Copy link
Member Author

@david-cabillic can you please update and try again?

Signed-off-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com>
Signed-off-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com>
Signed-off-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com>
@david-cabillic
Copy link

@ricardozanini Build ok, well done .

@ricardozanini
Copy link
Member Author

@david-cabillic, as soon as @mcruzdev and @hbelmiro review this PR, I'll merge it and release a new minor version. Thanks for reporting it; I've found many problems in the templates thanks to it.

Copy link
Contributor

@hbelmiro hbelmiro left a comment

Choose a reason for hiding this comment

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

LGTM
I just left two optional comments.

@david-cabillic
Copy link

@ricardozanini You're welcome

Signed-off-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com>
@ricardozanini ricardozanini merged commit e230b96 into quarkiverse:main Nov 25, 2024
7 checks passed
github-actions bot pushed a commit that referenced this pull request Nov 25, 2024
* Fix #852 - Process Qute templates in a strict manner

Signed-off-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com>

* Fix discriminator annotations on pojo.qute

Signed-off-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com>

* Improve testing on discriminator annotations

Signed-off-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com>

* Incorporate @hbelmiro review

Signed-off-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com>

---------

Signed-off-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com>
@ricardozanini ricardozanini deleted the issue-852 branch November 25, 2024 16:42
hbelmiro pushed a commit that referenced this pull request Nov 25, 2024
* Fix #852 - Process Qute templates in a strict manner



* Fix discriminator annotations on pojo.qute



* Improve testing on discriminator annotations



* Incorporate @hbelmiro review



---------

Signed-off-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com>
Co-authored-by: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com>
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.

Cannot find symbol "NOT_FOUND.class"
4 participants