diff --git a/CHANGES.rst b/CHANGES.rst index 54d83af80..eadcab93c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -18,6 +18,8 @@ Changes: Fixes: ------ +- Fix rendering of `OpenAPI` definitions for ``POST /processes`` deployment such that each indicated ``Content-Type`` + correctly provides its corresponding examples for `OGC Application Package` and `CWL` representations in YAML/JSON. - Fix the `CLI` documentation about the reported result from ``undeploy`` command. It referred to a missing JSON response file, which is not valid since ``HTTP 204 No Content`` is returned for that successful operation. - Adjusted OpenAPI `Job` result examples with by-value/href responses. diff --git a/weaver/processes/utils.py b/weaver/processes/utils.py index 70eadb62c..0c6ff2863 100644 --- a/weaver/processes/utils.py +++ b/weaver/processes/utils.py @@ -968,7 +968,7 @@ def deploy_process_from_payload(payload, container, overwrite=False): # pylint: request=container if hasattr(container, 'body') else None, content=payload, content_type=c_type_full, # Pass full Content-Type with parameters (e.g., boundary) - content_type_schema=sd.DeployContentType, + content_type_schema=sd.DeployContentTypeAny, ) # Extract process ID from Content-ID header if provided (RFC 2392) diff --git a/weaver/wps_restapi/processes/processes.py b/weaver/wps_restapi/processes/processes.py index ef6d9b63b..66623ee0e 100644 --- a/weaver/wps_restapi/processes/processes.py +++ b/weaver/wps_restapi/processes/processes.py @@ -187,16 +187,21 @@ def get_processes(request): @sd.processes_service.post( tags=[sd.TAG_PROCESSES, sd.TAG_DEPLOY], - schema=sd.PostProcessesEndpointCWLYAML(), + schema=sd.PostProcessesEndpointCWL(), accept=ContentType.APP_JSON, - content_type=[ContentType.APP_CWL_YAML, ContentType.APP_CWL, ContentType.APP_CWL_X], + content_type=[ + ctype for ctype in + sd.DeployContentTypeCWL.validator.choices + if ctype not in sd.DeployContentTypeOGC.validator.choices + ], renderer=OutputFormat.JSON, response_schemas=sd.post_processes_responses, ) @sd.processes_service.post( tags=[sd.TAG_PROCESSES, sd.TAG_DEPLOY], - schema=sd.PostProcessesEndpoint(), + schema=sd.PostProcessesEndpointOGC(), accept=ContentType.APP_JSON, + content_type=sd.DeployContentTypeOGC.validator.choices, renderer=OutputFormat.JSON, response_schemas=sd.post_processes_responses, ) diff --git a/weaver/wps_restapi/swagger_definitions.py b/weaver/wps_restapi/swagger_definitions.py index 1c8f32fa4..cae63a37c 100644 --- a/weaver/wps_restapi/swagger_definitions.py +++ b/weaver/wps_restapi/swagger_definitions.py @@ -7558,7 +7558,7 @@ class Deploy(OneOfKeywordSchema): ] -class DeployContentType(ContentTypeHeader): +class DeployContentTypeAny(ContentTypeHeader): example = ContentType.APP_JSON default = ContentType.APP_JSON validator = OneOf([ @@ -7573,19 +7573,52 @@ class DeployContentType(ContentTypeHeader): ]) -class DeployHeaders(RequestHeadersBody): +class DeployContentTypeOGC(ContentTypeHeader): + example = ContentType.APP_JSON + default = ContentType.APP_JSON + validator = OneOf([ + ContentType.APP_JSON, + ContentType.APP_OGC_PKG_JSON, + ContentType.APP_OGC_PKG_YAML, + ContentType.APP_YAML, + ]) + + +class DeployContentTypeCWL(ContentTypeHeader): + example = ContentType.APP_JSON + default = ContentType.APP_JSON + validator = OneOf([ + ContentType.APP_CWL, + ContentType.APP_CWL_JSON, + ContentType.APP_CWL_YAML, + ContentType.APP_CWL_X, + ContentType.APP_YAML, + ContentType.APP_JSON, + ]) + + +class DeployHeadersAny(RequestHeadersBody): + x_auth_docker = XAuthDockerHeader() + content_type = DeployContentTypeAny() + + +class DeployHeadersOGC(RequestHeadersBody): + x_auth_docker = XAuthDockerHeader() + content_type = DeployContentTypeOGC() + + +class DeployHeadersCWL(RequestHeadersBody): x_auth_docker = XAuthDockerHeader() - content_type = DeployContentType() + content_type = DeployContentTypeCWL() class PostProcessesEndpoint(ExtendedMappingSchema): - header = DeployHeaders(description="Headers employed for process deployment.") + header = DeployHeadersAny(description="Headers employed for process deployment.") querystring = FormatQuery() - body = Deploy(title="Deploy", examples={ - "DeployCWL": { - "summary": "Deploy a process from a CWL+JSON definition.", - "value": EXAMPLES["deploy_process_cwl.json"], - }, + + +class DeployBodyOGC(Deploy): + examples = { "DeployOGC": { "summary": "Deploy a process from an OGC Application Package definition.", "value": EXAMPLES["deploy_process_ogcapppkg.json"], @@ -7594,16 +7627,32 @@ class PostProcessesEndpoint(ExtendedMappingSchema): "summary": "Deploy a process from a remote WPS-1 reference URL.", "value": EXAMPLES["deploy_process_wps1.json"], } - }) + } -class PostProcessesEndpointCWLYAML(PostProcessesEndpoint): - body = PermissiveMappingSchema(title="DeployCWLYAML", examples={ +class DeployBodyCWL(Deploy): + examples = { + "DeployCWLJSON": { + "summary": "Deploy a process from a CWL+JSON definition.", + "value": EXAMPLES["deploy_process_cwl.json"], + }, "DeployCWLYAML": { "summary": "Deploy a process from a CWL+YAML definition.", "value": EXAMPLES["deploy_process_yaml.cwl"], }, - }) + } + + +class PostProcessesEndpointOGC(PostProcessesEndpoint): + header = DeployHeadersOGC(description="Headers employed for process deployment.") + querystring = FormatQuery() + body = DeployBodyOGC() + + +class PostProcessesEndpointCWL(PostProcessesEndpoint): + header = DeployHeadersCWL(description="Headers employed for process deployment.") + querystring = FormatQuery() + body = DeployBodyCWL() class UpdateInputOutputBase(DescriptionType, InputOutputDescriptionMeta):