ProtocApi

<back to all web services

Protoc

The following routes are available for this service:
All Verbs/protoc/{Lang}
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum


class ProtocLang(str, Enum):
    CPP = 'cpp'
    C_SHARP = 'csharp'
    DART = 'dart'
    JAVA = 'java'
    JAVA_LITE = 'java-lite'
    OBJECTIVE_C = 'objc'
    PHP = 'php'
    PYTHON = 'python'
    RUBY = 'ruby'
    GO = 'go'
    JAVA_SCRIPT_CLOSURE = 'js-closure'
    JAVA_SCRIPT_COMMON_JS = 'js-commonjs'
    JAVA_SCRIPT_NODE_JS = 'js-node'
    SWIFT = 'swift'
    TYPE_SCRIPT = 'ts'
    TYPE_SCRIPT_BINARY = 'ts-binary'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ProtocResponse:
    lang: Optional[ProtocLang] = None
    generated_files: Optional[Dict[str, str]] = None
    archive_url: Optional[str] = None
    response_status: Optional[ResponseStatus] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Protoc:
    lang: Optional[ProtocLang] = None
    files: Optional[Dict[str, str]] = None
    proto_url: Optional[str] = None

Python Protoc DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /protoc/{Lang} HTTP/1.1 
Host: grpc.servicestack.net 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"lang":"cpp","files":{"String":"String"},"protoUrl":"String"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"lang":"cpp","generatedFiles":{"String":"String"},"archiveUrl":"String","responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}