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 wiremock module #648

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mcruzdev
Copy link
Collaborator

@mcruzdev mcruzdev commented Feb 2, 2024

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
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.

@mcruzdev mcruzdev added this to the Wiremock Implementation M1 milestone Feb 2, 2024
@mcruzdev mcruzdev changed the title Wiremock module issue 575a Add wiremock module Feb 2, 2024
@mcruzdev
Copy link
Collaborator Author

mcruzdev commented Feb 2, 2024

Hi @hbelmiro and @ricardozanini I created the wiremock module, what initial features we need to have to merge to main?

Is it possible to create a branch for wiremock stuff, or just adding an initial feature is ok for now?

Copy link
Contributor

github-actions bot commented Feb 2, 2024

🎊 PR Preview 4cde6ca has been successfully built and deployed. See the documentation preview: https://quarkus-openapi-generator-preview-pr-648.surge.sh

@hbelmiro
Copy link
Contributor

hbelmiro commented Feb 3, 2024

@mcruzdev

what initial features we need to have to merge to main?

From us, you're probably the one who knows more about it. I'll let you decide.
Is this wiremock support a real need for you as a user? If so, what are the ones you need the most? From those, pick the easiest/fastest to implement.

Is it possible to create a branch for wiremock stuff, or just adding an initial feature is ok for now?
IMO, we can add features incrementally (an initial feature is ok), so users can benefit from them ASAP.

@mcruzdev
Copy link
Collaborator Author

mcruzdev commented Feb 3, 2024

Hi @hbelmiro, Thank you!

It help me a lot, I will continue here!

@mcruzdev
Copy link
Collaborator Author

mcruzdev commented Feb 4, 2024

  • Add response status from OpenAPI
  • Add response body from OpenAPI (without to get from components)

@mcruzdev mcruzdev force-pushed the wiremock-module-issue-575a branch 2 times, most recently from 95cf0ac to c5efd5b Compare February 10, 2024 18:29
@mcruzdev
Copy link
Collaborator Author

Hi @hbelmiro and @ricardozanini, I think that we can get a first review about this new feature.

@mcruzdev mcruzdev marked this pull request as ready for review February 14, 2024 01:15
@ricardozanini
Copy link
Member

I'd rather wait for #482 to be merged first. @carlesarnal will kick my ass if I keep asking him to rebase.

@mcruzdev mcruzdev force-pushed the wiremock-module-issue-575a branch 3 times, most recently from de998cb to e7afe5c Compare February 22, 2024 00:27
Copy link
Member

@ricardozanini ricardozanini left a comment

Choose a reason for hiding this comment

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

Just a few comments initially, I'll do a better review later.

@mcruzdev
Copy link
Collaborator Author

Just a few comments initially, I'll do a better review later.

I switched the extension to experimental Sound good?

I've added some basic features for starters. It is great for new contributors!

@ricardozanini
Copy link
Member

@mcruzdev can you rebase? 🙏

@ricardozanini
Copy link
Member

@mcruzdev are the issues pointed by GH relevant?

@mcruzdev
Copy link
Collaborator Author

mcruzdev commented Mar 6, 2024

@mcruzdev are the issues pointed by GH relevant?

Sorry for delay!

I think we can ignore because are Test classes. makes sense?

Unused class: SchemaReaderTest is not referenced within this codebase. If not used as an external API it should be removed.

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.

Good job and amazing contribution @mcruzdev. Thank you!
I left some comments.

wiremock/deployment/pom.xml Outdated Show resolved Hide resolved
wiremock/deployment/pom.xml Outdated Show resolved Hide resolved
wiremock/docs/modules/ROOT/nav.adoc Outdated Show resolved Hide resolved
wiremock/docs/modules/ROOT/pages/index.adoc Outdated Show resolved Hide resolved
wiremock/integration-tests/pom.xml Outdated Show resolved Hide resolved
wiremock/pom.xml Outdated Show resolved Hide resolved
wiremock/runtime/pom.xml Outdated Show resolved Hide resolved
@mcruzdev
Copy link
Collaborator Author

mcruzdev commented Mar 14, 2024

Hi @hbelmiro thank you for the reviewing it, I will solve all soon!

@hbelmiro
Copy link
Contributor

@mcruzdev can you please let me know when I can re-review it?

@mcruzdev
Copy link
Collaborator Author

mcruzdev commented Mar 27, 2024

Hi @hbelmiro, I think you can review it now! When all things are ok I will do the squash


public static String readObjectExample(Schema<?> schema) {
try {
HashMap<String, Object> map = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove the Map parameter of mapObjectExample.
By doing this, we avoid modifying objects passed as an argument, increasing the code's immutability.
Like this:

    static String readObjectExample(Schema<?> schema) {
        try {
            Map<String, Object> map = mapObjectExample(schema);
            return OpenApiWiremockGeneratorWrapper.OBJECT_MAPPER_INSTANCE.writeValueAsString(map);
        } catch (JsonProcessingException e) {
            return EMPTY_JSON_OBJECT;
        }
    }

    private static Map<String, Object> mapObjectExample(Schema<?> example) {
        HashMap<String, Object> root = new HashMap<>();
        Optional.ofNullable(example.getProperties()).orElse(Map.of())
                .forEach((key, schema) -> {
                    if (schema.getType().equals(OBJECT_TYPE)) {
                        root.put(key, mapObjectExample(schema));
                    } else {
                        root.put(key, schema.getExample());
                    }
                });
        return root;
    }

@mcruzdev
Copy link
Collaborator Author

Hi @hbelmiro and @ricardozanini I think we can wait for merge this pull request, I am seeing here some projects that does similar things and I am collecting some ideas to use here... Another point is: I am very busy and I think if we merge it we will not have effort to upgrade this module faster. WDYT?

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

Successfully merging this pull request may close these issues.

None yet

4 participants