{{baseName}}
property.
3 | * @enum {{=<% %>=}}{<%datatype%>}<%={{ }}=%>
4 | * @readonly
5 | */{{/emitJSDoc}}
6 | export default {{datatypeWithEnum}} = {
7 | {{#allowableValues}}{{#enumVars}}
8 | {{#emitJSDoc}}/**
9 | * value: {{{value}}}
10 | * @const
11 | */{{/emitJSDoc}}
12 | "{{name}}": {{{value}}}{{^-last}},
13 | {{/-last}}
14 | {{/enumVars}}{{/allowableValues}}
15 | };
16 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/js/ignore-list.txt:
--------------------------------------------------------------------------------
1 | /README.md
2 | /.travis.yml
3 | /.gitignore
4 | /.babelrc
5 | /git_push.sh
6 | /mocha.opts
7 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/js/licenseInfo.mustache:
--------------------------------------------------------------------------------
1 | // THIS FILE IS AUTOGENERATED, DO NOT EDIT
2 | // Generated by mify via OpenAPI Generator
3 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/js/model.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | // vim: set ft=javascript:
3 | import ApiClient from '../ApiClient.js';
4 | {{#imports}}import {{import}} from './{{import}}.js';
5 | {{/imports}}{{#models}}{{#model}}{{#isEnum}}{{>partial_model_enum_class}}{{/isEnum}}{{^isEnum}}{{>partial_model_generic}}{{/isEnum}}{{/model}}{{/models}}
6 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/js/partial_model_enum_class.mustache:
--------------------------------------------------------------------------------
1 | {{#emitJSDoc}}/**
2 | * Enum class {{classname}}.
3 | * @enum {{=<% %>=}}{<%datatype%>}<%={{ }}=%>
4 | * @readonly
5 | */{{/emitJSDoc}}
6 | export default class {{classname}} {
7 | {{#allowableValues}}{{#enumVars}}
8 | {{#emitJSDoc}}/**
9 | * value: {{{value}}}
10 | * @const
11 | */{{/emitJSDoc}}
12 | "{{name}}" = {{{value}}};
13 |
14 | {{/enumVars}}{{/allowableValues}}
15 |
16 | {{#emitJSDoc}}/**
17 | * Returns a {{classname}}
enum value from a Javascript object name.
18 | * @param {Object} data The plain JavaScript object containing the name of the enum value.
19 | * @return {{=< >=}}{module:<#invokerPackage>{{classname}}
value.
20 | */{{/emitJSDoc}}
21 | static constructFromObject(object) {
22 | return object;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/js/partial_model_inner_enum.mustache:
--------------------------------------------------------------------------------
1 | {{#emitJSDoc}}/**
2 | * Allowed values for the {{baseName}}
property.
3 | * @enum {{=<% %>=}}{<%datatype%>}<%={{ }}=%>
4 | * @readonly
5 | */{{/emitJSDoc}}
6 | {{classname}}['{{datatypeWithEnum}}'] = {
7 | {{#allowableValues}}{{#enumVars}}
8 | {{#emitJSDoc}}/**
9 | * value: {{{value}}}
10 | * @const
11 | */{{/emitJSDoc}}
12 | "{{name}}": {{{value}}}{{^-last}},
13 | {{/-last}}
14 | {{/enumVars}}{{/allowableValues}}
15 | };
16 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/__init__.handlebars:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mify-io/mify/a57d89478602566c7e24f7ff9ed8658296ea9510/assets/openapi/client-template/python/__init__.handlebars
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/__init__apis.handlebars:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 | # do not import all endpoints into this module because that uses a lot of memory and stack frames
4 | # if you need the ability to import all endpoints then import them from
5 | # tags, paths, or path_to_api, or tag_to_api
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/__init__apis_tags.handlebars:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 | # do not import all endpoints into this module because that uses a lot of memory and stack frames
4 | # if you need the ability to import all endpoints from this module, import them with
5 | # from {{packageName}}.apis.tag_to_api import tag_to_api
6 |
7 | import enum
8 |
9 |
10 | class TagValues(str, enum.Enum):
11 | {{#each enumToTag}}
12 | {{@key}} = "{{this}}"
13 | {{/each}}
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/__init__model.handlebars:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 | # we can not import model classes here because that would create a circular
4 | # reference which would not work in python2
5 | # do not import all models into this module because that uses a lot of memory and stack frames
6 | # if you need the ability to import all models from one package, import them with
7 | # from {{packageName}}.models import ModelA, ModelB
8 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/__init__models.handlebars:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 | # coding: utf-8
4 |
5 | # flake8: noqa
6 |
7 | # import all models into this package
8 | # if you have many models here with many references from one model to another this may
9 | # raise a RecursionError
10 | # to avoid this, import only the models that you directly need like:
11 | # from from {{packageName}}.{{modelPackage}}.pet import Pet
12 | # or import this package, but before doing it, use:
13 | # import sys
14 | # sys.setrecursionlimit(n)
15 |
16 | {{#each models}}
17 | {{#with model}}
18 | from {{packageName}}.{{modelPackage}}.{{classFilename}} import {{classname}}
19 | {{/with}}
20 | {{/each}}
21 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/__init__package.handlebars:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 | # coding: utf-8
4 |
5 | # flake8: noqa
6 |
7 | {{>partial_header}}
8 |
9 | __version__ = "{{packageVersion}}"
10 |
11 | # import ApiClient
12 | from {{packageName}}.api_client import ApiClient
13 |
14 | # import Configuration
15 | from {{packageName}}.configuration import Configuration
16 | {{#if hasHttpSignatureMethods}}
17 | from {{packageName}}.signing import HttpSigningConfiguration
18 | {{/if}}
19 |
20 | # import exceptions
21 | from {{packageName}}.exceptions import OpenApiException
22 | from {{packageName}}.exceptions import ApiAttributeError
23 | from {{packageName}}.exceptions import ApiTypeError
24 | from {{packageName}}.exceptions import ApiValueError
25 | from {{packageName}}.exceptions import ApiKeyError
26 | from {{packageName}}.exceptions import ApiException
27 | {{#if recursionLimit}}
28 |
29 | __import__('sys').setrecursionlimit({{recursionLimit}})
30 | {{/if}}
31 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/__init__paths.handlebars:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 | # do not import all endpoints into this module because that uses a lot of memory and stack frames
4 | # if you need the ability to import all endpoints from this module, import them with
5 | # from {{packageName}}.apis.path_to_api import path_to_api
6 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/__init__paths_enum.handlebars:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 | # do not import all endpoints into this module because that uses a lot of memory and stack frames
4 | # if you need the ability to import all endpoints from this module, import them with
5 | # from {{packageName}}.apis.path_to_api import path_to_api
6 |
7 | import enum
8 |
9 |
10 | class PathValues(str, enum.Enum):
11 | {{#each pathValToVar}}
12 | {{this}} = "{{@key}}"
13 | {{/each}}
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/__init__paths_x.handlebars:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 | # do not import all endpoints into this module because that uses a lot of memory and stack frames
4 | # if you need the ability to import all endpoints from this module, import them with
5 | # from {{packageName}}.paths.{{pathModule}} import {{apiClassName}}
6 |
7 | from {{packageName}}.paths import PathValues
8 |
9 | path = PathValues.{{{pathVar}}}
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/api.handlebars:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 |
4 | {{#with operations}}
5 | {{#each operation}}
6 | from {{packageName}}.paths.{{nickname}}.{{httpMethod}} import {{operationIdCamelCase}}
7 | {{/each}}
8 | {{/with}}
9 |
10 |
11 | {{#with operations}}
12 | class {{classname}}(
13 | {{#each operation}}
14 | {{operationIdCamelCase}},
15 | {{/each}}
16 | ):
17 | """NOTE: This class is auto generated by OpenAPI Generator
18 | Ref: https://openapi-generator.tech
19 |
20 | Do not edit the class manually.
21 | """
22 | pass
23 | {{/with}}
24 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/apis_path_to_api.handlebars:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 | import typing_extensions
4 |
5 | from {{packageName}}.paths import PathValues
6 | {{#each pathModuleToApiClassname}}
7 | from {{packageName}}.apis.paths.{{@key}} import {{this}}
8 | {{/each}}
9 |
10 | PathToApi = typing_extensions.TypedDict(
11 | 'PathToApi',
12 | {
13 | {{#each pathEnumToApiClassname}}
14 | PathValues.{{@key}}: {{this}},
15 | {{/each}}
16 | }
17 | )
18 |
19 | path_to_api = PathToApi(
20 | {
21 | {{#each pathEnumToApiClassname}}
22 | PathValues.{{@key}}: {{this}},
23 | {{/each}}
24 | }
25 | )
26 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/apis_tag_to_api.handlebars:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 | import typing_extensions
4 |
5 | from {{packageName}}.apis.tags import TagValues
6 | {{#each tagModuleNameToApiClassname}}
7 | from {{packageName}}.apis.tags.{{@key}} import {{this}}
8 | {{/each}}
9 |
10 | TagToApi = typing_extensions.TypedDict(
11 | 'TagToApi',
12 | {
13 | {{#each tagEnumToApiClassname}}
14 | TagValues.{{@key}}: {{this}},
15 | {{/each}}
16 | }
17 | )
18 |
19 | tag_to_api = TagToApi(
20 | {
21 | {{#each tagEnumToApiClassname}}
22 | TagValues.{{@key}}: {{this}},
23 | {{/each}}
24 | }
25 | )
26 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/comma.handlebars:
--------------------------------------------------------------------------------
1 | ,
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/config.yaml:
--------------------------------------------------------------------------------
1 | generatorName: python
2 | templateDir: /repo/.mify/assets/openapi/client-template/python
3 | enableMinimalUpdate: true
4 | globalProperties:
5 | apiDocs: false
6 | modelDocs: false
7 | apiTests: false
8 | modelTests: false
9 | additionalProperties:
10 | packageVersion: 1.0.0
11 | generateSourceCodeOnly: true
12 | packageName: openapi
13 | files:
14 | ignore-list.txt:
15 | destinationFilename: .openapi-generator-ignore
16 |
17 | releaseNote: Release note
18 | httpUserAgent: User Agent
19 |
20 | apiPackage: handlers
21 | modelPackage: models
22 |
23 | invokerPackage: unused
24 | apiNameSuffix: "_"
25 | modelNamePrefix: ""
26 | modelNameSuffix: ""
27 | library: ""
28 |
29 | instantiationTypes: {}
30 | typeMappings: {}
31 | importMappings: {}
32 | languageSpecificPrimitives: []
33 | reservedWordMappings: {}
34 | serverVariables: {}
35 |
36 | verbose: false
37 | skipOverwrite: false
38 | removeOperationIdPrefix: false
39 | skipOperationExample: false
40 | logToStderr: false
41 | validateSpec: true
42 | enablePostProcessFile: false
43 | strictSpecBehavior: true
44 | generateAliasAsModel: false
45 | templatingEngineName: handlebars
46 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/endpoint_args_passed.handlebars:
--------------------------------------------------------------------------------
1 | {{#if bodyParam}}
2 | {{#with bodyParam}}
3 | body=body,
4 | {{/with}}
5 | {{/if}}
6 | {{#if queryParams}}
7 | query_params=query_params,
8 | {{/if}}
9 | {{#if headerParams}}
10 | header_params=header_params,
11 | {{/if}}
12 | {{#if pathParams}}
13 | path_params=path_params,
14 | {{/if}}
15 | {{#if cookieParams}}
16 | cookie_params=cookie_params,
17 | {{/if}}
18 | {{#with bodyParam}}
19 | {{#each content}}
20 | {{#if @first}}
21 | content_type=content_type,
22 | {{/if}}
23 | {{/each}}
24 | {{/with}}
25 | {{#if produces}}
26 | accept_content_types=accept_content_types,
27 | {{/if}}
28 | {{#if servers}}
29 | host_index=host_index,
30 | {{/if}}
31 | stream=stream,
32 | timeout=timeout,
33 | skip_deserialization=skip_deserialization
34 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/endpoint_body_serialization.handlebars:
--------------------------------------------------------------------------------
1 | serialized_data = request_body_{{paramName}}.serialize(body, content_type)
2 | _headers.add('Content-Type', content_type)
3 | if 'fields' in serialized_data:
4 | _fields = serialized_data['fields']
5 | elif 'body' in serialized_data:
6 | _body = serialized_data['body']
7 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/endpoint_parameter.handlebars:
--------------------------------------------------------------------------------
1 | request_{{#if isQueryParam}}query{{/if}}{{#if isPathParam}}path{{/if}}{{#if isHeaderParam}}header{{/if}}{{#if isCookieParam}}cookie{{/if}}_{{paramName}} = api_client.{{#if isQueryParam}}Query{{/if}}{{#if isPathParam}}Path{{/if}}{{#if isHeaderParam}}Header{{/if}}{{#if isCookieParam}}Cookie{{/if}}Parameter(
2 | name="{{baseName}}",
3 | {{#if style}}
4 | style=api_client.ParameterStyle.{{style}},
5 | {{/if}}
6 | {{#if schema}}
7 | {{#with schema}}
8 | schema={{baseName}},
9 | {{/with}}
10 | {{/if}}
11 | {{#if required}}
12 | required=True,
13 | {{/if}}
14 | {{#if isExplode}}
15 | explode=True,
16 | {{/if}}
17 | )
18 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/endpoint_stub.handlebars:
--------------------------------------------------------------------------------
1 | {{> endpoint isStub=true }}
2 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/ignore-list.txt:
--------------------------------------------------------------------------------
1 | /Dockerfile
2 | /README.md
3 | /api/openapi.yaml
4 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model.handlebars:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 |
4 | {{#each models}}
5 | {{#with model}}
6 | {{> model_templates/imports_schema_types }}
7 | {{> model_templates/schema }}
8 | {{> model_templates/imports_schemas }}
9 | {{/with}}
10 | {{/each}}
11 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_doc.handlebars:
--------------------------------------------------------------------------------
1 | {{#each models}}
2 | {{#with model}}
3 | # {{packageName}}.{{modelPackage}}.{{classFilename}}.{{classname}}
4 | {{> schema_doc }}
5 | {{/with}}
6 | {{/each}}
7 |
8 | [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)
9 |
10 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_stub.handlebars:
--------------------------------------------------------------------------------
1 | {{> model isStub=true }}
2 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/classname.handlebars:
--------------------------------------------------------------------------------
1 | {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}}
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/enums.handlebars:
--------------------------------------------------------------------------------
1 | {{#with allowableValues}}
2 | {{#each enumVars}}
3 |
4 | @schemas.classproperty
5 | def {{name}}(cls):
6 | {{#eq value "schemas.NoneClass.NONE"}}
7 | return cls(None)
8 | {{else}}
9 | {{#eq value "schemas.BoolClass.TRUE"}}
10 | return cls(True)
11 | {{else}}
12 | {{#eq value "schemas.BoolClass.FALSE"}}
13 | return cls(False)
14 | {{else}}
15 | return cls({{{value}}})
16 | {{/eq}}
17 | {{/eq}}
18 | {{/eq}}
19 | {{/each}}
20 | {{/with}}
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/format_base.handlebars:
--------------------------------------------------------------------------------
1 | {{#eq getFormat "uuid"}}
2 | schemas.UUIDBase,
3 | {{/eq}}
4 | {{#eq getFormat "date"}}
5 | schemas.DateBase,
6 | {{/eq}}
7 | {{#eq getFormat "date-time"}}
8 | schemas.DateTimeBase,
9 | {{/eq}}
10 | {{#eq getFormat "number"}}
11 | schemas.DecimalBase,
12 | {{/eq}}
13 | {{#eq getFormat "binary"}}
14 | schemas.BinaryBase,
15 | {{/eq}}
16 | {{#eq getFormat "int32"}}
17 | schemas.Int32Base,
18 | {{/eq}}
19 | {{#eq getFormat "int64"}}
20 | schemas.Int64Base,
21 | {{/eq}}
22 | {{#eq getFormat "float"}}
23 | schemas.Float32Base,
24 | {{/eq}}
25 | {{#eq getFormat "double"}}
26 | schemas.Float64Base,
27 | {{/eq}}
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/imports_schema_types.handlebars:
--------------------------------------------------------------------------------
1 | from datetime import date, datetime # noqa: F401
2 | import decimal # noqa: F401
3 | import functools # noqa: F401
4 | import io # noqa: F401
5 | import re # noqa: F401
6 | import typing # noqa: F401
7 | import typing_extensions # noqa: F401
8 | import uuid # noqa: F401
9 |
10 | import frozendict # noqa: F401
11 |
12 | from {{packageName}} import schemas # noqa: F401
13 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/imports_schemas.handlebars:
--------------------------------------------------------------------------------
1 | {{#each imports}}
2 | {{#if @first}}
3 |
4 | {{/if}}
5 | {{{.}}}
6 | {{/each}}
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/list_partial.handlebars:
--------------------------------------------------------------------------------
1 | {{#with items}}
2 | {{#if complexType}}
3 |
4 | @staticmethod
5 | def {{baseName}}() -> typing.Type['{{complexType}}']:
6 | return {{complexType}}
7 | {{else}}
8 | {{> model_templates/schema }}
9 | {{/if}}
10 | {{/with}}
11 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/notes_msg.handlebars:
--------------------------------------------------------------------------------
1 | {{#unless isArray}}{{#unless complexType}}{{#with allowableValues}}must be one of [{{#each enumVars}}{{#eq value "schemas.NoneClass.NONE"}}None{{else}}{{#eq value "schemas.BoolClass.TRUE"}}True{{else}}{{#eq value "schemas.BoolClass.FALSE"}}False{{else}}{{{value}}}{{/eq}}{{/eq}}{{/eq}}, {{/each}}] {{/with}}{{#if defaultValue}}{{#unless hasRequired}}if omitted the server will use the default value of {{{defaultValue}}}{{/unless}}{{/if}}{{#eq getFormat "uuid"}}value must be a uuid{{/eq}}{{#eq getFormat "date"}}value must conform to RFC-3339 full-date YYYY-MM-DD{{/eq}}{{#eq getFormat "date-time"}}value must conform to RFC-3339 date-time{{/eq}}{{#eq getFormat "number"}}value must be numeric and storable in decimal.Decimal{{/eq}}{{#eq getFormat "int32"}}value must be a 32 bit integer{{/eq}}{{#eq getFormat "int64"}}value must be a 64 bit integer{{/eq}}{{#eq getFormat "double"}}value must be a 64 bit float{{/eq}}{{#eq getFormat "float"}}value must be a 32 bit float{{/eq}}{{/unless}}{{/unless}}
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/payload_renderer.handlebars:
--------------------------------------------------------------------------------
1 | {{#if isMap}}
2 | {
3 | {{#each value}}
4 | {{#with @key}}
5 | {{> model_templates/payload_renderer endChar=':'}}
6 | {{/with}}
7 | {{#with this}}
8 | {{> model_templates/payload_renderer endChar=','}}
9 | {{/with}}
10 | {{/each}}
11 | }{{endChar}}
12 | {{/if}}
13 | {{#if isArray}}
14 | [
15 | {{#each value}}
16 | {{> model_templates/payload_renderer endChar=','}}
17 | {{/each}}
18 | ]{{endChar}}
19 | {{/if}}
20 | {{#or isNumber isUnboundedInteger}}
21 | {{value}}{{endChar}}
22 | {{/or}}
23 | {{#if isBoolean}}
24 | {{#if value}}
25 | True{{endChar}}
26 | {{else}}
27 | False{{endChar}}
28 | {{/if}}
29 | {{/if}}
30 | {{#if isNull}}
31 | None{{endChar}}
32 | {{/if}}
33 | {{#if isString}}
34 | "{{{value}}}"{{endChar}}
35 | {{/if}}
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/property_getitems_with_addprops_getitem.handlebars:
--------------------------------------------------------------------------------
1 | def {{methodName}}(self, name: typing.Union[{{#each getRequiredVarsMap}}{{#with this}}typing_extensions.Literal["{{{baseName}}}"], {{/with}}{{/each}}{{#each vars}}{{#unless required}}typing_extensions.Literal["{{{baseName}}}"], {{/unless}}{{/each}}{{#with additionalProperties}}{{#unless getIsBooleanSchemaFalse}}str, {{/unless}}{{/with}}]){{#not vars}}{{#not getRequiredVarsMap}}{{#with additionalProperties}}{{#unless getIsBooleanSchemaFalse}} -> {{#if complexType}}'{{complexType}}'{{else}}MetaOapg.{{baseName}}{{/if}}{{/unless}}{{/with}}{{/not}}{{/not}}:
2 | {{#eq methodName "__getitem__"}}
3 | # dict_instance[name] accessor
4 | {{/eq}}
5 | return super().{{methodName}}(name)
6 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/property_type_hints.handlebars:
--------------------------------------------------------------------------------
1 | {{#if getRequiredVarsMap}}
2 |
3 | {{#if additionalProperties}}
4 | {{> model_templates/property_type_hints_required }}
5 | {{else}}
6 | {{> model_templates/property_type_hints_required addPropsUnset=true }}
7 | {{/if}}
8 | {{/if}}
9 | {{#if additionalProperties}}
10 | {{> model_templates/property_getitems_with_addprops }}
11 | {{else}}
12 | {{> model_templates/property_getitems_without_addprops }}
13 | {{/if}}
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/property_type_hints_required.handlebars:
--------------------------------------------------------------------------------
1 | {{#each getRequiredVarsMap}}
2 | {{#with this}}
3 | {{#unless nameInSnakeCase}}
4 | {{#if complexType}}
5 | {{baseName}}: '{{complexType}}'
6 | {{else}}
7 | {{#if schemaIsFromAdditionalProperties}}
8 | {{#if addPropsUnset}}
9 | {{baseName}}: schemas.AnyTypeSchema
10 | {{else}}
11 | {{baseName}}: MetaOapg.additional_properties
12 | {{/if}}
13 | {{else}}
14 | {{baseName}}: MetaOapg.properties.{{baseName}}
15 | {{/if}}
16 | {{/if}}
17 | {{/unless}}
18 | {{/with}}
19 | {{/each}}
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/schema_accessed_types.handlebars:
--------------------------------------------------------------------------------
1 | {{#if isAnyType}}frozendict.frozendict, str, decimal.Decimal, BoolClass, NoneClass, tuple, bytes, FileIO{{/if}}{{#if isArray}}tuple, {{/if}}{{#if isMap}}frozendict.frozendict, {{/if}}{{#if isNull}}NoneClass, {{/if}}{{#if isString }}{{#neq format "binary"}}str, {{/neq}}{{#eq format "binary"}}bytes, FileIO, {{/eq}}{{/if}}{{#or isInteger isNumber}}decimal.Decimal, {{/or}}{{#if isBoolean}}BoolClass, {{/if}}
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/schema_dict.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 | class {{> model_templates/classname }}(
4 | schemas.DictSchema
5 | ):
6 | {{#if this.classname}}
7 | """NOTE: This class is auto generated by OpenAPI Generator.
8 | Ref: https://openapi-generator.tech
9 |
10 | Do not edit the class manually.
11 | {{#if description}}
12 |
13 | {{{unescapedDescription}}}
14 | {{/if}}
15 | """
16 | {{/if}}
17 | {{#if isStub}}
18 | {{#or additionalProperties getRequiredVarsMap getHasDiscriminatorWithNonEmptyMapping vars}}
19 |
20 |
21 | class MetaOapg:
22 | {{> model_templates/dict_partial }}
23 | {{/or}}
24 | {{else}}
25 | {{#or additionalProperties getRequiredVarsMap getHasDiscriminatorWithNonEmptyMapping vars hasValidation}}
26 |
27 |
28 | class MetaOapg:
29 | {{> model_templates/dict_partial }}
30 | {{> model_templates/validations }}
31 | {{/or}}
32 | {{/if}}
33 | {{> model_templates/property_type_hints }}
34 |
35 | {{> model_templates/new }}
36 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/schema_list.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 | class {{> model_templates/classname }}(
4 | schemas.ListSchema
5 | ):
6 | {{#if this.classname}}
7 | """NOTE: This class is auto generated by OpenAPI Generator.
8 | Ref: https://openapi-generator.tech
9 |
10 | Do not edit the class manually.
11 | {{#if description}}
12 |
13 | {{{unescapedDescription}}}
14 | {{/if}}
15 | """
16 | {{/if}}
17 | {{#if isStub}}
18 | {{#if items}}
19 |
20 |
21 | class MetaOapg:
22 | {{> model_templates/list_partial }}
23 | {{/if}}
24 | {{else}}
25 | {{#or getItems hasValidation}}
26 |
27 |
28 | class MetaOapg:
29 | {{#if hasValidation}}
30 | {{> model_templates/validations }}
31 | {{/if}}
32 | {{> model_templates/list_partial }}
33 | {{/or}}
34 | {{/if}}
35 |
36 | {{> model_templates/new }}
37 |
38 | def __getitem__(self, i: int) -> {{#with items}}{{#if complexType}}'{{complexType}}'{{else}}MetaOapg.items{{/if}}{{/with}}:
39 | return super().__getitem__(i)
40 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/schema_python_types.handlebars:
--------------------------------------------------------------------------------
1 | {{#if isAnyType}}dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, {{/if}}{{#if isArray}}list, tuple, {{/if}}{{#if isMap}}dict, frozendict.frozendict, {{/if}}{{#if isNull}}None, {{/if}}{{#if isString }}{{#neq format "binary"}}str, {{/neq}}{{#eq format "date"}}date, {{/eq}}{{#eq format "date-time"}}datetime, {{/eq}}{{#eq format "uuid"}}uuid.UUID, {{/eq}}{{#eq format "binary"}}bytes, io.FileIO, io.BufferedReader, {{/eq}}{{/if}}{{#if isInteger}}decimal.Decimal, int, {{/if}}{{#if isNumber}}decimal.Decimal, int, float, {{/if}}{{#if isBoolean}}bool, {{/if}}
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/schema_simple.handlebars:
--------------------------------------------------------------------------------
1 |
2 |
3 | class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}}(
4 | {{#if isEnum}}
5 | schemas.EnumBase,
6 | {{/if}}
7 | {{> model_templates/xbase_schema }}
8 | ):
9 | {{#if this.classname}}
10 | """NOTE: This class is auto generated by OpenAPI Generator.
11 | Ref: https://openapi-generator.tech
12 |
13 | Do not edit the class manually.
14 | {{#if description}}
15 |
16 | {{{unescapedDescription}}}
17 | {{/if}}
18 | """
19 | {{/if}}
20 | {{#unless isStub}}
21 | {{#or hasValidation isEnum getFormat}}
22 |
23 |
24 | class MetaOapg:
25 | {{#if getFormat}}
26 | format = '{{getFormat}}'
27 | {{/if}}
28 | {{> model_templates/validations }}
29 | {{#if isEnum}}
30 | {{#with allowableValues}}
31 | enum_value_to_name = {
32 | {{#each enumVars}}
33 | {{{value}}}: "{{name}}",
34 | {{/each}}
35 | }
36 | {{/with}}
37 | {{/if}}
38 | {{/or}}
39 | {{/unless}}
40 | {{#if isEnum}}
41 | {{> model_templates/enums }}
42 | {{/if}}
43 | {{#if isStub}}
44 | {{#if hasValidation}}
45 | {{#unless isEnum}}
46 | pass
47 | {{/unless}}
48 | {{/if}}
49 | {{/if}}
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/model_templates/var_equals_cls.handlebars:
--------------------------------------------------------------------------------
1 | {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}} = {{#or getIsBooleanSchemaTrue getIsBooleanSchemaFalse}}{{#if getIsBooleanSchemaTrue}}schemas.AnyTypeSchema{{else}}schemas.NotAnyTypeSchema{{/if}}{{else}}{{#if complexType}}{{complexType}}{{else}}schemas.{{#if isNullable}}Nullable{{/if}}{{#if getIsNull}}None{{/if}}{{#if isAnyType}}AnyType{{/if}}{{#if isMap}}Dict{{/if}}{{#if isArray}}List{{/if}}{{#if isString}}{{#eq format "date"}}Date{{/eq}}{{#eq format "date-time"}}DateTime{{/eq}}{{#eq format "uuid"}}UUID{{/eq}}{{#eq format "number"}}Decimal{{/eq}}{{#eq format "binary"}}Binary{{/eq}}{{#neq format "date"}}{{#neq format "date-time"}}{{#neq format "uuid"}}{{#neq format "number"}}{{#neq format "binary"}}Str{{/neq}}{{/neq}}{{/neq}}{{/neq}}{{/neq}}{{/if}}{{#if isInteger}}{{#eq format "int32"}}Int32{{/eq}}{{#eq format "int64"}}Int64{{/eq}}{{#neq format "int32"}}{{#neq format "int64"}}Int{{/neq}}{{/neq}}{{/if}}{{#if isNumber}}{{#eq format "float"}}Float32{{/eq}}{{#eq format "double"}}Float64{{/eq}}{{#neq format "float"}}{{#neq format "double"}}Number{{/neq}}{{/neq}}{{/if}}{{#if isBoolean}}Bool{{/if}}Schema{{/if}}{{/or}}
2 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/partial_header.handlebars:
--------------------------------------------------------------------------------
1 | """
2 | {{#if appName}}
3 | {{{appName}}}
4 | {{/if}}
5 |
6 | {{#if appDescription}}
7 | {{{appDescription}}} # noqa: E501
8 | {{/if}}
9 |
10 | {{#if version}}
11 | The version of the OpenAPI document: {{{version}}}
12 | {{/if}}
13 | {{#if infoEmail}}
14 | Contact: {{{infoEmail}}}
15 | {{/if}}
16 | Generated by: https://openapi-generator.tech
17 | """
18 |
--------------------------------------------------------------------------------
/assets/openapi/client-template/python/setup_cfg.handlebars:
--------------------------------------------------------------------------------
1 | {{#if useNose}}
2 | [nosetests]
3 | logging-clear-handlers=true
4 | verbosity=2
5 | randomize=true
6 | exe=true
7 | with-coverage=true
8 | cover-package={{{packageName}}}
9 | cover-erase=true
10 |
11 | {{/if}}
12 | [flake8]
13 | max-line-length=99
14 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/go/cors.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | package {{packageName}}
3 | // vim: set ft=go:
4 |
5 | import (
6 | "net/http"
7 |
8 | "github.com/go-chi/cors"
9 | )
10 |
11 | func CORS() func(http.Handler) http.Handler {
12 | // TODO(chebykinn): get the list of domains instead of wildcards
13 | // https://github.com/mify-io/mify/issues/75
14 | return cors.Handler(
15 | cors.Options{
16 | AllowCredentials: true,
17 | AllowedMethods: []string{
18 | http.MethodHead,
19 | http.MethodGet,
20 | http.MethodPost,
21 | http.MethodPut,
22 | http.MethodPatch,
23 | http.MethodDelete,
24 | },
25 | AllowedOrigins: []string{
26 | "*",
27 | },
28 | AllowedHeaders: []string{
29 | "*",
30 | },
31 | })
32 | }
33 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/go/ignore-list.txt:
--------------------------------------------------------------------------------
1 | /Dockerfile
2 | /README.md
3 | /go.mod
4 | /main.go
5 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/go/impl.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | // vim: set ft=go:
3 | package {{packageName}}
4 |
5 | //Implementation response defines an error code with the associated body
6 | type ServiceResponse struct {
7 | Code int
8 | {{#addResponseHeaders}}
9 | Headers map[string][]string
10 | {{/addResponseHeaders}}
11 | Body interface{}
12 | }
13 |
14 | type Dependencies struct {
15 | // handlers deps go here
16 | }
17 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/go/init/routes.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | // vim: set ft=go:
3 | package {{packageName}}_init
4 |
5 | import (
6 | {{#routers}}
7 | "github.com/go-chi/chi/v5"
8 | {{/routers}}
9 | "{{mifyGeneratedServicePackage}}/api"
10 | "{{mifyGeneratedServicePackage}}/core"
11 |
12 | {{#openAPI}}{{#paths}}
13 | {{#entrySet}}
14 | "{{goModule}}/internal/{{serviceName}}/handlers{{key}}"
15 | {{/entrySet}}
16 | {{/paths}}{{/openAPI}}
17 | )
18 |
19 | func Routes(ctx *core.MifyServiceContext, routerConfig openapi.RouterConfig, reqExtraFactory core.RequestExtraFactory) {{#routers}}chi.Router{{/routers}} {
20 | {{#apiInfo}}{{#apis}}
21 | {{classname}}Service := {{classFilename}}.New{{classname}}Service()
22 | {{classname}}Controller := {{packageName}}.New{{classname}}Controller(ctx, {{classname}}Service)
23 | {{/apis}}{{/apiInfo}}
24 | router := {{packageName}}.NewRouter(ctx, routerConfig, reqExtraFactory, {{#apiInfo}}{{#apis}}{{classname}}Controller{{^-last}}, {{/-last}}{{/apis}}{{/apiInfo}})
25 | return router
26 | }
27 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/go/metrics.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | // vim: set ft=go:
3 | package {{packageName}}
4 |
5 | import (
6 | "net/http"
7 | "time"
8 |
9 | "github.com/go-chi/chi/v5/middleware"
10 | "{{mifyGeneratedCommonPackage}}/metrics"
11 | )
12 |
13 | func Metrics() func(next http.Handler) http.Handler {
14 | return func(next http.Handler) http.Handler {
15 | fn := func(w http.ResponseWriter, r *http.Request) {
16 | ww := middleware.NewWrapResponseWriter(w, r.ProtoMajor)
17 |
18 | ctxBuilder := mustGetContextBuilder(r)
19 | start := time.Now().UTC()
20 |
21 | next.ServeHTTP(ww, r)
22 |
23 | ctxBuilder.GetMetrics().ReportRequestEnd(
24 | metrics.RequestInfo{
25 | ServiceName: ctxBuilder.ServiceContext().ServiceName(),
26 | Hostname: ctxBuilder.ServiceContext().Hostname(),
27 | URLPath: ctxBuilder.GetURLPath(),
28 | },
29 | ww.Status(),
30 | time.Since(start),
31 | int(r.ContentLength),
32 | ww.BytesWritten())
33 | }
34 | return http.HandlerFunc(fn)
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/go/openapi.mustache:
--------------------------------------------------------------------------------
1 | {{{openapi-yaml}}}
2 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/go/partial_header.mustache:
--------------------------------------------------------------------------------
1 | // THIS FILE IS AUTOGENERATED, DO NOT EDIT
2 | // Generated by mify via OpenAPI Generator
3 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/go/public/req_ctx_access.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | // vim: set ft=go:
3 | package {{packageName}}_public
4 |
5 | import (
6 | "net/http"
7 |
8 | "{{mifyGeneratedServicePackage}}/core"
9 | )
10 |
11 | type ctxKeyMifyContext int
12 |
13 | const MifyContextField ctxKeyMifyContext = 0
14 |
15 | // GetRequestContext allows getting current request context in between
16 | // middleware calls. This is useful for accessing sevice dependencies inside
17 | // middleware, while keeping the context flow intact.
18 | func GetMifyRequestContext(r *http.Request) *core.MifyRequestContext {
19 | return r.Context().Value(MifyContextField).(*core.MifyRequestContext)
20 | }
21 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/go/recoverer.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | // vim: set ft=go:
3 |
4 | package {{packageName}}
5 |
6 | import (
7 | "fmt"
8 | "os"
9 | "net/http"
10 | "runtime"
11 |
12 | "go.uber.org/zap"
13 | )
14 |
15 | func Recoverer() func(next http.Handler) http.Handler {
16 | const STACK_SIZE = 4 * 1024 * 1024 // 4 KB
17 | return func(next http.Handler) http.Handler {
18 | fn := func(w http.ResponseWriter, r *http.Request) {
19 | defer func() {
20 | if rc := recover(); rc != nil {
21 | if rc == http.ErrAbortHandler {
22 | panic(rc)
23 | }
24 | reqCtx := getMifyRequestContextBuilder(r)
25 | err, ok := rc.(error)
26 | if !ok {
27 | err = fmt.Errorf("%v", r)
28 | }
29 | var stack []byte
30 | var length int
31 |
32 | stack = make([]byte, STACK_SIZE)
33 | length = runtime.Stack(stack, true)
34 | stack = stack[:length]
35 | reqCtx.Logger().Error(
36 | "got panic in handler",
37 | zap.String("stacktrace", string(stack)), zap.Error(err))
38 | fmt.Fprintf(os.Stderr, "panic: %s", string(stack))
39 | w.WriteHeader(http.StatusInternalServerError)
40 | }
41 | }()
42 | next.ServeHTTP(w, r)
43 | }
44 | return http.HandlerFunc(fn)
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/go/swaggerui.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | package {{packageName}}
3 | // vim: set ft=go:
4 |
5 | import (
6 | _ "embed"
7 | "net/http"
8 |
9 | "github.com/flowchartsman/swaggerui"
10 | )
11 |
12 | //go:embed openapi.yaml
13 | var openapiYamlRaw []byte
14 |
15 | func SwaggerUIHandlerFunc(rw http.ResponseWriter, r *http.Request) {
16 | http.StripPrefix("/swagger-ui", swaggerui.Handler(openapiYamlRaw)).ServeHTTP(rw, r)
17 | }
18 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/app.mustache:
--------------------------------------------------------------------------------
1 | const ExpressServer = require('./expressServer');
2 | const logger = require('./logger');
3 | // const swaggerRouter = require('./utils/swaggerRouter');
4 |
5 | class App {
6 | constructor(config) {
7 | this.config = config;
8 | }
9 |
10 | async launch() {
11 | try {
12 | this.expressServer = new ExpressServer(this.config.URL_PORT, this.config.OPENAPI_YAML);
13 | // this.expressServer.app.use(swaggerRouter());
14 | await this.expressServer.launch();
15 | logger.info('Express server running');
16 | } catch (error) {
17 | logger.error(error);
18 | await this.close();
19 | }
20 | }
21 |
22 | async close() {
23 | if (this.expressServer !== undefined) {
24 | await this.expressServer.close();
25 | logger.info(`Server shut down on port ${this.config.URL_PORT}`);
26 | }
27 | }
28 | }
29 |
30 | module.exports = App;
31 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/config.mustache:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 |
3 | const config = {
4 | ROOT_DIR: __dirname,
5 | URL_PORT: {{serverPort}}{{^serverPort}}3000{{/serverPort}},
6 | URL_PATH: '{{serverHost}}{{^serverHost}}http://localhost{{/serverHost}}',
7 | BASE_VERSION: '{{contextPath}}{{^contextPath}}v2{{/contextPath}}',
8 | CONTROLLER_DIRECTORY: path.join(__dirname, 'controllers'),
9 | PROJECT_DIR: __dirname,
10 | };
11 | config.OPENAPI_YAML = path.join(config.ROOT_DIR, 'api', 'openapi.yaml');
12 | config.FULL_PATH = `${config.URL_PATH}:${config.URL_PORT}/${config.BASE_VERSION}`;
13 | config.FILE_UPLOAD_PATH = path.join(config.PROJECT_DIR, 'uploaded_files');
14 |
15 | module.exports = config;
16 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/config.yaml:
--------------------------------------------------------------------------------
1 | generatorName: nodejs-express-server
2 | templateDir: /repo/.mify/assets/openapi/server-template/js
3 | enableMinimalUpdate: true
4 | globalProperties: {}
5 | additionalProperties:
6 | serverPort: 8080
7 |
8 | releaseNote: Release note
9 | httpUserAgent: User Agent
10 |
11 | apiPackage: handlers
12 | modelPackage: models
13 |
14 | invokerPackage: unused
15 | # packageName: api
16 | apiNameSuffix: Api
17 | modelNamePrefix: ""
18 | modelNameSuffix: ""
19 | artifactVersion: ARTIFACT_VERSION
20 | library: ""
21 |
22 | instantiationTypes: {}
23 | typeMappings: {}
24 | importMappings: {}
25 | languageSpecificPrimitives: []
26 | reservedWordMappings: {}
27 | serverVariables: {}
28 |
29 | verbose: false
30 | skipOverwrite: false
31 | removeOperationIdPrefix: false
32 | skipOperationExample: false
33 | logToStderr: false
34 | validateSpec: true
35 | enablePostProcessFile: false
36 | strictSpecBehavior: true
37 | generateAliasAsModel: false
38 | templatingEngineName: mustache
39 | # ignoreFileOverride: ""
40 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/controller.mustache:
--------------------------------------------------------------------------------
1 | /**
2 | * The {{{classname}}}Controller file is a very simple one, which does not need to be changed manually,
3 | * unless there's a case where business logic routes the request to an entity which is not
4 | * the service.
5 | * The heavy lifting of the Controller item is done in Request.js - that is where request
6 | * parameters are extracted and sent to the service, and where response is handled.
7 | */
8 |
9 | const Controller = require('./Controller');
10 | const service = require('../services/{{{classname}}}Service');
11 | {{#operations}}
12 | {{#operation}}
13 | const {{operationId}} = async (request, response) => {
14 | await Controller.handleRequest(request, response, service.{{operationId}});
15 | };
16 |
17 | {{/operation}}
18 | {{/operations}}
19 |
20 | module.exports = {
21 | {{#operations}}
22 | {{#operation}}
23 | {{operationId}},
24 | {{/operation}}
25 | {{/operations}}
26 | };
27 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/controllers/index.mustache:
--------------------------------------------------------------------------------
1 | {{#apiInfo}}
2 | {{#apis}}
3 | {{#operations}}
4 | {{#operation}}
5 | {{#-first}}
6 | const {{classname}}Controller = require('./{{classname}}Controller');
7 | {{/-first}}
8 | {{/operation}}
9 | {{/operations}}
10 | {{/apis}}
11 | {{/apiInfo}}
12 |
13 | module.exports = {
14 | {{#apiInfo}}
15 | {{#apis}}
16 | {{#operations}}
17 | {{#operation}}
18 | {{#-first}}
19 | {{classname}}Controller,
20 | {{/-first}}
21 | {{/operation}}
22 | {{/operations}}
23 | {{/apis}}
24 | {{/apiInfo}}
25 | };
26 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/eslintrc.mustache:
--------------------------------------------------------------------------------
1 | // Use this file as a starting point for your project's .eslintrc.
2 | // Copy this file, and add rule overrides as needed.
3 | {
4 | "extends": "airbnb-base",
5 | "rules": {
6 | "no-console": "off"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/ignore-list.txt:
--------------------------------------------------------------------------------
1 | /Dockerfile
2 | /README.md
3 | /.gitignore
4 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/index.mustache:
--------------------------------------------------------------------------------
1 | const config = require('../mify-generated/services/{{serviceName}}/config');
2 | const logger = require('../mify-generated/services/{{serviceName}}/logger');
3 | const ExpressServer = require('../mify-generated/services/{{serviceName}}/expressServer');
4 |
5 | const launchServer = async () => {
6 | try {
7 | this.expressServer = new ExpressServer(config.URL_PORT, config.OPENAPI_YAML);
8 | this.expressServer.launch();
9 | logger.info('Express server running');
10 | } catch (error) {
11 | logger.error('Express Server failure', error.message);
12 | await this.close();
13 | }
14 | };
15 |
16 | launchServer().catch(e => logger.error(e));
17 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/logger.mustache:
--------------------------------------------------------------------------------
1 | const { transports, createLogger, format } = require('winston');
2 |
3 | const logger = createLogger({
4 | level: 'info',
5 | format: format.combine(
6 | format.timestamp(),
7 | format.json(),
8 | ),
9 | defaultMeta: { service: 'user-service' },
10 | transports: [
11 | new transports.Console(),
12 | new transports.File({ filename: 'error.log', level: 'error', timestamp: true }),
13 | new transports.File({ filename: 'combined.log', timestamp: true }),
14 | ],
15 | });
16 |
17 | if (process.env.NODE_ENV !== 'production') {
18 | logger.add(new transports.Console({ format: format.simple() }));
19 | }
20 |
21 | module.exports = logger;
22 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/openapi.mustache:
--------------------------------------------------------------------------------
1 | {{{openapi-yaml}}}
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/package.mustache:
--------------------------------------------------------------------------------
1 | {
2 | "name": "{{projectName}}",
3 | "version": "{{appVersion}}",
4 | "description": "{{{appDescription}}}",
5 | "main": "index.js",
6 | "scripts": {
7 | "prestart": "npm install",
8 | "start": "node index.js",
9 | "dev": "node index.js"
10 | },
11 | "keywords": [
12 | "openapi-generator",
13 | "openapi"
14 | ],
15 | "license": "Unlicense",
16 | "private": true,
17 | "dependencies": {
18 | "body-parser": "^1.19.0",
19 | "camelcase": "^5.3.1",
20 | "cookie-parser": "^1.4.4",
21 | "cors": "^2.8.5",
22 | "express": "^4.18.2",
23 | "express-openapi-validator": "^5.0.4",
24 | "js-yaml": "^3.3.0",
25 | "ono": "^5.0.1",
26 | "openapi-sampler": "^1.0.0-beta.15",
27 | "swagger-ui-express": "^4.0.2",
28 | "winston": "^3.2.1"
29 | },
30 | "devDependencies": {
31 | "axios": "^0.19.0",
32 | "chai": "^4.2.0",
33 | "chai-as-promised": "^7.1.1",
34 | "eslint": "^5.16.0",
35 | "eslint-config-airbnb-base": "^14.0.0",
36 | "eslint-plugin-import": "^2.17.2",
37 | "mocha": "^7.1.1",
38 | "typescript": "^5.1.3"
39 | },
40 | "eslintConfig": {
41 | "env": {
42 | "node": true
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/service.mustache:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-unused-vars */
2 | const Service = require('./Service');
3 |
4 | {{#operations}}
5 | {{#operation}}
6 | /**
7 | {{#summary}}
8 | * {{{.}}}
9 | {{/summary}}
10 | {{#notes}}
11 | * {{{.}}}
12 | {{/notes}}
13 | *
14 | {{#allParams}}
15 | * {{paramName}} {{{dataType}}} {{{description}}}{{^required}} (optional){{/required}}
16 | {{/allParams}}
17 | {{^returnType}}
18 | * no response value expected for this operation
19 | {{/returnType}}
20 | {{#returnType}}
21 | * returns {{{.}}}
22 | {{/returnType}}
23 | * */
24 | const {{{operationId}}} = ({{#allParams}}{{#-first}}{ {{/-first}}{{paramName}}{{^-last}}, {{/-last}}{{#-last}} }{{/-last}}{{/allParams}}) => new Promise(
25 | async (resolve, reject) => {
26 | try {
27 | resolve(Service.successResponse({
28 | {{#allParams}}
29 | {{paramName}},
30 | {{/allParams}}
31 | }));
32 | } catch (e) {
33 | reject(Service.rejectResponse(
34 | e.message || 'Invalid input',
35 | e.status || 405,
36 | ));
37 | }
38 | },
39 | );
40 | {{/operation}}
41 | {{/operations}}
42 |
43 | module.exports = {
44 | {{#operations}}
45 | {{#operation}}
46 | {{operationId}},
47 | {{/operation}}
48 | {{/operations}}
49 | };
50 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/services/Service.mustache:
--------------------------------------------------------------------------------
1 | class Service {
2 | static rejectResponse(error, code = 500) {
3 | return { error, code };
4 | }
5 |
6 | static successResponse(payload, code = 200) {
7 | return { payload, code };
8 | }
9 | }
10 |
11 | module.exports = Service;
12 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/services/index.mustache:
--------------------------------------------------------------------------------
1 | {{#apiInfo}}
2 | {{#apis}}
3 | {{#operations}}
4 | {{#operation}}
5 | {{#-first}}
6 | const {{classname}}Service = require('./{{classname}}Service');
7 | {{/-first}}
8 | {{/operation}}
9 | {{/operations}}
10 | {{/apis}}
11 | {{/apiInfo}}
12 |
13 | module.exports = {
14 | {{#apiInfo}}
15 | {{#apis}}
16 | {{#operations}}
17 | {{#operation}}
18 | {{#-first}}
19 | {{classname}}Service,
20 | {{/-first}}
21 | {{/operation}}
22 | {{/operations}}
23 | {{/apis}}
24 | {{/apiInfo}}
25 | };
26 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/js/utils/writer.mustache:
--------------------------------------------------------------------------------
1 | var ResponsePayload = function(code, payload) {
2 | this.code = code;
3 | this.payload = payload;
4 | }
5 |
6 | exports.respondWithCode = function(code, payload) {
7 | return new ResponsePayload(code, payload);
8 | }
9 |
10 | var writeJson = exports.writeJson = function(response, arg1, arg2) {
11 | var code;
12 | var payload;
13 |
14 | if(arg1 && arg1 instanceof ResponsePayload) {
15 | writeJson(response, arg1.payload, arg1.code);
16 | return;
17 | }
18 |
19 | if(arg2 && Number.isInteger(arg2)) {
20 | code = arg2;
21 | }
22 | else {
23 | if(arg1 && Number.isInteger(arg1)) {
24 | code = arg1;
25 | }
26 | }
27 | if(code && arg1) {
28 | payload = arg1;
29 | }
30 | else if(arg1) {
31 | payload = arg1;
32 | }
33 |
34 | if(!code) {
35 | // if no response code given, we default to 200
36 | code = 200;
37 | }
38 | if(typeof payload === 'object') {
39 | payload = JSON.stringify(payload, null, 2);
40 | }
41 | response.writeHead(code, {'Content-Type': 'application/json'});
42 | response.end(payload);
43 | }
44 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/python/__init__.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/python/__init__main.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 | import os
4 | import connexion
5 | {{#featureCORS}}
6 | import aiohttp_cors
7 | {{/featureCORS}}
8 |
9 | def main():
10 | options = {
11 | "swagger_ui": True
12 | }
13 | specification_dir = os.path.join(os.path.dirname(__file__), 'openapi')
14 | app = connexion.AioHttpApp(__name__, specification_dir=specification_dir, options=options)
15 | app.add_api('openapi.yaml',
16 | arguments={'title': '{{appName}}'},
17 | pythonic_params=True,
18 | pass_context_arg_name='request')
19 |
20 | {{#featureCORS}}
21 | # Enable CORS for all origins.
22 | cors = aiohttp_cors.setup(app.app, defaults={
23 | "*": aiohttp_cors.ResourceOptions(
24 | allow_credentials=True,
25 | expose_headers="*",
26 | allow_headers="*",
27 | )
28 | })
29 |
30 | # Register all routers for CORS.
31 | for route in list(app.app.router.routes()):
32 | cors.add(route)
33 |
34 | {{/featureCORS}}
35 | app.run(port={{serverPort}})
36 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/python/__init__model.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 |
4 | # import models into model package
5 | {{#models}}{{#model}}from {{packageName}}.{{modelPackage}}.{{classFilename}} import {{classname}}{{/model}}
6 | {{/models}}
7 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/python/__main__.mustache:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | {{>partial_header}}
3 | # vim: set ft=python:
4 |
5 | from . import main
6 |
7 | if __name__ == '__main__':
8 | main()
9 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/python/conftest.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 | import logging
4 | import pytest
5 | import os
6 |
7 | import connexion
8 |
9 |
10 | @pytest.fixture
11 | def client(loop, aiohttp_client):
12 | logging.getLogger('connexion.operation').setLevel('ERROR')
13 | options = {
14 | "swagger_ui": True
15 | }
16 | specification_dir = os.path.join(os.path.dirname(__file__), '..',{{#pythonSrcRoot}}
17 | "{{{.}}}",{{/pythonSrcRoot}}
18 | '{{packageName}}',
19 | 'openapi')
20 | app = connexion.AioHttpApp(__name__, specification_dir=specification_dir,
21 | options=options)
22 | app.add_api('openapi.yaml', pythonic_params=True,
23 | pass_context_arg_name='request')
24 | return loop.run_until_complete(aiohttp_client(app.app))
25 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/python/ignore-list.txt:
--------------------------------------------------------------------------------
1 | /Dockerfile
2 | /README.md
3 | /.gitignore
4 | /requirements.txt
5 | /test-requirements.txt
6 | /tox.ini
7 | /tests/*
8 | /setup.py
9 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/python/openapi.mustache:
--------------------------------------------------------------------------------
1 | {{{openapi-yaml}}}
--------------------------------------------------------------------------------
/assets/openapi/server-template/python/param_type.mustache:
--------------------------------------------------------------------------------
1 | {{#isString}}str{{/isString}}{{#isInteger}}int{{/isInteger}}{{#isLong}}int{{/isLong}}{{#isFloat}}float{{/isFloat}}{{#isDouble}}float{{/isDouble}}{{#isByteArray}}str{{/isByteArray}}{{#isBinary}}str{{/isBinary}}{{#isBoolean}}bool{{/isBoolean}}{{#isDate}}str{{/isDate}}{{#isDateTime}}str{{/isDateTime}}
--------------------------------------------------------------------------------
/assets/openapi/server-template/python/partial_header.mustache:
--------------------------------------------------------------------------------
1 | # THIS FILE IS AUTOGENERATED, DO NOT EDIT
2 | # Generated by mify via OpenAPI Generator
3 |
--------------------------------------------------------------------------------
/assets/openapi/server-template/python/typing_utils.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | # vim: set ft=python:
3 |
4 | import sys
5 |
6 | if sys.version_info < (3, 7):
7 | import typing
8 |
9 | def is_generic(klass):
10 | """ Determine whether klass is a generic class """
11 | return type(klass) == typing.GenericMeta
12 |
13 | def is_dict(klass):
14 | """ Determine whether klass is a Dict """
15 | return klass.__extra__ == dict
16 |
17 | def is_list(klass):
18 | """ Determine whether klass is a List """
19 | return klass.__extra__ == list
20 |
21 | else:
22 |
23 | def is_generic(klass):
24 | """ Determine whether klass is a generic class """
25 | return hasattr(klass, '__origin__')
26 |
27 | def is_dict(klass):
28 | """ Determine whether klass is a Dict """
29 | return klass.__origin__ == dict
30 |
31 | def is_list(klass):
32 | """ Determine whether klass is a List """
33 | return klass.__origin__ == list
34 |
--------------------------------------------------------------------------------
/cmd/mify/cmd/generate.go:
--------------------------------------------------------------------------------
1 | package cmd
2 |
3 | import (
4 | "context"
5 | "errors"
6 | "fmt"
7 | "os"
8 |
9 | "github.com/mify-io/mify/internal/mify"
10 | "github.com/spf13/cobra"
11 | )
12 |
13 | var (
14 | migrate bool
15 | force bool
16 | )
17 |
18 | // genCmd represents the gen command
19 | var genCmd = &cobra.Command{
20 | Use: "generate [service]...",
21 | Short: "Generate code in workspace",
22 | Long: `Generate code for given list of services after schema changes.`,
23 | PersistentPreRun: func(*cobra.Command, []string) {
24 | err := appContext.LoadWorkspace()
25 | if err != nil {
26 | fmt.Fprintf(os.Stderr, "failed to init workspace: %s\n", err)
27 | os.Exit(2)
28 | }
29 | },
30 | Run: func(cmd *cobra.Command, args []string) {
31 | if err := mify.ServiceGenerateMany(appContext, workspacePath, args, migrate, force); err != nil {
32 | if errors.Is(err, context.Canceled) {
33 | return
34 | }
35 | fmt.Fprintf(os.Stderr, "%s", err)
36 | os.Exit(2)
37 | }
38 | },
39 | }
40 |
41 | func init() {
42 | genCmd.Flags().BoolVarP(
43 | &migrate,
44 | "migrate", "m", true, "Should code migrations be applied?",
45 | )
46 | genCmd.Flags().BoolVarP(
47 | &force,
48 | "force", "f", false, "Force complete regeneration",
49 | )
50 | }
51 |
--------------------------------------------------------------------------------
/cmd/mify/cmd/init.go:
--------------------------------------------------------------------------------
1 | package cmd
2 |
3 | import (
4 | "fmt"
5 | "os"
6 |
7 | "github.com/mify-io/mify/internal/mify"
8 | "github.com/spf13/cobra"
9 | )
10 |
11 | var (
12 | vcsTemplate string
13 | )
14 |
15 | // initCmd represents the init command
16 | var initCmd = &cobra.Command{
17 | Use: "init",
18 | Short: "Initialize new workspace",
19 | Long: `Initialize new workspace`,
20 | Run: func(cmd *cobra.Command, args []string) {
21 | workspaceName := "."
22 | if len(args) > 0 {
23 | workspaceName = args[0]
24 | }
25 |
26 | if err := mify.CreateWorkspace(appContext, workspacePath, workspaceName, vcsTemplate); err != nil {
27 | fmt.Fprintf(os.Stderr, "failed to create workspace: %s\n", err)
28 | os.Exit(2)
29 | }
30 | },
31 | }
32 |
33 | func init() {
34 | initCmd.LocalFlags().StringVar(&vcsTemplate, "vcs", "git", "[git|none]")
35 | }
36 |
--------------------------------------------------------------------------------
/cmd/mify/cmd/run.go:
--------------------------------------------------------------------------------
1 | package cmd
2 |
3 | import (
4 | "fmt"
5 | "os"
6 |
7 | "github.com/mify-io/mify/internal/mify"
8 | "github.com/spf13/cobra"
9 | )
10 |
11 | // initCmd represents the init command
12 | var runCmd = &cobra.Command{
13 | Use: "run",
14 | Short: "Run all go services",
15 | Long: `Run all go services in one dev-runner process`,
16 | PersistentPreRun: func(*cobra.Command, []string) {
17 | err := appContext.LoadWorkspace()
18 | if err != nil {
19 | fmt.Fprintf(os.Stderr, "failed to init workspace: %s\n", err)
20 | os.Exit(2)
21 | }
22 | },
23 | Run: func(cmd *cobra.Command, args []string) {
24 | if err := mify.Run(appContext, workspacePath); err != nil {
25 | fmt.Fprintf(os.Stderr, "failed to run app: %s\n", err)
26 | os.Exit(2)
27 | }
28 | },
29 | }
30 |
31 | func init() {
32 | }
33 |
--------------------------------------------------------------------------------
/cmd/mify/cmd/tool.go:
--------------------------------------------------------------------------------
1 | package cmd
2 |
3 | import (
4 | "fmt"
5 | "os"
6 |
7 | "github.com/mify-io/mify/internal/mify"
8 | "github.com/spf13/cobra"
9 | )
10 |
11 | var migrateCmd = &cobra.Command{
12 | Use: "migrate
9 | Edit src/App.tsx
and save to reload.
10 |