open-traffic-generator / openapiart

OpenAPI artifact generator
MIT License
6 stars 4 forks source link

Data type refactor restructuring and changes #433

Closed Vibaswan closed 1 year ago

Vibaswan commented 1 year ago

Fixes #436 Fixes #437 Fixes #438

ashutshkumr commented 1 year ago

Do we need this snippet ? Why ?

        if "enums" in xpattern:
            schema["properties"]["value"]["enum"] = copy.deepcopy(
                xpattern["enums"]
            )
            schema["properties"]["values"]["items"]["enum"] = copy.deepcopy(
                xpattern["enums"]
ashutshkumr commented 1 year ago

Do we need this too ? can't it be deepcopied directly to schema ?

        xconstants = (
            xpattern["x-constants"] if "x-constants" in xpattern else None
        )
ashutshkumr commented 1 year ago

This is again coming from old code, but shouldn't we check if counter feature is provided before defining Incr/Decr schemas ?

        if xpattern["format"] in ["integer", "ipv4", "ipv6", "mac"]:
            counter_pattern_name = "{}.Counter".format(schema_name)
Vibaswan commented 1 year ago

these were from beginning not sure of the use-cases

ashutshkumr commented 1 year ago

these were from beginning not sure of the use-cases

Would suggest removing any unused code, hence asking for confirmation if it's indeed used

ashutshkumr commented 1 year ago

We're not setting correct format for auto field (for integer)

ashutshkumr commented 1 year ago

Do not provide minimum and maximum for properties which require exact 32/64 bits.

Vibaswan commented 1 year ago

We're not setting correct format for auto field (for integer)

already showcased this

Vibaswan commented 1 year ago

these were from beginning not sure of the use-cases

Would suggest removing any unused code, hence asking for confirmation if it's indeed used

removed unused code

ashutshkumr commented 1 year ago

Still see some consistency issues in bundler.py:

ashutshkumr commented 1 year ago

empty string not needed

                    pt.get("type", "") == "int" or pt.get("itemtype") == "int"
ashutshkumr commented 1 year ago

Inside _get_integer_format, if type_format is None, set it to int32

ashutshkumr commented 1 year ago

needs to be and

    def _min_max_in_range(cls, format, min, max):
        if min is None or max is None:
            return True
ashutshkumr commented 1 year ago

Remove _format_from_range and its usage. Print a WARNING that since format has not been provided, it's being defaulted to int32

ashutshkumr commented 1 year ago

Probably need to include map for int32

self._oapi_go_types = {
ashutshkumr commented 1 year ago

Remove

                elif property_schema["format"].lower() in self._oapi_go_types:
                    go_type = "{oapi_go_type}".format(
                        oapi_go_type=self._oapi_go_types[
                            property_schema["format"].lower()
                        ]
                    )
ashutshkumr commented 1 year ago

use startswith

if "uint" in field.type and field.min == 0:
                    pass