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

citrus actions for REST api #200

Open
3 tasks
bbortt opened this issue Nov 5, 2023 · 2 comments
Open
3 tasks

citrus actions for REST api #200

bbortt opened this issue Nov 5, 2023 · 2 comments
Labels

Comments

@bbortt
Copy link
Collaborator

bbortt commented Nov 5, 2023

as a user of both citrusframework/citrus and citrusframework/citrus-simulator I want to have standard "actions" that call a citrus API with the right arguments.

a good way of doing this is by extracting the OpenAPI specification from the simulator, then add a new module (name to be thought of) with generated clients. I would use some java-generator for this, preferably one without spring so the end user is not dependent upon citrus-spring.

the specifications should be stored in one file per resource. they belong into the simulator-starter (soon to be citrus-spring-boot-simulator, see #193) module, because it is the root of the API. multiple files are better maintainable than one large file.

the server implementation should be based on the OpenAPI as well (interfaces only, the already present resources should then implement these. that ensures compatibility of both client and server at all times. use the OpenAPI Spring generator.

it can be split into the following tasks whereas the first task must be done before all others:

  • extract OpenAPI from v3/api-docs into files
  • create a new module with clients
  • switch the server implementation to the OpenAPI spring generator
@bbortt bbortt added Type: Enhancement Type: Feature Prio: Low java Pull requests that update Java code labels Nov 5, 2023
@christophd
Copy link
Member

I do not know if this is really related but maybe worth having a look. YAKS is having OpenAPI support where the client is able to run operations based on a OpenAPI specification. Test data is generated and the schema rules in the OpenAPI specification are also used for the response validation.

https://github.com/citrusframework/yaks/tree/main/java/steps/yaks-openapi/src/main/java/org/citrusframework/yaks/openapi

My plan is to backport these YAKS features to Citrus someday

@bbortt
Copy link
Collaborator Author

bbortt commented Nov 6, 2023

not exactly, although that's a cool feature.

assuming I have the endpoint /api/test-results and I expect one simulation to be executed. this is a real endpoint, not a REST (or whatever) simulator endpoint. I would love to do something like this in the citrus test:

        // Trigger a simulation
        $(http().client(simulatorClient)
                .send()
                .whatever());

        // Very simple access to endpoint
        $(getTestResults()
                .validate("$.length", 1));

       // Instead of
        $(http().client(simulatorClient)
                .send()
                .get("/api/test-results"));
        $(http().client(simulatorClient)
                .receive()
                .response(HttpStatus.OK)
                .message()
                .validate("$.length", 1));

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

No branches or pull requests

2 participants