OpenAPITools / OpenAPITools/openapi-generator

[REQ] [dart-dio] [internal refactor] Unify test schemas

Open
#15,449 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

The Problem

Looking at bin/configs/dart*
There are currently 5 dart-dio configs

and 2 dart configs

And with the addition of freezed serialization option in https://github.com/OpenAPITools/openapi-generator/pull/13047
And http networking option in https://github.com/OpenAPITools/openapi-generator/pull/14346
And with future support for OAS 3.1 https://github.com/orgs/OpenAPITools/projects/4

We are going to need way more configs and more test schemas to test all possible permutations

Currently all the schemas we use are stored in modules/openapi-generator/src/test/resources/3_0

and a lot of these schemas are used for tests for the core generator itself

Proposed Solution

as a prerequisite, this PR https://github.com/OpenAPITools/openapi-generator/pull/14346 will have to be merged to unify both dart and dart-dio generators into one dart generator.

I propose creating one gigantic schema that tests everything in the spec, one for version: 3.0 and one for version: 3.1
which uses a variant of the new Echo Server API

Maybe we can also utilize this PR to merge small spec files instead of one big file

This new schema will then get generated against all possible permutation of options
so we will have the following new configs:

http dio
json_serializable dart-http-json_serializable dart-dio-json_serializable
built_value dart-http-built_value dart-dio-built_value
freezed dart-http-freezed dart-dio-freezed
manual dart-http-manual dart-dio-manual

Note: manual refers to the current serialization/deserialization method in the dart generator

multiplied by version:

V3 V3.1
dart-http-json_serializable v3/dart-http-json_serializable v3.1/dart-http-json_serializable
dart-http-built_value v3/dart-http-built_value v3.1/dart-http-built_value
dart-http-freezed v3/dart-http-freezed v3.1/dart-http-freezed
dart-http-manual v3/dart-http-manual v3.1/dart-http-manual
dart-dio-json_serializable v3/dart-dio-json_serializable v3.1/dart-dio-json_serializable
dart-dio-built_value v3/dart-dio-built_value v3.1/dart-dio-built_value
dart-dio-freezed v3/dart-dio-freezed v3.1/dart-dio-freezed
dart-dio-manual v3/dart-dio-manual v3.1/dart-dio-manual

so with only 2 echo_api.yaml schemas (one for 3.0.0, and one for 3.1.0), we can get 16 different configs, meaning we get 16 different dart projects

The Tests

Currently for dart-dio we generate a tests folder that contain model tests, these aren't really useful at the moment (I think they were supposed to test model usage/serialization/deserialization)

Instead what I propose, is to replace those tests with a simple echo-server implementation in dart (using shelf for example)
and make sure each permutation of the generated files has the proper tests working, that test it against the provided examples


@wing328 @jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing bin/configs/dart* files and the schemas under modules/openapi-generator/src/test/resources/3_0, especially echo_api.yaml. Check the prerequisite generator-unification work and the proposed schema-merging approach before planning the permutations. Done means consolidated 3.0 and 3.1 schemas, configurations for each listed Dart option, and working generated-project tests against the examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, openapi
Domain
testing, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.