unioslo / harborapi

Python async client for the Harbor REST API v2.0.
https://unioslo.github.io/harborapi/
MIT License
28 stars 5 forks source link

`models.models.AuthProxySettings.tokenreivew_endpoint` is misspelled #19

Open pederhan opened 1 year ago

pederhan commented 1 year ago

The name of this field is misspelled in the official Harbor swagger schema.

This misspelling is also reflected in our auto generated models: https://github.com/pederhan/harborapi/blob/d4e07cec652f39205a707a7bd876bd70e434df9d/harborapi/models/models.py#L748-L751

Proposed solution

The field name should be tokenreview_endpoint, but we can't just rename the field without breaking validation. We should probably add a field alias in case this is fixed upstream, so that validation doesn't break. But even it's fixed in newer versions of Harbor, we can't remove the old one, as it would break validation for users of older versions of Harbor.

While harborapi is still very much unused by the general public, we should take this opportunity to rename the field to tokenreview_endpoint and use tokenreivew_endpoint as the alias, so that attribute access via dot notation uses the correctly spelled name.

class AuthproxySetting(BaseModel):
    # ...
   tokenreview_endpoint: Optional[str] = Field(
        None,
        description="The fully qualified URI of token review endpoint of authproxy, such as 'https://192.168.1.2:8443/tokenreview'",
        alias="tokenreivew_endpoint"
    )
    # ...
    class Config:
        allow_population_by_field_name = True

We need to allow it to be populated by both spellings of the name to ensure forwards and backwards compatibility. Therefore I am 99% sure we need to add allow_population_by_field_name = True to the config.