Is there a computer science theory behind automatic source code generation The OpenAPI specification aims at standardizing the representation of REST based systems in json and yaml formats. A short version of the petstore is below:

{
 "swagger": "2.0",
 "info": {},
 "host": "petstore.swagger.io",
 "basePath": "/v2",
  "tags": [],
  "schemes": [
 "http"
 ],
 "paths": {},
 "securityDefinitions": {},
 "definitions": {},
 "externalDocs": {
 "description": "Find out more about Swagger",
 "url": "http://swagger.io"
 }
}


Based on this document, client and server stubs can be generated in different programming languages/frameworks using the OpenAPI codegen project. Is there a computer science theory behind this ? To be more precise, I want to specifically know if there are theoretical concepts behind taking an input, (in this case a json/yaml document) and getting a source code representation in one or more programming languages that represents the initial input ?
I don't know anything about it but the field as a whole is called "automatic programming", which should give you pointers of where to look.