Skip to content

Commit

Permalink
Regenerate vardef client for renamed field (#78)
Browse files Browse the repository at this point in the history
* Add update-vardef-openapi-definition command

* Update OpenAPI definition

* Regenerate vardef_client

* Fix tests

* Fix some OpenAPI examples
  • Loading branch information
mmwinther authored Dec 16, 2024
1 parent 474fd98 commit d83d3a4
Show file tree
Hide file tree
Showing 18 changed files with 176 additions and 180 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
install-openapi-generator:
brew install openapi-generator

.PHONY: update-vardef-openapi-definition
update-vardef-openapi-definition:
cp \
../vardef/build/generated/ksp/main/resources/META-INF/swagger/variable-definitions-0.1.yml \
tests/variable_definitions/resources/variable-definitions-0.1.yml

.PHONY: generate-vardef-client
generate-vardef-client:
export PYTHON_POST_PROCESS_FILE="bin/openapi_generate_post_process.sh" && \
Expand Down
2 changes: 1 addition & 1 deletion demo/variable_definitions/read_variable_definitions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
" \"classification_reference\": \"91\",\n",
" \"unit_types\": [\"01\", \"02\"],\n",
" \"subject_fields\": [\"he04\"],\n",
" \"contains_sensitive_personal_information\": True,\n",
" \"contains_special_categories_of_personal_data\": True,\n",
" \"measurement_type\": None,\n",
" \"valid_from\": \"2003-01-01\",\n",
" \"external_reference_uri\": \"https://www.ssb.no/a/metadata/conceptvariable/vardok/1919/nb\",\n",
Expand Down
2 changes: 1 addition & 1 deletion demo/variable_definitions/vardef_client_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
" \"classification_reference\": \"91\",\n",
" \"unit_types\": [\"01\", \"02\"],\n",
" \"subject_fields\": [\"he04\"],\n",
" \"contains_sensitive_personal_information\": True,\n",
" \"contains_special_categories_of_personal_data\": True,\n",
" \"measurement_type\": None,\n",
" \"valid_from\": \"2003-01-01\",\n",
" \"external_reference_uri\": \"https://www.ssb.no/a/metadata/conceptvariable/vardok/1919/nb\",\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ def response_deserialize(
):
# if not found, look for '1XX', '2XX', etc.
response_type = response_types_map.get(
str(response_data.status)[0] + "XX", None
str(response_data.status)[0] + "XX",
None,
)

# deserialize response data
Expand All @@ -311,7 +312,9 @@ def response_deserialize(
encoding = match.group(1) if match else "utf-8"
response_text = response_data.data.decode(encoding)
return_data = self.deserialize(
response_text, response_type, content_type
response_text,
response_type,
content_type,
)
finally:
if not 200 <= response_data.status <= 299:
Expand Down Expand Up @@ -363,11 +366,6 @@ def sanitize_for_serialization(self, obj):

if isinstance(obj, dict):
obj_dict = obj
# Convert model obj to dict except
# attributes `openapi_types`, `attribute_map`
# and attributes which value is not None.
# Convert attribute name to json key in
# model definition for request.
elif hasattr(obj, "to_dict") and callable(obj.to_dict):
obj_dict = obj.to_dict()
else:
Expand All @@ -378,7 +376,10 @@ def sanitize_for_serialization(self, obj):
}

def deserialize(
self, response_text: str, response_type: str, content_type: str | None
self,
response_text: str,
response_type: str,
content_type: str | None,
):
"""Deserializes response into an object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ Complete response For internal users who need all details while maintaining vari

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **str** | Unique identifier for the variable definition. | [optional]
**patch_id** | **int** | Integer identifying a patch of a variable definition. |
**name** | [**LanguageStringType**](LanguageStringType.md) | Name of the variable. Must be unique for a given Unit Type and Owner combination. |
**short_name** | **str** | Recommended short name. Must be unique within an organization. |
**definition** | [**LanguageStringType**](LanguageStringType.md) | Definition of the variable. |
**classification_reference** | **str** | ID of a classification or code list from Klass. The given classification defines all possible values for the defined variable. | [optional]
**unit_types** | **List[str]** | A list of one or more unit types, e.g. person, vehicle, household. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/702. |
**subject_fields** | **List[str]** | A list of subject fields that the variable is used in. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/618. |
**contains_sensitive_personal_information** | **bool** | True if variable instances contain particularly sensitive information. Applies even if the information or identifiers are pseudonymized. Information within the following categories are regarded as particularly sensitive: Ethnicity, Political alignment, Religion, Philosophical beliefs, Union membership, Genetics, Biometrics, Health, Sexual relations, Sexual orientation |
**variable_status** | [**VariableStatus**](VariableStatus.md) | Status of the life cycle of the variable | [optional]
**measurement_type** | **str** | Type of measurement for the variable, e.g. length, volume, currency. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/303 | [optional]
**valid_from** | **date** | The variable definition is valid from this date inclusive |
**valid_until** | **date** | The variable definition is valid until this date inclusive | [optional]
**external_reference_uri** | **str** | A link (URI) to an external definition/documentation | [optional]
**comment** | [**LanguageStringType**](LanguageStringType.md) | Optional comment to explain the definition or communicate potential changes. | [optional]
**related_variable_definition_uris** | **List[str]** | Link(s) to related definitions of variables - a list of one or more definitions. For example for a variable after-tax income it could be relevant to link to definitions of income from work, property income etc. | [optional]
**owner** | [**Owner**](Owner.md) | Owner of the definition, i.e. responsible Dapla team (statistics team) and information about access management groups. |
**contact** | [**Contact**](Contact.md) | Contact details | [optional]
**created_at** | **datetime** | The timestamp at which this variable definition was first created. |
**created_by** | [**Person**](Person.md) | The user who created this variable definition. | [optional]
**last_updated_at** | **datetime** | The timestamp at which this variable definition was last modified. |
**last_updated_by** | [**Person**](Person.md) | The user who last modified this variable definition. | [optional]
**id** | **str** | Unique identifier for the variable definition. | [optional]
**patch_id** | **int** | Integer identifying a patch of a variable definition. |
**name** | [**LanguageStringType**](LanguageStringType.md) | Name of the variable. Must be unique for a given Unit Type and Owner combination. |
**short_name** | **str** | Recommended short name. Must be unique within an organization. |
**definition** | [**LanguageStringType**](LanguageStringType.md) | Definition of the variable. |
**classification_reference** | **str** | ID of a classification or code list from Klass. The given classification defines all possible values for the defined variable. | [optional]
**unit_types** | **List[str]** | A list of one or more unit types, e.g. person, vehicle, household. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/702. |
**subject_fields** | **List[str]** | A list of subject fields that the variable is used in. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/618. |
**contains_special_categories_of_personal_data** | **bool** | True if variable instances contain particularly sensitive information. Applies even if the information or identifiers are pseudonymized. Information within the following categories are regarded as particularly sensitive: Ethnicity, Political alignment, Religion, Philosophical beliefs, Union membership, Genetics, Biometrics, Health, Sexual relations, Sexual orientation |
**variable_status** | [**VariableStatus**](VariableStatus.md) | Status of the life cycle of the variable | [optional]
**measurement_type** | **str** | Type of measurement for the variable, e.g. length, volume, currency. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/303 | [optional]
**valid_from** | **date** | The variable definition is valid from this date inclusive |
**valid_until** | **date** | The variable definition is valid until this date inclusive | [optional]
**external_reference_uri** | **str** | A link (URI) to an external definition/documentation | [optional]
**comment** | [**LanguageStringType**](LanguageStringType.md) | Optional comment to explain the definition or communicate potential changes. | [optional]
**related_variable_definition_uris** | **List[str]** | Link(s) to related definitions of variables - a list of one or more definitions. For example for a variable after-tax income it could be relevant to link to definitions of income from work, property income etc. | [optional]
**owner** | [**Owner**](Owner.md) | Owner of the definition, i.e. responsible Dapla team (statistics team) and information about access management groups. |
**contact** | [**Contact**](Contact.md) | Contact details | [optional]
**created_at** | **datetime** | The timestamp at which this variable definition was first created. |
**created_by** | [**Person**](Person.md) | The user who created this variable definition. | [optional]
**last_updated_at** | **datetime** | The timestamp at which this variable definition was last modified. |
**last_updated_by** | [**Person**](Person.md) | The user who last modified this variable definition. | [optional]

## Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ Create a Draft Variable Definition

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | [**LanguageStringType**](LanguageStringType.md) | Name of the variable. Must be unique for a given Unit Type and Owner combination. |
**short_name** | **str** | Recommended short name. Must be unique within an organization. |
**definition** | [**LanguageStringType**](LanguageStringType.md) | Definition of the variable. |
**classification_reference** | **str** | ID of a classification or code list from Klass. The given classification defines all possible values for the defined variable. | [optional]
**unit_types** | **List[str]** | A list of one or more unit types, e.g. person, vehicle, household. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/702. |
**subject_fields** | **List[str]** | A list of subject fields that the variable is used in. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/618. |
**contains_sensitive_personal_information** | **bool** | True if variable instances contain particularly sensitive information. Applies even if the information or identifiers are pseudonymized. Information within the following categories are regarded as particularly sensitive: Ethnicity, Political alignment, Religion, Philosophical beliefs, Union membership, Genetics, Biometrics, Health, Sexual relations, Sexual orientation |
**measurement_type** | **str** | Type of measurement for the variable, e.g. length, volume, currency. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/303 | [optional]
**valid_from** | **date** | The variable definition is valid from this date inclusive |
**external_reference_uri** | **str** | A link (URI) to an external definition/documentation | [optional]
**comment** | [**LanguageStringType**](LanguageStringType.md) | Optional comment to explain the definition or communicate potential changes. | [optional]
**related_variable_definition_uris** | **List[str]** | Link(s) to related definitions of variables - a list of one or more definitions. For example for a variable after-tax income it could be relevant to link to definitions of income from work, property income etc. | [optional]
**contact** | [**Contact**](Contact.md) | Contact details | [optional]
**name** | [**LanguageStringType**](LanguageStringType.md) | Name of the variable. Must be unique for a given Unit Type and Owner combination. |
**short_name** | **str** | Recommended short name. Must be unique within an organization. |
**definition** | [**LanguageStringType**](LanguageStringType.md) | Definition of the variable. |
**classification_reference** | **str** | ID of a classification or code list from Klass. The given classification defines all possible values for the defined variable. | [optional]
**unit_types** | **List[str]** | A list of one or more unit types, e.g. person, vehicle, household. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/702. |
**subject_fields** | **List[str]** | A list of subject fields that the variable is used in. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/618. |
**contains_special_categories_of_personal_data** | **bool** | True if variable instances contain particularly sensitive information. Applies even if the information or identifiers are pseudonymized. Information within the following categories are regarded as particularly sensitive: Ethnicity, Political alignment, Religion, Philosophical beliefs, Union membership, Genetics, Biometrics, Health, Sexual relations, Sexual orientation |
**measurement_type** | **str** | Type of measurement for the variable, e.g. length, volume, currency. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/303 | [optional]
**valid_from** | **date** | The variable definition is valid from this date inclusive |
**external_reference_uri** | **str** | A link (URI) to an external definition/documentation | [optional]
**comment** | [**LanguageStringType**](LanguageStringType.md) | Optional comment to explain the definition or communicate potential changes. | [optional]
**related_variable_definition_uris** | **List[str]** | Link(s) to related definitions of variables - a list of one or more definitions. For example for a variable after-tax income it could be relevant to link to definitions of income from work, property income etc. | [optional]
**contact** | [**Contact**](Contact.md) | Contact details | [optional]

## Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ Create a new Patch version on a Published Variable Definition.

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | [**LanguageStringType**](LanguageStringType.md) | Name of the variable. Must be unique for a given Unit Type and Owner combination. | [optional]
**definition** | [**LanguageStringType**](LanguageStringType.md) | Definition of the variable. | [optional]
**classification_reference** | **str** | ID of a classification or code list from Klass. The given classification defines all possible values for the defined variable. | [optional]
**unit_types** | **List[str]** | A list of one or more unit types, e.g. person, vehicle, household. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/702. | [optional]
**subject_fields** | **List[str]** | A list of subject fields that the variable is used in. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/618. | [optional]
**contains_sensitive_personal_information** | **bool** | True if variable instances contain particularly sensitive information. Applies even if the information or identifiers are pseudonymized. Information within the following categories are regarded as particularly sensitive: Ethnicity, Political alignment, Religion, Philosophical beliefs, Union membership, Genetics, Biometrics, Health, Sexual relations, Sexual orientation | [optional]
**variable_status** | [**VariableStatus**](VariableStatus.md) | Status of the life cycle of the variable | [optional] [readonly]
**measurement_type** | **str** | Type of measurement for the variable, e.g. length, volume, currency. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/303 | [optional]
**valid_until** | **date** | The variable definition is valid until this date inclusive | [optional]
**external_reference_uri** | **str** | A link (URI) to an external definition/documentation | [optional]
**comment** | [**LanguageStringType**](LanguageStringType.md) | Optional comment to explain the definition or communicate potential changes. | [optional]
**related_variable_definition_uris** | **List[str]** | Link(s) to related definitions of variables - a list of one or more definitions. For example for a variable after-tax income it could be relevant to link to definitions of income from work, property income etc. | [optional]
**owner** | [**Owner**](Owner.md) | Owner of the definition, i.e. responsible Dapla team (statistics team) and information about access management groups. | [optional]
**contact** | [**Contact**](Contact.md) | Contact details | [optional]
**name** | [**LanguageStringType**](LanguageStringType.md) | Name of the variable. Must be unique for a given Unit Type and Owner combination. | [optional]
**definition** | [**LanguageStringType**](LanguageStringType.md) | Definition of the variable. | [optional]
**classification_reference** | **str** | ID of a classification or code list from Klass. The given classification defines all possible values for the defined variable. | [optional]
**unit_types** | **List[str]** | A list of one or more unit types, e.g. person, vehicle, household. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/702. | [optional]
**subject_fields** | **List[str]** | A list of subject fields that the variable is used in. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/618. | [optional]
**contains_special_categories_of_personal_data** | **bool** | True if variable instances contain particularly sensitive information. Applies even if the information or identifiers are pseudonymized. Information within the following categories are regarded as particularly sensitive: Ethnicity, Political alignment, Religion, Philosophical beliefs, Union membership, Genetics, Biometrics, Health, Sexual relations, Sexual orientation | [optional]
**variable_status** | [**VariableStatus**](VariableStatus.md) | Status of the life cycle of the variable | [optional] [readonly]
**measurement_type** | **str** | Type of measurement for the variable, e.g. length, volume, currency. Must be defined as codes from https://www.ssb.no/klass/klassifikasjoner/303 | [optional]
**valid_until** | **date** | The variable definition is valid until this date inclusive | [optional]
**external_reference_uri** | **str** | A link (URI) to an external definition/documentation | [optional]
**comment** | [**LanguageStringType**](LanguageStringType.md) | Optional comment to explain the definition or communicate potential changes. | [optional]
**related_variable_definition_uris** | **List[str]** | Link(s) to related definitions of variables - a list of one or more definitions. For example for a variable after-tax income it could be relevant to link to definitions of income from work, property income etc. | [optional]
**owner** | [**Owner**](Owner.md) | Owner of the definition, i.e. responsible Dapla team (statistics team) and information about access management groups. | [optional]
**contact** | [**Contact**](Contact.md) | Contact details | [optional]

## Example

Expand Down
Loading

0 comments on commit d83d3a4

Please sign in to comment.